Cleaned some debug logging

This commit is contained in:
Michiel Broek 2001-12-16 12:33:21 +00:00
parent 749da678f7
commit 1bd01075b1
6 changed files with 23 additions and 103 deletions

View File

@ -1,8 +1,7 @@
/***************************************************************************** /*****************************************************************************
* *
* File ..................: common/charconv.c * $Id$
* Purpose ...............: Common utilities * Purpose ...............: Common utilities - character set conversion
* Last modification date : 21-Mar-2001
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2001 * Copyright (C) 1997-2001
@ -88,7 +87,6 @@ static int getmaptab(char *maptab_name)
char buf[BUFSIZ], *p, *q; char buf[BUFSIZ], *p, *q;
int in, on; int in, on;
Syslog('M', "getmaptab: %s\n", maptab_name);
if ((fp = fopen(maptab_name, "r")) == NULL) { if ((fp = fopen(maptab_name, "r")) == NULL) {
WriteError("$can't open mapchan file \"%s\" ", maptab_name); WriteError("$can't open mapchan file \"%s\" ", maptab_name);
return 0; return 0;
@ -661,12 +659,9 @@ char *hdrconv(char *s, int incode, int outcode)
char *xbuf=NULL, *buf=NULL, *q; char *xbuf=NULL, *buf=NULL, *q;
int codage; int codage;
// Syslog('N', "hdrconv(%s, %d, %d)", s, incode, outcode);
iptr = s; iptr = s;
while (*iptr) { while (*iptr) {
if (!strncmp(iptr,"=?",2)) { if (!strncmp(iptr,"=?",2)) {
// Syslog('N', "hdrconv =?");
q=strchr(iptr+2,'?'); q=strchr(iptr+2,'?');
if (q) { if (q) {
incode=getcode(iptr+2); incode=getcode(iptr+2);
@ -704,20 +699,13 @@ char *hdrconv(char *s, int incode, int outcode)
xbuf=xstrcat(xbuf,b64_decode(ttbuf)); xbuf=xstrcat(xbuf,b64_decode(ttbuf));
} }
} else { /* not coded */ } else { /* not coded */
// Syslog('N', "hdrconv not coded 1");
*ttbuf=*iptr; *ttbuf=*iptr;
// Syslog('N', "hdrconv not coded 2");
*(ttbuf+1)='\0'; *(ttbuf+1)='\0';
// Syslog('N', "hdrconv not coded 3");
xbuf=xstrcat(xbuf,ttbuf); xbuf=xstrcat(xbuf,ttbuf);
// Syslog('N', "hdrconv not coded 4");
iptr++; iptr++;
// Syslog('N', "hdrconv not coded 5");
} }
} }
// Syslog('N', "hdrconv call strkconv");
buf=strkconv(xbuf, incode, outcode); buf=strkconv(xbuf, incode, outcode);
// Syslog('N', "hdrconv return");
return buf; return buf;
} }

View File

@ -281,19 +281,13 @@ int is_8_3( char *fname)
fname = slash_pos + 1; fname = slash_pos + 1;
len = strlen(fname); len = strlen(fname);
Syslog('f', "Checking %s for 8.3", fname);
/* Can't be 0 chars or longer than 12 chars */ /* Can't be 0 chars or longer than 12 chars */
if ((len == 0) || (len > 12)) { if ((len == 0) || (len > 12))
Syslog('f', "filename length not right");
return FALSE; return FALSE;
}
/* Mustn't be an MS-DOS Special file such as lpt1 or even lpt1.txt */ /* Mustn't be an MS-DOS Special file such as lpt1 or even lpt1.txt */
if (is_reserved_msdos(fname)) { if (is_reserved_msdos(fname))
Syslog('f', "is reserved msdos name");
return FALSE; return FALSE;
}
init_chartest(); init_chartest();
for (i = 0; i < strlen(fname); i++) { for (i = 0; i < strlen(fname); i++) {
@ -323,10 +317,8 @@ int is_8_3( char *fname)
return(0 == strcmp( fname, "." ) || 0 == strcmp( fname, ".." )); return(0 == strcmp( fname, "." ) || 0 == strcmp( fname, ".." ));
/* base can't be greater than 8 */ /* base can't be greater than 8 */
if (l > 8) { if (l > 8)
Syslog('f', "filebase longer then 8 chars");
return FALSE; return FALSE;
}
if (len - l == 1 && !strchr( dot_pos + 1, '.' )) { if (len - l == 1 && !strchr( dot_pos + 1, '.' )) {
*dot_pos = 0; *dot_pos = 0;
@ -334,16 +326,12 @@ int is_8_3( char *fname)
} }
/* extension must be between 1 and 3 */ /* extension must be between 1 and 3 */
if ((len - l < 2 ) || (len - l > 4)) { if ((len - l < 2 ) || (len - l > 4))
Syslog('f', "extension length not right");
return FALSE; return FALSE;
}
/* extensions may not have a dot */ /* extensions may not have a dot */
if (strchr( dot_pos+1, '.' )) { if (strchr( dot_pos+1, '.' ))
Syslog('f', "extension with a dot in it");
return FALSE; return FALSE;
}
/* must be in 8.3 format */ /* must be in 8.3 format */
return TRUE; return TRUE;
@ -375,27 +363,21 @@ void mangle_name_83(char *s)
if (strcmp(q = s + strlen(s) - strlen(".tar.gz"), ".tar.gz") == 0) { if (strcmp(q = s + strlen(s) - strlen(".tar.gz"), ".tar.gz") == 0) {
*q = '\0'; *q = '\0';
q = (char *)"tgz"; q = (char *)"tgz";
Syslog('f', "mangle_name_83 tar.gz => tgz");
} else if (strcmp(q = s + strlen(s) - strlen(".tar.z"), ".tar.z") == 0) { } else if (strcmp(q = s + strlen(s) - strlen(".tar.z"), ".tar.z") == 0) {
*q = '\0'; *q = '\0';
q = (char *)"tgz"; q = (char *)"tgz";
Syslog('f', "mangle_name_83 tar.z => tgz");
} else if (strcmp(q = s + strlen(s) - strlen(".tar.Z"), ".tar.Z") == 0) { } else if (strcmp(q = s + strlen(s) - strlen(".tar.Z"), ".tar.Z") == 0) {
*q = '\0'; *q = '\0';
q = (char *)"taz"; q = (char *)"taz";
Syslog('f', "mangle_name_83 tar.Z => taz");
} else if (strcmp(q = s + strlen(s) - strlen(".html"), ".html") == 0) { } else if (strcmp(q = s + strlen(s) - strlen(".html"), ".html") == 0) {
*q = '\0'; *q = '\0';
q = (char *)"htm"; q = (char *)"htm";
Syslog('f', "mangle_name_83 html => htm");
} else if (strcmp(q = s + strlen(s) - strlen(".shtml"), ".shtml") == 0) { } else if (strcmp(q = s + strlen(s) - strlen(".shtml"), ".shtml") == 0) {
*q = '\0'; *q = '\0';
q = (char *)"stm"; q = (char *)"stm";
Syslog('f', "mangle_name_83 shtml => stm");
} else if (strcmp(q = s + strlen(s) - strlen(".conf"), ".conf") == 0) { } else if (strcmp(q = s + strlen(s) - strlen(".conf"), ".conf") == 0) {
*q = '\0'; *q = '\0';
q = (char *)"cnf"; q = (char *)"cnf";
Syslog('f', "mangle_name_83 conf => cnf");
} else { } else {
q = NULL; q = NULL;
} }
@ -484,7 +466,6 @@ void name_mangle(char *OutName)
* check if it's already in 8.3 format * check if it's already in 8.3 format
*/ */
if (!is_8_3(OutName)) { if (!is_8_3(OutName)) {
Syslog('f', "is 8.3 = FALSE");
mangle_name_83(OutName); mangle_name_83(OutName);
} else { } else {
/* /*

View File

@ -49,17 +49,14 @@ int flagset(char *s)
int i; int i;
int fl=0; int fl=0;
Syslog('M', "setting flags from string \"%s\"",MBSE_SS(s));
buf=xstrcpy(s); buf=xstrcpy(s);
for (p=strtok(buf," ,\t\n"); p; p=strtok(NULL," ,\t\n")) { for (p=strtok(buf," ,\t\n"); p; p=strtok(NULL," ,\t\n")) {
for (i=0;i<16;i++) for (i=0;i<16;i++)
if (!strcasecmp(p,flnm[i])) { if (!strcasecmp(p,flnm[i])) {
Syslog('M', "setting flag bit %d for \"%s\"", i,MBSE_SS(p));
fl |= (1 << i); fl |= (1 << i);
} }
} }
free(buf); free(buf);
Syslog('M', "set flags 0x%04x",fl);
return fl; return fl;
} }
@ -73,7 +70,6 @@ char *compose_flags(int flags, char *fkludge)
if ((fkludge == NULL) && (!flags)) if ((fkludge == NULL) && (!flags))
return buf; return buf;
Syslog('M', "composing flag string from binary 0x%04x and string \"%s\"", flags,MBSE_SS(fkludge));
if (fkludge) { if (fkludge) {
if (!isspace(fkludge[0])) if (!isspace(fkludge[0]))
buf=xstrcpy((char *)" "); buf=xstrcpy((char *)" ");
@ -87,9 +83,7 @@ char *compose_flags(int flags, char *fkludge)
if ((flags & (1 << i)) && (!flag_on(flnm[i],buf))) { if ((flags & (1 << i)) && (!flag_on(flnm[i],buf))) {
buf=xstrcat(buf,(char *)" "); buf=xstrcat(buf,(char *)" ");
buf=xstrcat(buf,flnm[i]); buf=xstrcat(buf,flnm[i]);
Syslog('m', "adding \"%s\"",flnm[i]);
} }
Syslog('M', "resulting string is \"%s\"",buf);
return buf; return buf;
} }
@ -103,7 +97,6 @@ char *strip_flags(char *flags)
if (flags == NULL) if (flags == NULL)
return NULL; return NULL;
Syslog('M', "stripping official flags from \"%s\"",MBSE_SS(flags));
p=xstrcpy(flags); p=xstrcpy(flags);
for (tok=strtok(flags,", \t\n");tok;tok=strtok(NULL,", \t\n")) { for (tok=strtok(flags,", \t\n");tok;tok=strtok(NULL,", \t\n")) {
canonic=0; canonic=0;
@ -116,7 +109,6 @@ char *strip_flags(char *flags)
} }
} }
free(p); free(p);
Syslog('M', "stripped string is \"%s\"",q);
return q; return q;
} }
@ -130,14 +122,12 @@ int flag_on(char *flag, char *flags)
if (flags == NULL) if (flags == NULL)
return FALSE; return FALSE;
Syslog('m', "checking flag \"%s\" in string \"%s\"", MBSE_SS(flag), MBSE_SS(flags));
p = xstrcpy(flags); p = xstrcpy(flags);
for (tok = strtok(p, ", \t\n"); tok; tok = strtok(NULL, ", \t\n")) { for (tok = strtok(p, ", \t\n"); tok; tok = strtok(NULL, ", \t\n")) {
if (strcasecmp(flag, tok) == 0) if (strcasecmp(flag, tok) == 0)
up = TRUE; up = TRUE;
} }
free(p); free(p);
Syslog('m', "flag%s present", up ? "":" not");
return up; return up;
} }

View File

@ -1,8 +1,7 @@
/***************************************************************************** /*****************************************************************************
* *
* File ..................: rfcaddr.c * $Id$
* Purpose ...............: MBSE BBS Common Library * Purpose ...............: MBSE BBS Common Library - RFC address functions
* Last modification date : 23-Mar-2001
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2001 * Copyright (C) 1997-2001
@ -87,8 +86,6 @@ parsedaddr parserfcaddr(char *s)
int quotes, brackets, escaped, anglecomplete; int quotes, brackets, escaped, anglecomplete;
char *firstat, *lastat, *percent, *colon, *comma, *exclam; char *firstat, *lastat, *percent, *colon, *comma, *exclam;
// Syslog('M', "parserfcaddr() 1");
result.target = NULL; result.target = NULL;
result.remainder = NULL; result.remainder = NULL;
result.comment = NULL; result.comment = NULL;
@ -97,13 +94,12 @@ parsedaddr parserfcaddr(char *s)
if ((s == NULL) || (*s == '\0')) if ((s == NULL) || (*s == '\0'))
return result; return result;
/* First check if there is an "angled" portion */ /*
* First check if there is an "angled" portion
// Syslog('M', "parserfcaddr() 1b strlen=%d", strlen(s)); */
inbrackets = calloc(strlen(s)+1, sizeof(char)); inbrackets = calloc(strlen(s)+1, sizeof(char));
outbrackets = calloc(strlen(s)+1, sizeof(char)); outbrackets = calloc(strlen(s)+1, sizeof(char));
brackets = quotes = escaped = anglecomplete = 0; brackets = quotes = escaped = anglecomplete = 0;
// Syslog('M', "parserfcaddr() 2");
for (p = s,q = inbrackets, r = outbrackets, x = &r; *p; p++) { for (p = s,q = inbrackets, r = outbrackets, x = &r; *p; p++) {
if (escaped) if (escaped)
escaped = FALSE; escaped = FALSE;
@ -134,22 +130,16 @@ parsedaddr parserfcaddr(char *s)
if (!brackets) if (!brackets)
x = &r; x = &r;
} }
// Syslog('M', "parserfcaddr() 3");
*q = '\0'; *q = '\0';
*r = '\0'; *r = '\0';
if (brackets || quotes) if (brackets || quotes)
addrerror |= ADDR_UNMATCHED; addrerror |= ADDR_UNMATCHED;
// Syslog('N', " inbrackets: \"%s\"",inbrackets);
// Syslog('N', "outbrackets: \"%s\"",outbrackets);
// Syslog('N', " addrerror: 0x%04x",addrerror);
if (addrerror) if (addrerror)
goto leave1; goto leave1;
cleanbuf = calloc(strlen(s)+1, sizeof(char)); cleanbuf = calloc(strlen(s)+1, sizeof(char));
combuf = calloc(strlen(s)+1, sizeof(char)); combuf = calloc(strlen(s)+1, sizeof(char));
// Syslog('M', "parserfcaddr() 4");
if (*inbrackets) { /* there actually is an angled portion */ if (*inbrackets) { /* there actually is an angled portion */
strcpy(combuf, outbrackets); strcpy(combuf, outbrackets);
c = combuf + strlen(combuf); c = combuf + strlen(combuf);
@ -160,15 +150,11 @@ parsedaddr parserfcaddr(char *s)
p = outbrackets; p = outbrackets;
} }
// Syslog('N', " now parsing: \"%s\"",p);
// Syslog('N', "current comment: \"%s\"",result.comment);
/* OK, now we have result.comment filled with wat was outside /* OK, now we have result.comment filled with wat was outside
angle brackets, c pointing past the end of it, angle brackets, c pointing past the end of it,
p pointing to what is supposed to be address, with angle p pointing to what is supposed to be address, with angle
brackets already removed */ brackets already removed */
// Syslog('M', "parserfcaddr() 5");
quotes = brackets = escaped = 0; quotes = brackets = escaped = 0;
for (r = cleanbuf, x = &r; *p; p++) { for (r = cleanbuf, x = &r; *p; p++) {
if (escaped) { if (escaped) {
@ -214,11 +200,6 @@ parsedaddr parserfcaddr(char *s)
if (brackets || quotes) if (brackets || quotes)
addrerror |= ADDR_UNMATCHED; addrerror |= ADDR_UNMATCHED;
// Syslog('N', " now parsing: \"%s\"",inbrackets);
// Syslog('N', "complete comment: \"%s\"",result.comment);
// Syslog('N', " addrerror: 0x%04x",addrerror);
// Syslog('M', "parserfcaddr() 6");
if (addrerror) if (addrerror)
goto leave2; goto leave2;
@ -255,40 +236,28 @@ parsedaddr parserfcaddr(char *s)
exclam = p; exclam = p;
break; break;
} }
// Syslog('M', "parserfcaddr() 7");
if ((firstat == cleanbuf) && colon) { if ((firstat == cleanbuf) && colon) {
// Syslog('N', "@aaa,@bbb:xxx@yyy construct");
if (comma && (comma < colon)) { if (comma && (comma < colon)) {
*comma = '\0'; *comma = '\0';
r = comma + 1; r = comma + 1;
// Syslog('M', "parserfcaddr() 9");
} else { } else {
*colon = '\0'; *colon = '\0';
r = colon + 1; r = colon + 1;
// Syslog('M', "parserfcaddr() 10");
} }
t = firstat + 1; t = firstat + 1;
// Syslog('M', "parserfcaddr() 11");
} else if (lastat) { } else if (lastat) {
// Syslog('N', "anything@somewhere construct");
*lastat = '\0'; *lastat = '\0';
r = cleanbuf; r = cleanbuf;
t = lastat + 1; t = lastat + 1;
// Syslog('M', "parserfcaddr() 12");
} else if (exclam) { } else if (exclam) {
// Syslog('N', "domain!something construct (without @'s)");
*exclam = '\0'; *exclam = '\0';
r = exclam + 1; r = exclam + 1;
t = cleanbuf; t = cleanbuf;
// Syslog('M', "parserfcaddr() 13");
} else if (percent) { } else if (percent) {
// Syslog('N', "anything%%somewhere construct (without !'s and @'s)");
*percent = '\0'; *percent = '\0';
r = cleanbuf; r = cleanbuf;
t = percent + 1; t = percent + 1;
// Syslog('M', "parserfcaddr() 14");
} else { } else {
// Syslog('N', "remainder only present");
/* unquote it if necessary */ /* unquote it if necessary */
if ((*cleanbuf == '\"') && (*(p = (cleanbuf+strlen(cleanbuf)-1)) == '\"')) { if ((*cleanbuf == '\"') && (*(p = (cleanbuf+strlen(cleanbuf)-1)) == '\"')) {
*p = '\0'; *p = '\0';
@ -296,33 +265,24 @@ parsedaddr parserfcaddr(char *s)
} else } else
r = cleanbuf; r = cleanbuf;
t = NULL; t = NULL;
// Syslog('M', "parserfcaddr() 15");
} }
// Syslog('M', "parserfcaddr() 16");
if (t && (*t != '\0')) if (t && (*t != '\0'))
result.target = xstrcpy(t); result.target = xstrcpy(t);
// Syslog('M', "parserfcaddr() 17");
if (r && (*r != '\0')) if (r && (*r != '\0'))
result.remainder = xstrcpy(r); result.remainder = xstrcpy(r);
// Syslog('M', "parserfcaddr() 18");
if (*combuf != '\0') if (*combuf != '\0')
result.comment = xstrcpy(combuf); result.comment = xstrcpy(combuf);
// Syslog('M', "parserfcaddr() 19");
leave1: /* this is also normal exit */ leave1: /* this is also normal exit */
// Syslog('M', "parserfcaddr() leave1");
free(cleanbuf); free(cleanbuf);
free(combuf); free(combuf);
free(inbrackets); free(inbrackets);
free(outbrackets); free(outbrackets);
// Syslog('M', "going");
return result; return result;
leave2: /* if error found on second stage, free */ leave2: /* if error found on second stage, free */
// Syslog('M', "parserfcaddr() leave2");
free(cleanbuf); free(cleanbuf);
free(combuf); free(combuf);
// Syslog('M', "going");
return result; return result;
} }

View File

@ -1,8 +1,7 @@
/***************************************************************************** /*****************************************************************************
* *
* File ..................: rfcmsg.c * $Id$
* Purpose ...............: RFC msg * Purpose ...............: RFC msg
* Last modification date : 14-Apr-2001
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2001 * Copyright (C) 1997-2001
@ -76,7 +75,7 @@ rfcmsg *parsrfc(FILE *fp)
} else } else
cur->val = xstrcat(cur->val,buffer); cur->val = xstrcat(cur->val,buffer);
} else { } else {
// Syslog('M', "this is a header line"); Syslog('M', "this is a header line");
if (cur) { if (cur) {
firstline=FALSE; firstline=FALSE;
(cur->next) = (rfcmsg *)malloc(sizeof(rfcmsg)); (cur->next) = (rfcmsg *)malloc(sizeof(rfcmsg));
@ -109,7 +108,7 @@ rfcmsg *parsrfc(FILE *fp)
/* at least one non blank char */ /* at least one non blank char */
(strspn(p+2, " \t\n") < strlen(p+2)) && (strspn(buffer,KWDCHARS) == (p-buffer))) { (strspn(p+2, " \t\n") < strlen(p+2)) && (strspn(buffer,KWDCHARS) == (p-buffer))) {
*p='\0'; *p='\0';
// Syslog('M', "This is a regular header"); Syslog('M', "This is a regular header");
cur->key = xstrcpy(buffer); cur->key = xstrcpy(buffer);
cur->val = xstrcpy(p+1); cur->val = xstrcpy(p+1);
} else { } else {

View File

@ -343,8 +343,8 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
if (strlen(buf) > (sizeof(buf) /2)) if (strlen(buf) > (sizeof(buf) /2))
Syslog('+', "FTN: Possible bufferoverflow: line read %d bytes", strlen(buf)); Syslog('+', "FTN: Possible bufferoverflow: line read %d bytes", strlen(buf));
if (strlen(buf) > 200) { if (strlen(buf) > 200) {
Syslog('m', "FTN: Next line should be %d characters", strlen(buf)); Syslog('M', "FTN: Next line should be %d characters", strlen(buf));
Syslogp('m', printable(buf, 200)); Syslogp('M', printable(buf, 200));
} else { } else {
Syslogp('M', printable(buf, 0)); Syslogp('M', printable(buf, 0));
} }
@ -574,7 +574,7 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
if (msgs.MsgKinds == USEMOD) if (msgs.MsgKinds == USEMOD)
modtype = 1; modtype = 1;
} }
Syslog('m', "newsgroup %s, distribution %s, moderator %s modtype %d", Syslog('M', "newsgroup %s, distribution %s, moderator %s modtype %d",
printable(newsgroup, 0), printable(distribution, 0), printable(moderator, 0), modtype); printable(newsgroup, 0), printable(distribution, 0), printable(moderator, 0), modtype);
newsmode = TRUE; newsmode = TRUE;
if ((modtype == 1) && (!hdr((char *)"Approved",msg)) && if ((modtype == 1) && (!hdr((char *)"Approved",msg)) &&
@ -582,7 +582,7 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
newsmode = TRUE; newsmode = TRUE;
} else } else
newsmode = FALSE; newsmode = FALSE;
Syslog('m', "Got %s message", newsmode?"echo":"netmail"); Syslog('M', "Got %s message", newsmode?"echo":"netmail");
if ((outcode == CHRS_NOTSET) && (hdr((char *)"MSGID", kmsg))) { if ((outcode == CHRS_NOTSET) && (hdr((char *)"MSGID", kmsg))) {
p = rfcmsgid(hdr((char *)"MSGID",kmsg),bestaka); p = rfcmsgid(hdr((char *)"MSGID",kmsg),bestaka);
@ -673,8 +673,10 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
if ((p=hdr((char *)"TOPT",kmsg))) if ((p=hdr((char *)"TOPT",kmsg)))
t->point=atoi(p); t->point=atoi(p);
Syslog('m', "final from: %s",ascfnode(f,0xff)); if (!newsmode) {
Syslog('m', "final to: %s",ascfnode(t,0xff)); Syslog('m', "final from: %s",ascfnode(f,0xff));
Syslog('m', "final to: %s",ascfnode(t,0xff));
}
if (!newsmode) { if (!newsmode) {
p=hdr((char *)"Resent-To",msg); p=hdr((char *)"Resent-To",msg);