summaryrefslogtreecommitdiffstats
path: root/innbbsd/inntobbs.c
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-01-08 15:54:00 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-01-08 15:54:00 +0800
commit271bcfc4e7d98aafb59b6e67399244f635ee74e8 (patch)
tree6c8c84e636581109db1de66d4036441c36b607c8 /innbbsd/inntobbs.c
parent9b4d34a17c6061171456ae8e4b63dcd270f53091 (diff)
downloadpttbbs-271bcfc4e7d98aafb59b6e67399244f635ee74e8.tar
pttbbs-271bcfc4e7d98aafb59b6e67399244f635ee74e8.tar.gz
pttbbs-271bcfc4e7d98aafb59b6e67399244f635ee74e8.tar.bz2
pttbbs-271bcfc4e7d98aafb59b6e67399244f635ee74e8.tar.lz
pttbbs-271bcfc4e7d98aafb59b6e67399244f635ee74e8.tar.xz
pttbbs-271bcfc4e7d98aafb59b6e67399244f635ee74e8.tar.zst
pttbbs-271bcfc4e7d98aafb59b6e67399244f635ee74e8.zip
indent -i4
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1473 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'innbbsd/inntobbs.c')
-rw-r--r--innbbsd/inntobbs.c470
1 files changed, 242 insertions, 228 deletions
diff --git a/innbbsd/inntobbs.c b/innbbsd/inntobbs.c
index fb854867..fb1211ee 100644
--- a/innbbsd/inntobbs.c
+++ b/innbbsd/inntobbs.c
@@ -7,311 +7,325 @@
#include "inntobbs.h"
typedef struct Header {
- char *name;
- int id;
-} header_t;
+ char *name;
+ int id;
+} header_t;
-/*enum HeaderValue {
-SUBJECT_H, FROM_H, DATE_H, MID_H, NEWSGROUPS_H,
-NNTPPOSTINGHOST_H, NNTPHOST_H, CONTROL_H, PATH_H,
-ORGANIZATION_H, LASTHEADER,
-};
-*/
+/*
+ * enum HeaderValue { SUBJECT_H, FROM_H, DATE_H, MID_H, NEWSGROUPS_H,
+ * NNTPPOSTINGHOST_H, NNTPHOST_H, CONTROL_H, PATH_H, ORGANIZATION_H,
+ * LASTHEADER, };
+ */
#include <string.h>
-header_t headertable[] = {
-"Subject" ,SUBJECT_H,
-"From" ,FROM_H,
-"Date" ,DATE_H,
-"Message-ID",MID_H,
-"Newsgroups",NEWSGROUPS_H,
-"NNTP-Posting-Host",NNTPPOSTINGHOST_H,
-"NNTP-Host", NNTPHOST_H,
-"Control", CONTROL_H,
-"Path", PATH_H,
-"Organization", ORGANIZATION_H,
-"X-Auth-From", X_Auth_From_H,
-"Approved", APPROVED_H,
-"Distribution", DISTRIBUTION_H,
-"Keywords", KEYWORDS_H,
-"Summary", SUMMARY_H,
-"References",REFERENCES_H,
+header_t headertable[] = {
+ "Subject", SUBJECT_H,
+ "From", FROM_H,
+ "Date", DATE_H,
+ "Message-ID", MID_H,
+ "Newsgroups", NEWSGROUPS_H,
+ "NNTP-Posting-Host", NNTPPOSTINGHOST_H,
+ "NNTP-Host", NNTPHOST_H,
+ "Control", CONTROL_H,
+ "Path", PATH_H,
+ "Organization", ORGANIZATION_H,
+ "X-Auth-From", X_Auth_From_H,
+ "Approved", APPROVED_H,
+ "Distribution", DISTRIBUTION_H,
+ "Keywords", KEYWORDS_H,
+ "Summary", SUMMARY_H,
+ "References", REFERENCES_H,
};
-char *HEADER[LASTHEADER];
-char *BODY;
-char *FROM, *SUBJECT, *SITE, *DATE, *POSTHOST,
- *NNTPHOST, *PATH, *GROUPS, *MSGID, *CONTROL;
+char *HEADER[LASTHEADER];
+char *BODY;
+char *FROM, *SUBJECT, *SITE, *DATE, *POSTHOST, *NNTPHOST, *PATH,
+ *GROUPS, *MSGID, *CONTROL;
#ifdef PalmBBS
-char **XHEADER;
-char *XPATH;
+char **XHEADER;
+char *XPATH;
#endif
int
isexcluded(path1, nl)
-char *path1;
-nodelist_t *nl;
+ char *path1;
+ nodelist_t *nl;
{
- char path2[1024];
- /*path2 = (char*)mymalloc(strlen(nl->node) + 3);*/
- sprintf(path2, "!%.*s!",sizeof path2 - 3, nl->node);
- if (strstr(path1, path2) != NULL) return 1;
- if (nl->exclusion && *nl->exclusion) {
- char *exclude, *ptr;
- for (exclude = nl->exclusion, ptr = strchr(exclude,',');
- exclude && *exclude; ptr = strchr(exclude,',')) {
- if (ptr) *ptr = '\0';
- sprintf(path2, "!%.*s!",sizeof path2 - 3, exclude);
- if (strstr(path1, path2) != NULL) return 1;
- if (ptr) {
- *ptr = ',';
- exclude = ptr+1;
- } else {
- break;
- }
+ char path2[1024];
+ /* path2 = (char*)mymalloc(strlen(nl->node) + 3); */
+ sprintf(path2, "!%.*s!", sizeof path2 - 3, nl->node);
+ if (strstr(path1, path2) != NULL)
+ return 1;
+ if (nl->exclusion && *nl->exclusion) {
+ char *exclude, *ptr;
+ for (exclude = nl->exclusion, ptr = strchr(exclude, ',');
+ exclude && *exclude; ptr = strchr(exclude, ',')) {
+ if (ptr)
+ *ptr = '\0';
+ sprintf(path2, "!%.*s!", sizeof path2 - 3, exclude);
+ if (strstr(path1, path2) != NULL)
+ return 1;
+ if (ptr) {
+ *ptr = ',';
+ exclude = ptr + 1;
+ } else {
+ break;
+ }
}
- }
- return 0;
+ }
+ return 0;
}
feedfplog(nf, filepath, type)
-newsfeeds_t *nf;
-char *filepath;
-int type;
+ newsfeeds_t *nf;
+ char *filepath;
+ int type;
{
- char *path1, *path2, *hostptr;
- nodelist_t *nl;
- if (nf == NULL) return;
- if( nf->path != NULL ) {
- char *ptr1, *ptr2;
- char savech;
- path1 = (char*)mymalloc(strlen(HEADER[PATH_H]) + 3);
- sprintf(path1, "!%s!",HEADER[PATH_H]);
- for (ptr1 = nf->path; ptr1 && *ptr1;) {
- for (; *ptr1 && isspace(*ptr1); ptr1++);
- if (!*ptr1) break;
- for (ptr2 = ptr1; *ptr2 && !isspace(*ptr2); ptr2++);
- savech = *ptr2;
- *ptr2 = '\0';
- /*
- bbslog("search node %s\n",ptr1);
- */
- nl = (nodelist_t*) search_nodelist_bynode(ptr1);
- /*
- bbslog("search node node %s, host %s fp %d\n",nl->node, nl->host, nl->feedfp);
- */
- *ptr2 = savech;
- ptr1 = ptr2++;
- if (nl == NULL) continue;
- if (nl->feedfp == NULL) continue;
- if (isexcluded(path1,nl)) continue;
- /*path2 = (char*)mymalloc(strlen(nl->node) + 3);
- sprintf(path2, "!%s!",nl->node);
- free(path2);
- */
- /*
- bbslog("path1 %s path2 %s\n",path1, path2);
- */
- /*if (strstr(path1, path2) != NULL) return;*/
- /* to conform to the bntplink batch file */
- {
- char *slash = strrchr(filepath,'/');
- if (slash != NULL) *slash = '\t';
- fprintf(nl->feedfp,"%s\t%s\t\t%s\t%s\t%c\t%s\t%s!%s\n",
- filepath == NULL ? "": filepath,
- GROUPS, FROM, SUBJECT, type, MSGID, MYBBSID, HEADER[PATH_H]);
- if (slash != NULL) *slash = '/';
- }
- fflush(nl->feedfp);
- if (savech == '\0') break;
+ char *path1, *path2, *hostptr;
+ nodelist_t *nl;
+ if (nf == NULL)
+ return;
+ if (nf->path != NULL) {
+ char *ptr1, *ptr2;
+ char savech;
+ path1 = (char *)mymalloc(strlen(HEADER[PATH_H]) + 3);
+ sprintf(path1, "!%s!", HEADER[PATH_H]);
+ for (ptr1 = nf->path; ptr1 && *ptr1;) {
+ for (; *ptr1 && isspace(*ptr1); ptr1++);
+ if (!*ptr1)
+ break;
+ for (ptr2 = ptr1; *ptr2 && !isspace(*ptr2); ptr2++);
+ savech = *ptr2;
+ *ptr2 = '\0';
+ /*
+ * bbslog("search node %s\n",ptr1);
+ */
+ nl = (nodelist_t *) search_nodelist_bynode(ptr1);
+ /*
+ * bbslog("search node node %s, host %s fp %d\n",nl->node,
+ * nl->host, nl->feedfp);
+ */
+ *ptr2 = savech;
+ ptr1 = ptr2++;
+ if (nl == NULL)
+ continue;
+ if (nl->feedfp == NULL)
+ continue;
+ if (isexcluded(path1, nl))
+ continue;
+ /*
+ * path2 = (char*)mymalloc(strlen(nl->node) + 3); sprintf(path2,
+ * "!%s!",nl->node); free(path2);
+ */
+ /*
+ * bbslog("path1 %s path2 %s\n",path1, path2);
+ */
+ /* if (strstr(path1, path2) != NULL) return; */
+ /* to conform to the bntplink batch file */
+ {
+ char *slash = strrchr(filepath, '/');
+ if (slash != NULL)
+ *slash = '\t';
+ fprintf(nl->feedfp, "%s\t%s\t\t%s\t%s\t%c\t%s\t%s!%s\n",
+ filepath == NULL ? "" : filepath,
+ GROUPS, FROM, SUBJECT, type, MSGID, MYBBSID, HEADER[PATH_H]);
+ if (slash != NULL)
+ *slash = '/';
+ }
+ fflush(nl->feedfp);
+ if (savech == '\0')
+ break;
+ }
+ free(path1);
}
- free(path1);
- }
}
-static FILE* bbsfeedsfp = NULL;
-static bbsfeedson = -1;
+static FILE *bbsfeedsfp = NULL;
+static bbsfeedson = -1;
init_bbsfeedsfp()
{
- if (bbsfeedsfp != NULL) {
- fclose(bbsfeedsfp);
- bbsfeedsfp = NULL;
- }
- bbsfeedson = -1;
+ if (bbsfeedsfp != NULL) {
+ fclose(bbsfeedsfp);
+ bbsfeedsfp = NULL;
+ }
+ bbsfeedson = -1;
}
-bbsfeedslog(filepath, type)
-char *filepath;
-int type;
+bbsfeedslog(filepath, type)
+ char *filepath;
+ int type;
{
- char datebuf[40];
- time_t now;
+ char datebuf[40];
+ time_t now;
- if (bbsfeedson ==0) return;
- if (bbsfeedson == -1) {
- if (!isfile(BBSFEEDS)) {
- bbsfeedson = 0;
- return;
+ if (bbsfeedson == 0)
+ return;
+ if (bbsfeedson == -1) {
+ if (!isfile(BBSFEEDS)) {
+ bbsfeedson = 0;
+ return;
+ }
+ bbsfeedson = 1;
}
- bbsfeedson = 1;
- }
-
- if (bbsfeedsfp == NULL) {
- bbsfeedsfp = fopen(BBSFEEDS,"a");
- }
- time(&now);
- strftime(datebuf, sizeof(datebuf), "%b %d %X ", localtime(&now));
+ if (bbsfeedsfp == NULL) {
+ bbsfeedsfp = fopen(BBSFEEDS, "a");
+ }
+ time(&now);
+ strftime(datebuf, sizeof(datebuf), "%b %d %X ", localtime(&now));
- if( bbsfeedsfp != NULL ) {
- fprintf(bbsfeedsfp,"%s %c %s %s %s %s!%s %s\n", datebuf, type,
- REMOTEHOSTNAME, GROUPS, MSGID, MYBBSID, HEADER[PATH_H], filepath==NULL? "": filepath);
+ if (bbsfeedsfp != NULL) {
+ fprintf(bbsfeedsfp, "%s %c %s %s %s %s!%s %s\n", datebuf, type,
+ REMOTEHOSTNAME, GROUPS, MSGID, MYBBSID, HEADER[PATH_H], filepath == NULL ? "" : filepath);
fflush(bbsfeedsfp);
- }
+ }
}
-static FILE* echomailfp = NULL;
-static echomaillogon = -1;
+static FILE *echomailfp = NULL;
+static echomaillogon = -1;
init_echomailfp()
{
- if (echomailfp != NULL) {
- fclose(echomailfp);
- echomailfp = NULL;
- }
- echomaillogon = -1;
+ if (echomailfp != NULL) {
+ fclose(echomailfp);
+ echomailfp = NULL;
+ }
+ echomaillogon = -1;
}
-echomaillog()
+echomaillog()
{
- if (echomaillogon ==0) return;
- if (echomaillogon == -1) {
- if (!isfile(ECHOMAIL)) {
- echomaillogon = 0;
- return;
+ if (echomaillogon == 0)
+ return;
+ if (echomaillogon == -1) {
+ if (!isfile(ECHOMAIL)) {
+ echomaillogon = 0;
+ return;
+ }
+ echomaillogon = 1;
}
- echomaillogon = 1;
- }
-
- if (echomailfp == NULL) {
- echomailfp = fopen(ECHOMAIL,"a");
- }
-
- if( echomailfp != NULL ) {
- fprintf(echomailfp,"\n");
- fprintf(echomailfp,"發信人: %s, 信區: %s\n", FROM, GROUPS);
+ if (echomailfp == NULL) {
+ echomailfp = fopen(ECHOMAIL, "a");
+ }
+ if (echomailfp != NULL) {
+ fprintf(echomailfp, "\n");
+ fprintf(echomailfp, "發信人: %s, 信區: %s\n", FROM, GROUPS);
str_decode_M3(SUBJECT);
- fprintf(echomailfp,"標 題: %s\n", SUBJECT);
- fprintf(echomailfp,"發信站: %s (%s)\n", SITE, DATE);
- fprintf(echomailfp,"轉信站: %s (%s)\n", PATH, REMOTEHOSTNAME);
+ fprintf(echomailfp, "標 題: %s\n", SUBJECT);
+ fprintf(echomailfp, "發信站: %s (%s)\n", SITE, DATE);
+ fprintf(echomailfp, "轉信站: %s (%s)\n", PATH, REMOTEHOSTNAME);
fflush(echomailfp);
- }
+ }
}
-int headercmp(a,b)
-header_t *a, *b;
+int
+headercmp(a, b)
+ header_t *a, *b;
{
- return strcasecmp(a->name, b->name);
+ return strcasecmp(a->name, b->name);
}
-int readlines(client)
-ClientType *client;
+int
+readlines(client)
+ ClientType *client;
{
- int fd = client->fd;
- char *buffer = client->buffer;
- buffer_t *in = &client->in;
- char *front = in->data, *ptr, *hptr;
- int i;
-
- for (i=0; i < LASTHEADER; i++ )
- HEADER[i] = NULL;
- for (ptr = (char*)strchr(in->data,'\n'); ptr != NULL && *ptr != '\0' ; front = ptr+1, ptr = (char*)strchr(front,'\n')) {
+ int fd = client->fd;
+ char *buffer = client->buffer;
+ buffer_t *in = &client->in;
+ char *front = in->data, *ptr, *hptr;
+ int i;
+
+ for (i = 0; i < LASTHEADER; i++)
+ HEADER[i] = NULL;
+ for (ptr = (char *)strchr(in->data, '\n'); ptr != NULL && *ptr != '\0'; front = ptr + 1, ptr = (char *)strchr(front, '\n')) {
*ptr = '\0';
- if (front[0] == '\r' || front[1] == '\n') {
- BODY = front+2;
- break;
- }
- hptr = (char*)strchr(front,':');
+ if (front[0] == '\r' || front[1] == '\n') {
+ BODY = front + 2;
+ break;
+ }
+ hptr = (char *)strchr(front, ':');
if (hptr != NULL && hptr[1] == ' ') {
- int value;
- *hptr = '\0';
- value = headervalue(front);
- if (value != -1) {
- char *tp;
- HEADER[value] = hptr + 2;
- if ((tp = (char*)strchr(HEADER[value],'\r'))!=NULL)
- *tp = '\0';
- }
- *hptr = ':';
+ int value;
+ *hptr = '\0';
+ value = headervalue(front);
+ if (value != -1) {
+ char *tp;
+ HEADER[value] = hptr + 2;
+ if ((tp = (char *)strchr(HEADER[value], '\r')) != NULL)
+ *tp = '\0';
+ }
+ *hptr = ':';
}
/**ptr = '\n';*/
}
NNTPHOST = HEADER[NNTPHOST_H];
- PATH = HEADER[PATH_H];
- FROM = HEADER[FROM_H];
- GROUPS = HEADER[NEWSGROUPS_H];
- SUBJECT = HEADER[SUBJECT_H];
- DATE = HEADER[DATE_H];
- SITE = HEADER[ORGANIZATION_H];
- MSGID = HEADER[MID_H];
- CONTROL = HEADER[CONTROL_H];
+ PATH = HEADER[PATH_H];
+ FROM = HEADER[FROM_H];
+ GROUPS = HEADER[NEWSGROUPS_H];
+ SUBJECT = HEADER[SUBJECT_H];
+ DATE = HEADER[DATE_H];
+ SITE = HEADER[ORGANIZATION_H];
+ MSGID = HEADER[MID_H];
+ CONTROL = HEADER[CONTROL_H];
POSTHOST = HEADER[NNTPPOSTINGHOST_H];
if (POSTHOST == NULL) {
- if (HEADER[X_Auth_From_H] != NULL) {
- POSTHOST = HEADER[X_Auth_From_H];
- HEADER[NNTPPOSTINGHOST_H] = POSTHOST;
- }
+ if (HEADER[X_Auth_From_H] != NULL) {
+ POSTHOST = HEADER[X_Auth_From_H];
+ HEADER[NNTPPOSTINGHOST_H] = POSTHOST;
+ }
}
#ifdef PalmBBS
- XPATH = PATH;
- XHEADER = HEADER;
+ XPATH = PATH;
+ XHEADER = HEADER;
#endif
}
-int headervalue(inputheader)
-char *inputheader;
+int
+headervalue(inputheader)
+ char *inputheader;
{
- header_t key, *findkey;
- static int hasinit=0;
+ header_t key, *findkey;
+ static int hasinit = 0;
- if (hasinit == 0) {
- article_init();
- hasinit = 1;
- }
-
- key.name = inputheader;
- findkey = ( header_t *)bsearch (
- (char *) &key, (char *) headertable,
- sizeof(headertable)/ sizeof(header_t), sizeof (key),
- headercmp);
- if (findkey != NULL) return findkey->id;
- return -1;
+ if (hasinit == 0) {
+ article_init();
+ hasinit = 1;
+ }
+ key.name = inputheader;
+ findkey = (header_t *) bsearch(
+ (char *)&key, (char *)headertable,
+ sizeof(headertable) / sizeof(header_t), sizeof(key),
+ headercmp);
+ if (findkey != NULL)
+ return findkey->id;
+ return -1;
}
article_init()
{
- int i;
- static int article_inited = 0;
+ int i;
+ static int article_inited = 0;
- if (article_inited) return;
- article_inited = 1;
+ if (article_inited)
+ return;
+ article_inited = 1;
- qsort(headertable, sizeof(headertable)/ sizeof(header_t), sizeof(header_t),
- headercmp);
- for (i=0; i < LASTHEADER; i++ )
- HEADER[i] = NULL;
+ qsort(headertable, sizeof(headertable) / sizeof(header_t), sizeof(header_t),
+ headercmp);
+ for (i = 0; i < LASTHEADER; i++)
+ HEADER[i] = NULL;
}
#ifdef INNTOBBS_MAIN
main()
{
- int i,j,k,l,m,n,o,p,q;
- article_init();
+ int i, j, k, l, m, n, o, p, q;
+ article_init();
i = headervalue("Subject");
j = headervalue("From");
k = headervalue("Date");