|
|
1.1 root 1: #line 1 "FILE_OVL.C"
2:
3: /* Developed 1990-1997 by Rob Swindell; PO Box 501, Yorba Linda, CA 92885 */
4:
5: #include "sbbs.h"
6:
7: /****************************************************************************/
8: /* Adds file data in 'f' to DIR#.DAT and DIR#.IXB and updates user */
9: /* info for uploader. Must have .name, .desc and .dir fields filled prior */
10: /* to a call to this function. */
11: /* Returns 1 if file uploaded sucessfully, 0 if not. */
12: /****************************************************************************/
13: char uploadfile(file_t *f)
14: {
15: uchar path[256],str[256],fname[25],ext[513],desc[513],tmp[128],*p;
16: static uchar sbbsfilename[128],sbbsfiledesc[128];
17: int file;
18: uint i;
19: long length;
20: FILE *stream;
21:
22: f->misc=0;
23: curdirnum=f->dir;
24: if(findfile(f->dir,f->name)) {
25: errormsg(WHERE,ERR_CHK,f->name,f->dir);
26: return(0); }
27: sprintf(path,"%s%s",f->altpath>0 && f->altpath<=altpaths
28: ? altpath[f->altpath-1]
29: : dir[f->dir]->path,unpadfname(f->name,fname));
30: if(!fexist(path)) {
31: bprintf(text[FileNotReceived],f->name);
32: sprintf(str,"Attempted to upload %s to %s %s (Not received)",f->name
33: ,lib[dir[f->dir]->lib]->sname,dir[f->dir]->sname);
34: logline("U!",str);
35: return(0); }
36: strcpy(tmp,f->name);
37: truncsp(tmp);
38: for(i=0;i<total_ftests;i++)
39: if(ftest[i]->ext[0]=='*' || !strcmp(tmp+9,ftest[i]->ext)) {
40: if(!chk_ar(ftest[i]->ar,useron))
41: continue;
42: attr(LIGHTGRAY);
43: bputs(ftest[i]->workstr);
44:
45: sprintf(sbbsfilename,"SBBSFILENAME=%.12s",unpadfname(f->name,fname));
46: putenv(sbbsfilename);
47: sprintf(sbbsfiledesc,"SBBSFILEDESC=%.*s",LEN_FDESC,f->desc);
48: putenv(sbbsfiledesc);
49: sprintf(str,"%sSBBSFILE.NAM",node_dir);
50: if((stream=fopen(str,"w"))!=NULL) {
51: fwrite(fname,1,strlen(fname),stream);
52: fclose(stream); }
53: sprintf(str,"%sSBBSFILE.DES",node_dir);
54: if((stream=fopen(str,"w"))!=NULL) {
55: fwrite(f->desc,1,strlen(f->desc),stream);
56: fclose(stream); }
57: if(external(cmdstr(ftest[i]->cmd,path,f->desc,NULL),0)) { /* EX_OUTL */
58: bprintf(text[FileHadErrors],f->name,ftest[i]->ext);
59: if(SYSOP) {
60: if(!yesno(text[DeleteFileQ])) return(0); }
61: remove(path);
62: sprintf(str,"Attempted to upload %s to %s %s (%s Errors)",f->name
63: ,lib[dir[f->dir]->lib]->sname,dir[f->dir]->sname,ftest[i]->ext);
64: logline("U!",str);
65: return(0); }
66: else {
67: sprintf(str,"%sSBBSFILE.NAM",node_dir);
68: if((stream=fopen(str,"r"))!=NULL) {
69: if(fgets(str,128,stream)) {
70: truncsp(str);
71: strupr(str);
72: padfname(str,f->name);
73: strcpy(tmp,f->name);
74: truncsp(tmp);
75: sprintf(path,"%s%s",f->altpath>0 && f->altpath<=altpaths
76: ? altpath[f->altpath-1] : dir[f->dir]->path
77: ,unpadfname(f->name,fname)); }
78: fclose(stream);
79: }
80: sprintf(str,"%sSBBSFILE.DES",node_dir);
81: if((stream=fopen(str,"r"))!=NULL) {
82: if(fgets(str,128,stream)) {
83: truncsp(str);
84: sprintf(f->desc,"%.*s",LEN_FDESC,str); }
85: fclose(stream); }
86: CRLF; } }
87:
88: if((length=flength(path))<=0L) {
89: bprintf(text[FileZeroLength],f->name);
90: remove(path);
91: sprintf(str,"Attempted to upload %s to %s %s (Zero length)",f->name
92: ,lib[dir[f->dir]->lib]->sname,dir[f->dir]->sname);
93: logline("U!",str);
94: return(0); }
95: if(dir[f->dir]->misc&DIR_DIZ) {
96: for(i=0;i<total_fextrs;i++)
97: if(!stricmp(fextr[i]->ext,tmp+9) && chk_ar(fextr[i]->ar,useron))
98: break;
99: if(i<total_fextrs) {
100: sprintf(str,"%sFILE_ID.DIZ",temp_dir);
101: remove(str);
102: external(cmdstr(fextr[i]->cmd,path,"FILE_ID.DIZ",NULL),EX_OUTL);
103: if(!fexist(str)) {
104: sprintf(str,"%sDESC.SDI",temp_dir);
105: remove(str);
106: external(cmdstr(fextr[i]->cmd,path,"DESC.SDI",NULL),EX_OUTL); }
107: if((file=nopen(str,O_RDONLY))!=-1) {
108: memset(ext,0,513);
109: read(file,ext,512);
110: for(i=512;i;i--)
111: if(ext[i-1]>SP)
112: break;
113: ext[i]=0;
114: if(!f->desc[0]) {
115: strcpy(desc,ext);
116: strip_exascii(desc);
117: strip_ctrl(desc);
118: for(i=0;desc[i];i++)
119: if(isalnum(desc[i]))
120: break;
121: sprintf(f->desc,"%.*s",LEN_FDESC,desc+i); }
122: close(file);
123: remove(str);
124: f->misc|=FM_EXTDESC; } } }
125:
126: logon_ulb+=length; /* Update 'this call' stats */
127: logon_uls++;
128: if(dir[f->dir]->misc&DIR_AONLY) /* Forced anonymous */
129: f->misc|=FM_ANON;
130: f->cdt=length;
131: f->dateuled=time(NULL);
132: f->timesdled=0;
133: f->datedled=0L;
134: f->opencount=0;
135: strcpy(f->uler,useron.alias);
136: bprintf(text[FileNBytesReceived],f->name,ultoac(length,tmp));
137: if(!f->desc[0])
138: sprintf(f->desc,"%.*s",LEN_FDESC,text[NoDescription]);
139: if(!addfiledat(f))
140: return(0);
141:
142: if(f->misc&FM_EXTDESC)
143: putextdesc(f->dir,f->datoffset,ext);
144:
145: sprintf(str,"Uploaded %s to %s %s",f->name,lib[dir[f->dir]->lib]->sname
146: ,dir[f->dir]->sname);
147: if(dir[f->dir]->upload_sem[0])
148: if((file=nopen(dir[f->dir]->upload_sem,O_WRONLY|O_CREAT|O_TRUNC))!=-1)
149: close(file);
150: logline("U+",str);
151: /**************************/
152: /* Update Uploader's Info */
153: /**************************/
154: useron.uls=adjustuserrec(useron.number,U_ULS,5,1);
155: useron.ulb=adjustuserrec(useron.number,U_ULB,10,length);
156: if(dir[f->dir]->up_pct && dir[f->dir]->misc&DIR_CDTUL) { /* credit for upload */
157: if(dir[f->dir]->misc&DIR_CDTMIN && cur_cps) /* Give min instead of cdt */
158: useron.min=adjustuserrec(useron.number,U_MIN,10
159: ,((ulong)(length*(dir[f->dir]->up_pct/100.0))/cur_cps)/60);
160: else
161: useron.cdt=adjustuserrec(useron.number,U_CDT,10
162: ,(ulong)(f->cdt*(dir[f->dir]->up_pct/100.0))); }
163: return(1);
164: }
165:
166:
167: /****************************************************************************/
168: /* Updates downloader, uploader and downloaded file data */
169: /* Must have offset, dir and name fields filled prior to call. */
170: /****************************************************************************/
171: void downloadfile(file_t f)
172: {
173: char str[256],str2[256],fname[13];
174: int i,file;
175: long length,mod;
176: ulong l;
177: user_t uploader;
178:
179: getfiledat(&f); /* Get current data - right after download */
180: if((length=f.size)<0L)
181: length=0L;
182: logon_dlb+=length; /* Update 'this call' stats */
183: logon_dls++;
184: bprintf(text[FileNBytesSent],f.name,ultoac(length,tmp));
185: sprintf(str,"Downloaded %s from %s %s",f.name,lib[dir[f.dir]->lib]->sname
186: ,dir[f.dir]->sname);
187: logline("D-",str);
188: /****************************/
189: /* Update Downloader's Info */
190: /****************************/
191: useron.dls=adjustuserrec(useron.number,U_DLS,5,1);
192: useron.dlb=adjustuserrec(useron.number,U_DLB,10,length);
193: if(!(dir[f.dir]->misc&DIR_FREE) && !(useron.exempt&FLAG('D')))
194: subtract_cdt(f.cdt);
195: /**************************/
196: /* Update Uploader's Info */
197: /**************************/
198: i=matchuser(f.uler);
199: uploader.number=i;
200: getuserdat(&uploader);
201: if(i && i!=useron.number && uploader.firston<f.dateuled) {
202: l=f.cdt;
203: if(!(dir[f.dir]->misc&DIR_CDTDL)) /* Don't give credits on d/l */
204: l=0;
205: if(dir[f.dir]->misc&DIR_CDTMIN && cur_cps) { /* Give min instead of cdt */
206: mod=((ulong)(l*(dir[f.dir]->dn_pct/100.0))/cur_cps)/60;
207: adjustuserrec(i,U_MIN,10,mod);
208: sprintf(tmp,"%lu minute",mod);
209: sprintf(str,text[DownloadUserMsg]
210: ,!strcmp(dir[f.dir]->code,"TEMP") ? temp_file : f.name
211: ,!strcmp(dir[f.dir]->code,"TEMP") ? text[Partially] : nulstr
212: ,useron.alias,tmp); }
213: else {
214: mod=(ulong)(l*(dir[f.dir]->dn_pct/100.0));
215: adjustuserrec(i,U_CDT,10,mod);
216: ultoac(mod,tmp);
217: sprintf(str,text[DownloadUserMsg]
218: ,!strcmp(dir[f.dir]->code,"TEMP") ? temp_file : f.name
219: ,!strcmp(dir[f.dir]->code,"TEMP") ? text[Partially] : nulstr
220: ,useron.alias,tmp); }
221: putsmsg(i,str); }
222: /*******************/
223: /* Update IXB File */
224: /*******************/
225: f.datedled=time(NULL);
226: sprintf(str,"%s%s.IXB",dir[f.dir]->data_dir,dir[f.dir]->code);
227: if((file=nopen(str,O_RDWR))==-1) {
228: errormsg(WHERE,ERR_OPEN,str,O_RDWR);
229: return; }
230: length=filelength(file);
231: if(length%F_IXBSIZE) {
232: close(file);
233: errormsg(WHERE,ERR_LEN,str,length);
234: return; }
235: strcpy(fname,f.name);
236: for(i=8;i<12;i++) /* Turn FILENAME.EXT into FILENAMEEXT */
237: fname[i]=fname[i+1];
238: for(l=0;l<length;l+=F_IXBSIZE) {
239: read(file,str,F_IXBSIZE); /* Look for the filename in the IXB file */
240: str[11]=0;
241: if(!strcmp(fname,str)) break; }
242: if(l>=length) {
243: close(file);
244: errormsg(WHERE,ERR_CHK,f.name,0);
245: return; }
246: lseek(file,l+18,SEEK_SET);
247: write(file,&f.datedled,4); /* Write the current time stamp for datedled */
248: close(file);
249: /*******************/
250: /* Update DAT File */
251: /*******************/
252: f.timesdled++;
253: putfiledat(f);
254: /******************************************/
255: /* Update User to User index if necessary */
256: /******************************************/
257: if(f.dir==user_dir) {
258: rmuserxfers(0,useron.number,f.name);
259: if(!getuserxfers(0,0,f.name)) { /* check if any ixt entries left */
260: sprintf(str,"%s%s",f.altpath>0 && f.altpath<=altpaths ?
261: altpath[f.altpath-1] : dir[f.dir]->path,unpadfname(f.name,tmp));
262: remove(str);
263: removefiledat(f); } }
264: }
265:
266: /****************************************************************************/
267: /* Removes DAT and IXB entries for the file in the struct 'f' */
268: /****************************************************************************/
269: void removefiledat(file_t f)
270: {
271: char c,str[256],ixbname[12],HUGE16 *ixbbuf,fname[13];
272: int file;
273: ulong l,length;
274:
275: strcpy(fname,f.name);
276: for(c=8;c<12;c++) /* Turn FILENAME.EXT into FILENAMEEXT */
277: fname[c]=fname[c+1];
278: sprintf(str,"%s%s.IXB",dir[f.dir]->data_dir,dir[f.dir]->code);
279: if((file=nopen(str,O_RDONLY))==-1) {
280: errormsg(WHERE,ERR_OPEN,str,O_RDONLY);
281: return; }
282: length=filelength(file);
283: if(!length) {
284: close(file);
285: return; }
286: if((ixbbuf=(char *)MALLOC(length))==0) {
287: close(file);
288: errormsg(WHERE,ERR_ALLOC,str,length);
289: return; }
290: if(lread(file,ixbbuf,length)!=length) {
291: close(file);
292: errormsg(WHERE,ERR_READ,str,length);
293: FREE((char *)ixbbuf);
294: return; }
295: close(file);
296: if((file=nopen(str,O_WRONLY|O_TRUNC))==-1) {
297: errormsg(WHERE,ERR_OPEN,str,O_WRONLY|O_TRUNC);
298: return; }
299: for(l=0;l<length;l+=F_IXBSIZE) {
300: for(c=0;c<11;c++)
301: ixbname[c]=ixbbuf[l+c];
302: ixbname[c]=0;
303: if(strcmp(ixbname,fname))
304: if(lwrite(file,&ixbbuf[l],F_IXBSIZE)!=F_IXBSIZE) {
305: close(file);
306: errormsg(WHERE,ERR_WRITE,str,F_IXBSIZE);
307: FREE((char *)ixbbuf);
308: return; } }
309: FREE((char *)ixbbuf);
310: close(file);
311: sprintf(str,"%s%s.DAT",dir[f.dir]->data_dir,dir[f.dir]->code);
312: if((file=nopen(str,O_WRONLY))==-1) {
313: errormsg(WHERE,ERR_OPEN,str,O_WRONLY);
314: return; }
315: lseek(file,f.datoffset,SEEK_SET);
316: c=ETX; /* If first char of record is ETX, record is unused */
317: if(write(file,&c,1)!=1) { /* So write a D_T on the first byte of the record */
318: close(file);
319: errormsg(WHERE,ERR_WRITE,str,1);
320: return; }
321: close(file);
322: if(f.dir==user_dir) /* remove file from index */
323: rmuserxfers(0,0,f.name);
324:
325: }
326:
327: /****************************************************************************/
328: /* Puts filedata into DIR_code.DAT file */
329: /* Called from removefiles */
330: /****************************************************************************/
331: void putfiledat(file_t f)
332: {
333: char buf[F_LEN+1],str[256];
334: int file;
335: long length;
336:
337: putrec(buf,F_CDT,LEN_FCDT,ultoa(f.cdt,tmp,10));
338: putrec(buf,F_DESC,LEN_FDESC,f.desc);
339: putrec(buf,F_DESC+LEN_FDESC,2,crlf);
340: putrec(buf,F_ULER,LEN_ALIAS+5,f.uler);
341: putrec(buf,F_ULER+LEN_ALIAS+5,2,crlf);
342: putrec(buf,F_TIMESDLED,5,itoa(f.timesdled,tmp,10));
343: putrec(buf,F_TIMESDLED+5,2,crlf);
344: putrec(buf,F_OPENCOUNT,3,itoa(f.opencount,tmp,10));
345: putrec(buf,F_OPENCOUNT+3,2,crlf);
346: buf[F_MISC]=f.misc+SP;
347: putrec(buf,F_ALTPATH,2,hexplus(f.altpath,tmp));
348: putrec(buf,F_ALTPATH+2,2,crlf);
349: sprintf(str,"%s%s.DAT",dir[f.dir]->data_dir,dir[f.dir]->code);
350: if((file=nopen(str,O_WRONLY))==-1) {
351: errormsg(WHERE,ERR_OPEN,str,O_WRONLY);
352: return; }
353: length=filelength(file);
354: if(length%F_LEN) {
355: close(file);
356: errormsg(WHERE,ERR_LEN,str,length);
357: return; }
358: if(f.datoffset>length) {
359: close(file);
360: errormsg(WHERE,ERR_LEN,str,length);
361: return; }
362: lseek(file,f.datoffset,SEEK_SET);
363: if(write(file,buf,F_LEN)!=F_LEN) {
364: close(file);
365: errormsg(WHERE,ERR_WRITE,str,F_LEN);
366: return; }
367: length=filelength(file);
368: close(file);
369: if(length%F_LEN)
370: errormsg(WHERE,ERR_LEN,str,length);
371: }
372:
373: /****************************************************************************/
374: /* Adds the data for struct filedat to the directory's data base. */
375: /* changes the .datoffset field only */
376: /* returns 1 if added successfully, 0 if not. */
377: /****************************************************************************/
378: char addfiledat(file_t *f)
379: {
380: uchar str[256],fdat[F_LEN+1],fname[13],idx[3],c,HUGE16 *ixbbuf;
381: int i,file;
382: ulong length,l;
383: time_t uldate;
384:
385: /************************/
386: /* Add data to DAT File */
387: /************************/
388: sprintf(str,"%s%s.DAT",dir[f->dir]->data_dir,dir[f->dir]->code);
389: if((file=nopen(str,O_RDWR|O_CREAT))==-1) {
390: errormsg(WHERE,ERR_OPEN,str,O_RDWR|O_CREAT);
391: return(0); }
392: length=filelength(file);
393: if(length==0L)
394: l=0L;
395: else {
396: if(length%F_LEN) {
397: close(file);
398: errormsg(WHERE,ERR_LEN,str,length);
399: return(0); }
400: for(l=0;l<length;l+=F_LEN) { /* Find empty slot */
401: lseek(file,l,SEEK_SET);
402: read(file,&c,1);
403: if(c==ETX) break; }
404: if(l/F_LEN>=MAX_FILES || l/F_LEN>=dir[f->dir]->maxfiles) {
405: bputs(text[DirFull]);
406: close(file);
407: sprintf(str,"Directory Full: %s %s"
408: ,lib[dir[f->dir]->lib]->sname,dir[f->dir]->sname);
409: logline("U!",str);
410: return(0); } }
411: putrec(fdat,F_CDT,LEN_FCDT,ultoa(f->cdt,tmp,10));
412: putrec(fdat,F_DESC,LEN_FDESC,f->desc);
413: putrec(fdat,F_DESC+LEN_FDESC,2,crlf);
414: putrec(fdat,F_ULER,LEN_ALIAS+5,f->uler);
415: putrec(fdat,F_ULER+LEN_ALIAS+5,2,crlf);
416: putrec(fdat,F_TIMESDLED,5,ultoa(f->timesdled,tmp,10));
417: putrec(fdat,F_TIMESDLED+5,2,crlf);
418: putrec(fdat,F_OPENCOUNT,3,itoa(f->opencount,tmp,10));
419: putrec(fdat,F_OPENCOUNT+3,2,crlf);
420: fdat[F_MISC]=f->misc+SP;
421: putrec(fdat,F_ALTPATH,2,hexplus(f->altpath,tmp));
422: putrec(fdat,F_ALTPATH+2,2,crlf);
423: f->datoffset=l;
424: idx[0]=l&0xff; /* Get offset within DAT file for IXB file */
425: idx[1]=(l>>8)&0xff;
426: idx[2]=(l>>16)&0xff;
427: lseek(file,l,SEEK_SET);
428: if(write(file,fdat,F_LEN)!=F_LEN) {
429: close(file);
430: errormsg(WHERE,ERR_WRITE,str,F_LEN);
431: return(0); }
432: length=filelength(file);
433: close(file);
434: if(length%F_LEN)
435: errormsg(WHERE,ERR_LEN,str,length);
436:
437: /*******************************************/
438: /* Update last upload date/time stamp file */
439: /*******************************************/
440: sprintf(str,"%s%s.DAB",dir[f->dir]->data_dir,dir[f->dir]->code);
441: if((file=nopen(str,O_WRONLY|O_CREAT))==-1)
442: errormsg(WHERE,ERR_OPEN,str,O_WRONLY|O_CREAT);
443: else {
444: now=time(NULL);
445: write(file,&now,4);
446: close(file); }
447:
448: /************************/
449: /* Add data to IXB File */
450: /************************/
451: strcpy(fname,f->name);
452: for(i=8;i<12;i++) /* Turn FILENAME.EXT into FILENAMEEXT */
453: fname[i]=fname[i+1];
454: sprintf(str,"%s%s.IXB",dir[f->dir]->data_dir,dir[f->dir]->code);
455: if((file=nopen(str,O_RDWR|O_CREAT))==-1) {
456: errormsg(WHERE,ERR_OPEN,str,O_RDWR|O_CREAT);
457: return(0); }
458: length=filelength(file);
459: if(length) { /* IXB file isn't empty */
460: if(length%F_IXBSIZE) {
461: close(file);
462: errormsg(WHERE,ERR_LEN,str,length);
463: return(0); }
464: if((ixbbuf=(char *)MALLOC(length))==NULL) {
465: close(file);
466: errormsg(WHERE,ERR_ALLOC,str,length);
467: return(0); }
468: if(lread(file,ixbbuf,length)!=length) {
469: close(file);
470: errormsg(WHERE,ERR_READ,str,length);
471: FREE((char *)ixbbuf);
472: return(0); }
473: /************************************************/
474: /* Sort by Name or Date, Assending or Decending */
475: /************************************************/
476: if(dir[f->dir]->sort==SORT_NAME_A || dir[f->dir]->sort==SORT_NAME_D) {
477: for(l=0;l<length;l+=F_IXBSIZE) {
478: for(i=0;i<12 && fname[i]==ixbbuf[l+i];i++);
479: if(i==12) { /* file already in directory index */
480: close(file);
481: errormsg(WHERE,ERR_CHK,str,0);
482: FREE((char *)ixbbuf);
483: return(0); }
484: if(dir[f->dir]->sort==SORT_NAME_A && fname[i]<ixbbuf[l+i])
485: break;
486: if(dir[f->dir]->sort==SORT_NAME_D && fname[i]>ixbbuf[l+i])
487: break; } }
488: else { /* sort by date */
489: for(l=0;l<length;l+=F_IXBSIZE) {
490: uldate=(ixbbuf[l+14]|((long)ixbbuf[l+15]<<8)
491: |((long)ixbbuf[l+16]<<16)|((long)ixbbuf[l+17]<<24));
492: if(dir[f->dir]->sort==SORT_DATE_A && f->dateuled<uldate)
493: break;
494: if(dir[f->dir]->sort==SORT_DATE_D && f->dateuled>uldate)
495: break; } }
496: lseek(file,l,SEEK_SET);
497: if(write(file,fname,11)!=11) { /* Write filename to IXB file */
498: close(file);
499: errormsg(WHERE,ERR_WRITE,str,11);
500: FREE((char *)ixbbuf);
501: return(0); }
502: if(write(file,idx,3)!=3) { /* Write DAT offset into IXB file */
503: close(file);
504: errormsg(WHERE,ERR_WRITE,str,3);
505: FREE((char *)ixbbuf);
506: return(0); }
507: write(file,&f->dateuled,sizeof(time_t));
508: write(file,&f->datedled,4); /* Write 0 for datedled */
509: if(lwrite(file,&ixbbuf[l],length-l)!=length-l) { /* Write rest of IXB */
510: close(file);
511: errormsg(WHERE,ERR_WRITE,str,length-l);
512: FREE((char *)ixbbuf);
513: return(0); }
514: FREE((char *)ixbbuf); }
515: else { /* IXB file is empty... No files */
516: if(write(file,fname,11)!=11) { /* Write filename it IXB file */
517: close(file);
518: errormsg(WHERE,ERR_WRITE,str,11);
519: return(0); }
520: if(write(file,idx,3)!=3) { /* Write DAT offset into IXB file */
521: close(file);
522: errormsg(WHERE,ERR_WRITE,str,3);
523: return(0); }
524: write(file,&f->dateuled,sizeof(time_t));
525: write(file,&f->datedled,4); }
526: length=filelength(file);
527: close(file);
528: if(length%F_IXBSIZE)
529: errormsg(WHERE,ERR_LEN,str,length);
530: return(1);
531: }
532:
533: /****************************************************************************/
534: /* Update the upload date for the file 'f' */
535: /****************************************************************************/
536: void update_uldate(file_t f)
537: {
538: char str[256],fname[13];
539: int i,file;
540: long l,length;
541:
542: /*******************/
543: /* Update IXB File */
544: /*******************/
545: sprintf(str,"%s%s.IXB",dir[f.dir]->data_dir,dir[f.dir]->code);
546: if((file=nopen(str,O_RDWR))==-1) {
547: errormsg(WHERE,ERR_OPEN,str,O_RDWR);
548: return; }
549: length=filelength(file);
550: if(length%F_IXBSIZE) {
551: close(file);
552: errormsg(WHERE,ERR_LEN,str,length);
553: return; }
554: strcpy(fname,f.name);
555: for(i=8;i<12;i++) /* Turn FILENAME.EXT into FILENAMEEXT */
556: fname[i]=fname[i+1];
557: for(l=0;l<length;l+=F_IXBSIZE) {
558: read(file,str,F_IXBSIZE); /* Look for the filename in the IXB file */
559: str[11]=0;
560: if(!strcmp(fname,str)) break; }
561: if(l>=length) {
562: close(file);
563: errormsg(WHERE,ERR_CHK,f.name,length);
564: return; }
565: lseek(file,l+14,SEEK_SET);
566: write(file,&f.dateuled,4);
567: close(file);
568:
569: /*******************************************/
570: /* Update last upload date/time stamp file */
571: /*******************************************/
572: sprintf(str,"%s%s.DAB",dir[f.dir]->data_dir,dir[f.dir]->code);
573: if((file=nopen(str,O_WRONLY|O_CREAT))==-1)
574: errormsg(WHERE,ERR_OPEN,str,O_WRONLY|O_CREAT);
575: else {
576: write(file,&f.dateuled,4);
577: close(file); }
578:
579: }
580:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.