diff options
author | Xavier Roche <xroche@users.noreply.github.com> | 2013-05-14 20:30:28 +0000 |
---|---|---|
committer | Xavier Roche <xroche@users.noreply.github.com> | 2013-05-14 20:30:28 +0000 |
commit | 07f4b003675260004c49755dde413944a16ca2d3 (patch) | |
tree | 11050b4c7fbe1d7c63a38f5f9a6b5ba6d8260ae1 /src/proxy/proxytrack.h | |
parent | b09def438c5e47305e4a5ab18d8a646a3b004fdc (diff) |
Indenting cleanup for all *.[ch] files, except htsparse.c (too ugly to be automatically indented for now) and /minizip/, /mmsrip/ (external files)
setup:
indent -l80 -lc80 -nhnl -nut -bad -bap -bbo -br -brf -bli2 -brs -bls -br -ss -sai -pmt -nsaw -nsaf -nprs -i2 -ce -npsl -npcs -cs -sob -cdw -nbc -lp
logs:
indent: ./src/htsback.c:157: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsback.c:1417: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsback.c:1826: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsback.c:1833: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsback.c:1981: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsback.c:2685: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsback.c:2747: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsback.c:2861: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsback.c:3128: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsback.c:3512: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htswizard.c:140: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htswizard.c:597: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htswizard.c:598: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htswizard.c:611: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htscoremain.c:97: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htscoremain.c:106: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htscoremain.c:106: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htscoremain.c:256: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htscoremain.c:262: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htscoremain.c:935: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:271: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:272: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:273: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:274: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:275: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:276: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:277: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:278: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:279: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:280: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:281: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:662: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/httrack.c:752: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsweb.c:413: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsweb.c:414: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsweb.c:415: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsweb.c:416: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsweb.c:417: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsweb.c:418: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsweb.c:419: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsweb.c:420: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsweb.c:421: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsweb.c:422: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsweb.c:423: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.c:188: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.c:507: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.c:508: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.c:509: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.c:510: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.c:511: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.c:512: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.c:580: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.c:581: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.h:115: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.h:246: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.h:247: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.h:248: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.h:249: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.h:250: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.h:251: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.h:314: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/proxy/proxytrack.h:315: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htstools.c:151: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htstools.c:158: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htstools.c:161: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htstools.c:166: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htstools.c:174: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htstools.c:177: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htstools.c:188: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htstools.c:243: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htstools.c:245: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htstools.c:248: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htstools.c:257: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htstools.c:647: Warning:old style assignment ambiguity in "=*". Assuming "= *"
indent: ./src/htsbauth.c:364: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htsbauth.c:387: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htscache.c:473: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsserver.h:112: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsserver.h:187: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsjava.c:312: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsjava.c:379: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htsjava.c:407: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsjava.c:472: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htsjava.c:483: Warning:old style assignment ambiguity in "=*". Assuming "= *"
indent: ./src/htslib.c:593: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:809: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:1743: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:1874: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:1896: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:1984: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:2085: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:2604: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:2605: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:2606: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:2607: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:2608: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:2609: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:2672: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:2673: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:2906: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:2928: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:2996: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:4802: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htslib.c:5353: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:5354: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:5355: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:5357: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:5429: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htslib.c:5435: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htscore.c:208: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htscore.c:277: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htscore.c:279: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htscore.c:357: Warning:old style assignment ambiguity in "=*". Assuming "= *"
indent: ./src/htscore.c:394: Warning:old style assignment ambiguity in "=*". Assuming "= *"
indent: ./src/htscore.c:1544: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htscore.c:3330: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htscore.c:3361: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htshash.c:140: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htshash.c:217: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsname.c:733: Warning:old style assignment ambiguity in "=*". Assuming "= *"
indent: ./src/htsname.c:749: Warning:old style assignment ambiguity in "=*". Assuming "= *"
indent: ./src/htsname.c:933: Warning:old style assignment ambiguity in "=*". Assuming "= *"
indent: ./src/htsname.c:1520: Warning:old style assignment ambiguity in "=*". Assuming "= *"
indent: ./src/htszlib.c:76: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htszlib.c:81: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htscatchurl.c:268: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsinthash.c:156: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htsinthash.c:159: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htsinthash.c:176: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htsinthash.c:179: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htsinthash.c:226: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htsinthash.c:253: Warning:old style assignment ambiguity in "=&". Assuming "= &"
indent: ./src/htsftp.c:169: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsftp.c:177: Warning:old style assignment ambiguity in "=-". Assuming "= -"
indent: ./src/htsfilters.c:67: Warning:old style assignment ambiguity in "=*". Assuming "= *"
indent: ./src/htsfilters.c:80: Warning:old style assignment ambiguity in "=*". Assuming "= *"
Diffstat (limited to 'src/proxy/proxytrack.h')
-rw-r--r-- | src/proxy/proxytrack.h | 328 |
1 files changed, 182 insertions, 146 deletions
diff --git a/src/proxy/proxytrack.h b/src/proxy/proxytrack.h index ae5af27..6152919 100644 --- a/src/proxy/proxytrack.h +++ b/src/proxy/proxytrack.h @@ -53,9 +53,8 @@ Please visit our Website: http://www.httrack.com /* generic */ -int proxytrack_main(char* proxyAddr, int proxyPort, - char* icpAddr, int icpPort, - PT_Indexes index); +int proxytrack_main(char *proxyAddr, int proxyPort, char *icpAddr, int icpPort, + PT_Indexes index); /* Spaces: CR,LF,TAB,FF */ #define is_space(c) ( ((c)==' ') || ((c)=='\"') || ((c)==10) || ((c)==13) || ((c)==9) || ((c)==12) || ((c)==11) || ((c)=='\'') ) @@ -71,6 +70,7 @@ static void proxytrack_print_log(const char *severity, const char *format, ...) const int error = errno; FILE *const fp = stderr; va_list args; + fprintf(fp, " * %s: ", severity); va_start(args, format); (void) vfprintf(fp, format, args); @@ -110,90 +110,105 @@ static void proxytrack_print_log(const char *severity, const char *format, ...) "<!-- _-._.--._._-._.--._._-._.--._._-._.--._._-._.--._. -->\r\n" \ "<!-- End Disable IE Friendly HTTP Error Messages -->\r\n" -static char* gethomedir(void) { - char* home = getenv( "HOME" ); +static char *gethomedir(void) { + char *home = getenv("HOME"); + if (home) return home; else return "."; } -static int linput(FILE* fp,char* s,int max) { +static int linput(FILE * fp, char *s, int max) { int c; - int j=0; + int j = 0; + do { - c=fgetc(fp); - if (c!=EOF) { - switch(c) { - case 13: break; // sauter CR - case 10: c=-1; break; - case 0: case 9: case 12: break; // sauter ces caractères - default: s[j++]=(char) c; break; + c = fgetc(fp); + if (c != EOF) { + switch (c) { + case 13: + break; // sauter CR + case 10: + c = -1; + break; + case 0: + case 9: + case 12: + break; // sauter ces caractères + default: + s[j++] = (char) c; + break; } } - } while((c!=-1) && (c!=EOF) && (j<(max-1))); - s[j]='\0'; + } while((c != -1) && (c != EOF) && (j < (max - 1))); + s[j] = '\0'; return j; } -static int link_has_authority(const char* lien) { - const char* a=lien; - if (isalpha((const unsigned char)*a)) { +static int link_has_authority(const char *lien) { + const char *a = lien; + + if (isalpha((const unsigned char) *a)) { // Skip scheme? - while (isalpha((const unsigned char)*a)) + while(isalpha((const unsigned char) *a)) a++; if (*a == ':') a++; else return 0; } - if (strncmp(a,"//",2) == 0) + if (strncmp(a, "//", 2) == 0) return 1; return 0; } -static const char* jump_protocol(const char* source) { +static const char *jump_protocol(const char *source) { int p; + // scheme // "Comparisons of scheme names MUST be case-insensitive" (RFC2616) - if ((p = strfield(source,"http:"))) - source+=p; - else if ((p = strfield(source,"ftp:"))) - source+=p; - else if ((p = strfield(source,"https:"))) - source+=p; - else if ((p = strfield(source,"file:"))) - source+=p; - else if ((p = strfield(source,"mms:"))) - source+=p; + if ((p = strfield(source, "http:"))) + source += p; + else if ((p = strfield(source, "ftp:"))) + source += p; + else if ((p = strfield(source, "https:"))) + source += p; + else if ((p = strfield(source, "file:"))) + source += p; + else if ((p = strfield(source, "mms:"))) + source += p; // net_path - if (strncmp(source,"//",2)==0) - source+=2; + if (strncmp(source, "//", 2) == 0) + source += 2; return source; } -static const char* strrchr_limit(const char* s, char c, const char* limit) { +static const char *strrchr_limit(const char *s, char c, const char *limit) { if (limit == NULL) { - char* p = strrchr(s, c); - return p?(p+1):NULL; + char *p = strrchr(s, c); + + return p ? (p + 1) : NULL; } else { - char *a=NULL, *p; + char *a = NULL, *p; + for(;;) { - p=strchr((a)?a:s, c); + p = strchr((a) ? a : s, c); if ((p >= limit) || (p == NULL)) return a; - a=p+1; + a = p + 1; } } } -static const char* jump_protocol_and_auth(const char* source) { - const char *a,*trytofind; +static const char *jump_protocol_and_auth(const char *source) { + const char *a, *trytofind; + if (strcmp(source, "file://") == 0) - return source; + return source; a = jump_protocol(source); - trytofind = strrchr_limit(a, '@', strchr(a,'/')); - return (trytofind != NULL)?trytofind:a; + trytofind = strrchr_limit(a, '@', strchr(a, '/')); + return (trytofind != NULL) ? trytofind : a; } #ifndef min @@ -202,27 +217,29 @@ static const char* jump_protocol_and_auth(const char* source) { #ifndef max #define max(a,b) ((a)>(b)?(a):(b)) #endif -static int linput_trim(FILE* fp,char* s,int max) { - int rlen=0; - char* ls=(char*) malloc(max+2); - s[0]='\0'; +static int linput_trim(FILE * fp, char *s, int max) { + int rlen = 0; + char *ls = (char *) malloc(max + 2); + + s[0] = '\0'; if (ls) { - char* a; + char *a; + // lire ligne - rlen=linput(fp,ls,max); + rlen = linput(fp, ls, max); if (rlen) { // sauter espaces et tabs en fin - while( (rlen>0) && is_realspace(ls[max(rlen-1,0)]) ) - ls[--rlen]='\0'; + while((rlen > 0) && is_realspace(ls[max(rlen - 1, 0)])) + ls[--rlen] = '\0'; // sauter espaces en début - a=ls; - while((rlen>0) && ((*a==' ') || (*a=='\t'))) { + a = ls; + while((rlen > 0) && ((*a == ' ') || (*a == '\t'))) { a++; rlen--; } - if (rlen>0) { - memcpy(s,a,rlen); // can copy \0 chars - s[rlen]='\0'; + if (rlen > 0) { + memcpy(s, a, rlen); // can copy \0 chars + s[rlen] = '\0'; } } // @@ -234,8 +251,9 @@ static int linput_trim(FILE* fp,char* s,int max) { #ifndef S_ISREG #define S_ISREG(m) ((m) & _S_IFREG) #endif -static int fexist(char* s) { +static int fexist(char *s) { struct stat st; + memset(&st, 0, sizeof(st)); if (stat(s, &st) == 0) { if (S_ISREG(st.st_mode)) { @@ -243,137 +261,155 @@ static int fexist(char* s) { } } return 0; -} +} /* convertir une chaine en temps */ -static void set_lowcase(char* s) { +static void set_lowcase(char *s) { int i; - for(i=0;i<(int) strlen(s);i++) - if ((s[i]>='A') && (s[i]<='Z')) - s[i]+=('a'-'A'); + + for(i = 0; i < (int) strlen(s); i++) + if ((s[i] >= 'A') && (s[i] <= 'Z')) + s[i] += ('a' - 'A'); } -static struct tm* convert_time_rfc822(struct tm *result,const char* s) { - char months[]="jan feb mar apr may jun jul aug sep oct nov dec"; +static struct tm *convert_time_rfc822(struct tm *result, const char *s) { + char months[] = "jan feb mar apr may jun jul aug sep oct nov dec"; char str[256]; - char* a; + char *a; + /* */ - int result_mm=-1; - int result_dd=-1; - int result_n1=-1; - int result_n2=-1; - int result_n3=-1; - int result_n4=-1; + int result_mm = -1; + int result_dd = -1; + int result_n1 = -1; + int result_n2 = -1; + int result_n3 = -1; + int result_n4 = -1; + /* */ if ((int) strlen(s) > 200) return NULL; - strcpy(str,s); + strcpy(str, s); set_lowcase(str); /* éliminer :,- */ - while( (a=strchr(str,'-')) ) *a=' '; - while( (a=strchr(str,':')) ) *a=' '; - while( (a=strchr(str,',')) ) *a=' '; + while((a = strchr(str, '-'))) + *a = ' '; + while((a = strchr(str, ':'))) + *a = ' '; + while((a = strchr(str, ','))) + *a = ' '; /* tokeniser */ - a=str; + a = str; while(*a) { char *first, *last; char tok[256]; + /* découper mot */ - while(*a==' ') a++; /* sauter espaces */ - first=a; - while((*a) && (*a!=' ')) a++; - last=a; - tok[0]='\0'; - if (first!=last) { - char* pos; - strncat(tok,first,(int) (last - first)); + while(*a == ' ') + a++; /* sauter espaces */ + first = a; + while((*a) && (*a != ' ')) + a++; + last = a; + tok[0] = '\0'; + if (first != last) { + char *pos; + + strncat(tok, first, (int) (last - first)); /* analyser */ - if ( (pos=strstr(months,tok)) ) { /* month always in letters */ - result_mm=((int) (pos - months))/4; + if ((pos = strstr(months, tok))) { /* month always in letters */ + result_mm = ((int) (pos - months)) / 4; } else { int number; - if (sscanf(tok,"%d",&number) == 1) { /* number token */ - if (result_dd<0) /* day always first number */ - result_dd=number; - else if (result_n1<0) - result_n1=number; - else if (result_n2<0) - result_n2=number; - else if (result_n3<0) - result_n3=number; - else if (result_n4<0) - result_n4=number; - } /* sinon, bruit de fond(+1GMT for exampel) */ + + if (sscanf(tok, "%d", &number) == 1) { /* number token */ + if (result_dd < 0) /* day always first number */ + result_dd = number; + else if (result_n1 < 0) + result_n1 = number; + else if (result_n2 < 0) + result_n2 = number; + else if (result_n3 < 0) + result_n3 = number; + else if (result_n4 < 0) + result_n4 = number; + } /* sinon, bruit de fond(+1GMT for exampel) */ } } } - if ((result_n1>=0) && (result_mm>=0) && (result_dd>=0) && (result_n2>=0) && (result_n3>=0) && (result_n4>=0)) { - if (result_n4>=1000) { /* Sun Nov 6 08:49:37 1994 */ - result->tm_year=result_n4-1900; - result->tm_hour=result_n1; - result->tm_min=result_n2; - result->tm_sec=max(result_n3,0); - } else { /* Sun, 06 Nov 1994 08:49:37 GMT or Sunday, 06-Nov-94 08:49:37 GMT */ - result->tm_hour=result_n2; - result->tm_min=result_n3; - result->tm_sec=max(result_n4,0); - if (result_n1<=50) /* 00 means 2000 */ - result->tm_year=result_n1+100; - else if (result_n1<1000) /* 99 means 1999 */ - result->tm_year=result_n1; - else /* 2000 */ - result->tm_year=result_n1-1900; + if ((result_n1 >= 0) && (result_mm >= 0) && (result_dd >= 0) + && (result_n2 >= 0) && (result_n3 >= 0) && (result_n4 >= 0)) { + if (result_n4 >= 1000) { /* Sun Nov 6 08:49:37 1994 */ + result->tm_year = result_n4 - 1900; + result->tm_hour = result_n1; + result->tm_min = result_n2; + result->tm_sec = max(result_n3, 0); + } else { /* Sun, 06 Nov 1994 08:49:37 GMT or Sunday, 06-Nov-94 08:49:37 GMT */ + result->tm_hour = result_n2; + result->tm_min = result_n3; + result->tm_sec = max(result_n4, 0); + if (result_n1 <= 50) /* 00 means 2000 */ + result->tm_year = result_n1 + 100; + else if (result_n1 < 1000) /* 99 means 1999 */ + result->tm_year = result_n1; + else /* 2000 */ + result->tm_year = result_n1 - 1900; } - result->tm_isdst=0; /* assume GMT */ - result->tm_yday=-1; /* don't know */ - result->tm_wday=-1; /* don't know */ - result->tm_mon=result_mm; - result->tm_mday=result_dd; + result->tm_isdst = 0; /* assume GMT */ + result->tm_yday = -1; /* don't know */ + result->tm_wday = -1; /* don't know */ + result->tm_mon = result_mm; + result->tm_mday = result_dd; return result; } return NULL; } static struct tm PT_GetTime(time_t t) { - struct tm tmbuf; + struct tm tmbuf; + #ifdef _WIN32 - struct tm * tm = gmtime(&t); + struct tm *tm = gmtime(&t); #else - struct tm * tm = gmtime_r(&t, &tmbuf); + struct tm *tm = gmtime_r(&t, &tmbuf); #endif - if (tm != NULL) - return *tm; - else { - memset(&tmbuf, 0, sizeof(tmbuf)); - return tmbuf; - } + if (tm != NULL) + return *tm; + else { + memset(&tmbuf, 0, sizeof(tmbuf)); + return tmbuf; + } } -static int set_filetime(const char* file, struct tm* tm_time) { +static int set_filetime(const char *file, struct tm *tm_time) { struct utimbuf tim; + #ifndef HTS_DO_NOT_USE_FTIME struct timeb B; + memset(&B, 0, sizeof(B)); - B.timezone=0; - ftime( &B ); - tim.actime = tim.modtime = mktime(tm_time) - B.timezone*60; + B.timezone = 0; + ftime(&B); + tim.actime = tim.modtime = mktime(tm_time) - B.timezone * 60; #else // bogus time (GMT/local).. - tim.actime=tim.modtime=mktime(tm_time); + tim.actime = tim.modtime = mktime(tm_time); #endif return utime(file, &tim); } -static int set_filetime_time_t(const char* file, time_t t) { - if (t != (time_t) 0 && t != (time_t) -1) { - struct tm tm = PT_GetTime(t); - return set_filetime(file, &tm); - } - return -1; +static int set_filetime_time_t(const char *file, time_t t) { + if (t != (time_t) 0 && t != (time_t) - 1) { + struct tm tm = PT_GetTime(t); + + return set_filetime(file, &tm); + } + return -1; } -static int set_filetime_rfc822(const char* file, const char* date) { - struct tm buffer; - struct tm* tm_s = convert_time_rfc822(&buffer,date); +static int set_filetime_rfc822(const char *file, const char *date) { + struct tm buffer; + struct tm *tm_s = convert_time_rfc822(&buffer, date); + if (tm_s) { - return set_filetime(file,tm_s); - } else return -1; + return set_filetime(file, tm_s); + } else + return -1; } #endif |