⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmpt.c

📁 Wget很好的处理了http和ftp的下载,很值得学习的经典代码
💻 C
📖 第 1 页 / 共 4 页
字号:
            return NULL;          break;        case 's':          {            /* The number of seconds may be very high so we cannot use               the `get_number' macro.  Instead read the number               character for character and construct the result while               doing this.  */            time_t secs = 0;            if (*rp < '0' || *rp > '9')              /* We need at least one digit.  */              return NULL;            do              {                secs *= 10;                secs += *rp++ - '0';              }            while (*rp >= '0' && *rp <= '9');            if (localtime_r (&secs, tm) == NULL)              /* Error in function.  */              return NULL;          }          break;        case 'S':          get_number (0, 61, 2);          tm->tm_sec = val;          break;        case 'X':#ifdef _NL_CURRENT          if (*decided != raw)            {              if (!recursive (_NL_CURRENT (LC_TIME, T_FMT)))                {                  if (*decided == loc)                    return NULL;                  else                    rp = rp_backup;                }              else                {                  if (strcmp (_NL_CURRENT (LC_TIME, T_FMT), HERE_T_FMT))                    *decided = loc;                  break;                }              *decided = raw;            }#endif          /* Fall through.  */        case 'T':          if (!recursive (HERE_T_FMT))            return NULL;          break;        case 'u':          get_number (1, 7, 1);          tm->tm_wday = val % 7;          have_wday = 1;          break;        case 'g':          get_number (0, 99, 2);          /* XXX This cannot determine any field in TM.  */          break;        case 'G':          if (*rp < '0' || *rp > '9')            return NULL;          /* XXX Ignore the number since we would need some more             information to compute a real date.  */          do            ++rp;          while (*rp >= '0' && *rp <= '9');          break;        case 'U':        case 'V':        case 'W':          get_number (0, 53, 2);          /* XXX This cannot determine any field in TM without some             information.  */          break;        case 'w':          /* Match number of weekday.  */          get_number (0, 6, 1);          tm->tm_wday = val;          have_wday = 1;          break;        case 'y':          /* Match year within century.  */          get_number (0, 99, 2);          /* The "Year 2000: The Millennium Rollover" paper suggests that             values in the range 69-99 refer to the twentieth century.  */          tm->tm_year = val >= 69 ? val : val + 100;          /* Indicate that we want to use the century, if specified.  */          want_century = 1;          want_xday = 1;          break;        case 'Y':          /* Match year including century number.  */          get_number (0, 9999, 4);          tm->tm_year = val - 1900;          want_century = 0;          want_xday = 1;          break;        case 'Z':          /* XXX How to handle this?  */          break;        case 'E':#ifdef _NL_CURRENT          switch (*fmt++)            {            case 'c':              /* Match locale's alternate date and time format.  */              if (*decided != raw)                {                  const char *fmt = _NL_CURRENT (LC_TIME, ERA_D_T_FMT);                  if (*fmt == '\0')                    fmt = _NL_CURRENT (LC_TIME, D_T_FMT);                  if (!recursive (fmt))                    {                      if (*decided == loc)                        return NULL;                      else                        rp = rp_backup;                    }                  else                    {                      if (strcmp (fmt, HERE_D_T_FMT))                        *decided = loc;                      want_xday = 1;                      break;                    }                  *decided = raw;                }              /* The C locale has no era information, so use the                 normal representation.  */              if (!recursive (HERE_D_T_FMT))                return NULL;              want_xday = 1;              break;            case 'C':            case 'y':            case 'Y':              /* Match name of base year in locale's alternate                 representation.  */              /* XXX This is currently not implemented.  It should                 use the value _NL_CURRENT (LC_TIME, ERA).  */              break;            case 'x':              if (*decided != raw)                {                  const char *fmt = _NL_CURRENT (LC_TIME, ERA_D_FMT);                  if (*fmt == '\0')                    fmt = _NL_CURRENT (LC_TIME, D_FMT);                  if (!recursive (fmt))                    {                      if (*decided == loc)                        return NULL;                      else                        rp = rp_backup;                    }                  else                    {                      if (strcmp (fmt, HERE_D_FMT))                        *decided = loc;                      break;                    }                  *decided = raw;                }              if (!recursive (HERE_D_FMT))                return NULL;              break;            case 'X':              if (*decided != raw)                {                  const char *fmt = _NL_CURRENT (LC_TIME, ERA_T_FMT);                  if (*fmt == '\0')                    fmt = _NL_CURRENT (LC_TIME, T_FMT);                  if (!recursive (fmt))                    {                      if (*decided == loc)                        return NULL;                      else                        rp = rp_backup;                    }                  else                    {                      if (strcmp (fmt, HERE_T_FMT))                        *decided = loc;                      break;                    }                  *decided = raw;                }              if (!recursive (HERE_T_FMT))                return NULL;              break;            default:              return NULL;            }          break;#else          /* We have no information about the era format.  Just use             the normal format.  */          if (*fmt != 'c' && *fmt != 'C' && *fmt != 'y' && *fmt != 'Y'              && *fmt != 'x' && *fmt != 'X')            /* This is an illegal format.  */            return NULL;          goto start_over;#endif        case 'O':          switch (*fmt++)            {            case 'd':            case 'e':              /* Match day of month using alternate numeric symbols.  */              get_alt_number (1, 31, 2);              tm->tm_mday = val;              have_mday = 1;              want_xday = 1;              break;            case 'H':              /* Match hour in 24-hour clock using alternate numeric                 symbols.  */              get_alt_number (0, 23, 2);              tm->tm_hour = val;              have_I = 0;              break;            case 'I':              /* Match hour in 12-hour clock using alternate numeric                 symbols.  */              get_alt_number (1, 12, 2);              tm->tm_hour = val - 1;              have_I = 1;              break;            case 'm':              /* Match month using alternate numeric symbols.  */              get_alt_number (1, 12, 2);              tm->tm_mon = val - 1;              have_mon = 1;              want_xday = 1;              break;            case 'M':              /* Match minutes using alternate numeric symbols.  */              get_alt_number (0, 59, 2);              tm->tm_min = val;              break;            case 'S':              /* Match seconds using alternate numeric symbols.  */              get_alt_number (0, 61, 2);              tm->tm_sec = val;              break;            case 'U':            case 'V':            case 'W':              get_alt_number (0, 53, 2);              /* XXX This cannot determine any field in TM without                 further information.  */              break;            case 'w':              /* Match number of weekday using alternate numeric symbols.  */              get_alt_number (0, 6, 1);              tm->tm_wday = val;              have_wday = 1;              break;            case 'y':              /* Match year within century using alternate numeric symbols.  */              get_alt_number (0, 99, 2);              tm->tm_year = val >= 69 ? val : val + 100;              want_xday = 1;              break;            default:              return NULL;            }          break;        default:          return NULL;        }    }  if (have_I && is_pm)    tm->tm_hour += 12;  if (century != -1)    {      if (want_century)        tm->tm_year = tm->tm_year % 100 + (century - 19) * 100;      else        /* Only the century, but not the year.  Strange, but so be it.  */        tm->tm_year = (century - 19) * 100;    }  if (want_xday && !have_wday) {      if ( !(have_mon && have_mday) && have_yday)  {          /* we don't have tm_mon and/or tm_mday, compute them */          int t_mon = 0;          while (__mon_yday[__isleap(1900 + tm->tm_year)][t_mon] <= tm->tm_yday)              t_mon++;          if (!have_mon)              tm->tm_mon = t_mon - 1;          if (!have_mday)              tm->tm_mday = tm->tm_yday - __mon_yday[__isleap(1900 + tm->tm_year)][t_mon - 1] + 1;      }      day_of_the_week (tm);  }  if (want_xday && !have_yday)    day_of_the_year (tm);  return (char *) rp;}char *strptime (buf, format, tm)     const char *buf;     const char *format;     struct tm *tm;{  enum locale_status decided;#ifdef _NL_CURRENT  decided = not;#else  decided = raw;#endif  return strptime_internal (buf, format, tm, &decided);}#endif /* not HAVE_STRPTIME */#ifdef NEED_MON_YDAYconst unsigned short int __mon_yday[2][13] =  {    /* Normal years.  */    { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },    /* Leap years.  */    { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }  };#endif/* fnmatch is required by POSIX, but we include an implementation for   the sake of systems that don't have it, most notably Windows.  Some   systems do have fnmatch, but Apache's installation process installs   its own fnmatch.h (incompatible with the system one!) in a system   include directory, effectively rendering fnmatch unusable.  This   has been fixed with Apache 2, where fnmatch has been moved to apr   and given a prefix, but many systems out there are still (as of   this writing in 2005) broken and we must cater to them.   Additionally, according to some conventional wisdom, many   historical implementations of fnmatch are buggy and unreliable.  If   yours is such, undefine SYSTEM_FNMATCH in sysdep.h and tell us   about it.  */#ifndef SYSTEM_FNMATCH

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -