
219: path = getenv("DATA_DIR") + "\\stpl\\user.dat";
220: leg = leg_open(path, lmOpenRead);
221: if(leg) {
222: leg_readstring(leg, "/common/url", url, 1024, "");
223: leg_readstring(leg, "/common/mbox", mbox, 1024, "");
224: autobrowseropen=leg_readbool(leg, "/common/autobrowseropen", 0);
225: }
226: leg_close(leg);
227:
228: strcpy(TGTFILE,getenv("DATA_DIR"));
229: strcpy(TGTFILE+strlen(TGTFILE),"\\");
230: strcpy(TGTFILE+strlen(TGTFILE),mbox);
|
231: memset(&loc,0,sizeof(LOCATION)); 232: loc.size=sizeof(LOCATION); 233: decodeurl(&loc,url); |
235: inet=inet_open(NULL,loc.host,loc.port,INET_SERVICE_HTTP,NULL,NULL,0);
236: if(inet) {
|
241: do {
242: ofs = getmessages(&buffer,inet,loc.path,ofs);
243: } while(ofs && !terminated);
|
167: http=http_open(inet,"GET",path,NULL,0);
168: if (http) {
169: buf->bsize+=BUFSIZEUNIT;
170: buf->text=realloc(buf->text,buf->bsize+1);
171: sprintf(tmp,"ダウンロード中... %d メッセージ (%d bytes)",offset,buf->esize);
172: setstatustext(tmp);
173: tmplen=http_request(http,NULL,0,buf->text+buf->esize,BUFSIZEUNIT+1);
174: buf->esize+=tmplen;
175: while(tmplen==BUFSIZEUNIT) {
176: buf->bsize+=BUFSIZEUNIT;
177: buf->text=realloc(buf->text,buf->bsize+1);
178: tmplen=http_read(http,buf->text+buf->esize,BUFSIZEUNIT+1);
179: buf->esize+=tmplen;
180: sprintf(tmp,"ダウンロード中... %d メッセージ (%d bytes)",offset,buf->esize);
181: setstatustext(tmp);
182: }
183: buf->text[buf->esize]='\0';
184: sprintf(tmp,"ダウンロード中... %d メッセージ (%d bytes)",offset,buf->esize);
185: setstatustext(tmp);
186: http_close(http);
187: }
|
188: result = 0;
189: if(count = checkmessages(inet,path,buf)) {
190: if(strstr(buf->text,"<input type=submit value=\"次のページ\">")) result = offset + count;
191: else result = 0;
192: }
|
127://メッセージのあるURLのパスを求める
128: sep=0;
129: while(strstr(path+sep,"/")>0){
130: sep=strstr(path+sep,"/")-path+1;
131: }
132: strncpy(dirpath,path,sep);
|
137: page=page_create(buf->text,buf->esize); 138: ea=page_elements(page); 139: el=page_find_elements(page,NULL,"TABLE"); 140: 141: for(scan=0;scan |
75: strcpy(idstr,log_no);
76: if(qfind(qd,QFIND_NUMBER,atoi(idstr))==-1) {
|
77: // HTTP GET メソッドで / を取得する準備
78: http = http_open(inet, "GET", path, NULL, 0);
79: if (http != NULL) {
80: // HTTP のリクエストを実行(上の GET / )
81: len = http_request(http, NULL, 0, buffer, BUFFER_SIZE);
82: page=page_create(buffer,sizeof(buffer));
83: ea=page_elements(page);
84: el=page_find_elements(page,NULL,"TABLE");
85: for(scan=0;scan |
19:int getmessagedate(struct tm *trec,char *datestr) {
20: char tmp[40];
21:
22: strcpy(tmp,datestr);
23: /* 01234567890123456789012345678901 */
24: /* 2000/12/10 20:20 */
25: tmp[4]='\0';
26: trec->tm_year=atoi(tmp);
27: tmp[7]='\0';
28: trec->tm_mon=atoi(tmp+5);
29: tmp[10]='\0';
30: trec->tm_mday=atoi(tmp+8);
31: tmp[13]='\0';
32: trec->tm_hour=atoi(tmp+11);
33: tmp[16]='\0';
34: trec->tm_min=atoi(tmp+14);
35: trec->tm_sec=0;
36: return 0;
37:}
|
39:int storemessage(char *idstr,char *subject,char *date,char *text) {
40: MSGBUF *tmpmsg;
41: struct tm tmp;
42: char timestamp[128];
43: int result;
44: str tmptext;
45:
46: getmessagedate(&tmp,date);
47: strftime(timestamp,sizeof(timestamp),"%c",&tmp);
48:
49: tmpmsg = (MSGBUF *)malloc(sizeof(MSGBUF));
50: tmptext = "From foo@bar " + timestamp + "\r\n";
51: tmptext = tmptext + "From: スタパ齋藤" + "\r\n";
52: tmptext = tmptext + "X-Number: " + idstr + "\r\n";
53: tmptext = tmptext + "Date: " + timestamp + "\r\n";
54: tmptext = tmptext + "Subject: " + subject + "\r\n";
55: tmptext = tmptext + "\r\n";
56: tmptext = tmptext + text;
57: tmptext = tmptext + "\r\n";
58: tmptext = tmptext + "\r\n";
59:
60: tmpmsg->msgtext = strcpy(malloc(strlen(tmptext)+1),tmptext);
61:
62: tmpmsg->next = MSGSTACK;
63: MSGSTACK = tmpmsg;
64: return result;
65:}
|
246: if(MSGSTACK) {
247: strcpy(filename,TGTFILE);
248: scan=strrchr(filename,'.');
249: if(!scan) scan=strend(filename);
250: strcpy(scan,".g00");
251: out=fopen(filename,"a+");
252: while(MSGSTACK) {
253: ofs++;
254: fwrite(MSGSTACK->msgtext,1,strlen(MSGSTACK->msgtext),out);
255: tmp = MSGSTACK->next;
256: free(MSGSTACK->msgtext);
257: free(MSGSTACK);
258: MSGSTACK = tmp;
259: }
260: fclose(out);
261: qd=qopen(TGTFILE);
262: qupdate(qd);
263: qclose(qd);
264: }
|
269: if((ofs>0)&&autobrowseropen) 270: spawnl(P_NOWAIT, "stpl\\openstpl.rx", "stpl\\openstpl.rx",NULL); |