int txtcp(void) { int rc=0; file_list *tosend = NULL, *respond = NULL; char *nonhold_mail; Syslog('+', "TCP: outbound session start"); nonhold_mail = (char *)ALL_MAIL; if (emsi_remote_lcodes & LCODE_HAT) { Syslog('+', "Remote asked to \"hold all traffic\", no send"); tosend=NULL; } else tosend = create_filelist(remote,nonhold_mail,0); if ((tosend != NULL) || ((emsi_remote_lcodes & LCODE_NPU) == 0)) rc = tcpsndfiles(tosend); if (rc == 0) if ((rc = tcprcvfiles()) == 0) if ((emsi_local_opts & OPT_NRQ) == 0) if ((respond = respond_wazoo())) rc = tcpsndfiles(respond); tidy_filelist(tosend,(rc == 0)); tidy_filelist(respond,0); if (rc) WriteError("TCP: session failed: rc=%d", rc); else Syslog('+', "TCP: session completed"); return rc; }
int rxtcp(void) { int rc = 0; fa_list *eff_remote, tmpl; file_list *tosend = NULL, **tmpfl; Syslog('+', "TCP: inbound session start"); if (emsi_remote_lcodes & LCODE_NPU) { Syslog('+', "Remote requested \"no pickup\", no send"); eff_remote=NULL; } else if (emsi_remote_lcodes & LCODE_PUP) { Syslog('+', "Remote requested \"pickup primary\""); tmpl.addr=remote->addr; tmpl.next=NULL; eff_remote=&tmpl; } else eff_remote=remote; tosend = create_filelist(eff_remote, (char *)ALL_MAIL, 0); if ((rc=tcprcvfiles()) == 0) { if ((emsi_local_opts & OPT_NRQ) == 0) { for (tmpfl = &tosend; *tmpfl; tmpfl = &((*tmpfl)->next)); *tmpfl = respond_wazoo(); } if ((tosend != NULL) || ((emsi_remote_lcodes & LCODE_NPU) == 0)) rc = tcpsndfiles(tosend); if ((rc == 0) && (made_request)) { Syslog('+', "TCP: freq was made, trying to receive files"); rc = tcprcvfiles(); } } tidy_filelist(tosend,(rc == 0)); if (rc) WriteError("TCP: session failed: rc=%d", rc); else Syslog('+', "TCP: session completed"); return rc; }
int main(int argc, char **argv) { static struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"noclear", no_argument, 0, 'c'}, {"alpha", no_argument, 0, 'a'}, {"unhide", no_argument, 0, 'u'}, {"noinfo", no_argument, 0, 'i'}, {"stretch", no_argument, 0, 'f'}, {"colorstrech", no_argument, 0, 'k'}, {"delay", required_argument, 0, 's'}, {"enlarge", no_argument, 0, 'e'}, {"ignore-aspect", no_argument, 0, 'r'}, {"play_folder", required_argument, 0, 'd'}, {0, 0, 0, 0} }; int c, i; char* filelist=NULL; video_out_t vo={0}; vo.name="gles"; if(argc < 2) { help(argv[0]); fprintf(stderr, "Error: Required argument missing.\n"); return(1); } while((c = getopt_long_only(argc, argv, "hcauifks:er", long_options, NULL)) != EOF) { switch(c) { case 'a': opt_alpha = 1; break; case 'c': opt_clear = 0; break; case 's': opt_delay = atoi(optarg); break; case 'u': opt_hide_cursor = 0; break; case 'h': help(argv[0]); return(0); case 'i': opt_image_info = 0; break; case 'f': opt_stretch = 1; break; case 'k': opt_stretch = 2; break; case 'e': opt_enlarge = 1; break; case 'r': opt_ignore_aspect = 1; break; case 'd': filelist = create_filelist(optarg); break; } } #if 0 if(!argv[optind]) { fprintf(stderr, "Required argument missing! Consult %s -h.\n", argv[0]); return(1); } #endif if(vo_cfg(&vo)!=VO_ERROR_OK) { printf("video out device invalid\n"); exit(1); } vo_preinit(&vo); #ifndef WIN32 signal(SIGHUP, sighandler); signal(SIGINT, sighandler); signal(SIGQUIT, sighandler); signal(SIGSEGV, sighandler); signal(SIGTERM, sighandler); signal(SIGABRT, sighandler); if(opt_hide_cursor) { printf("\033[?25l"); fflush(stdout); } setup_console(1); #endif if(filelist) { filelist_t* pre=NULL; char* filename; while(enum_file(filelist,&pre,&filename)!=-1) { if(filename&&strlen(filename)>3) show_image(filename,&vo); } free_filelist(filelist); } else { for(i = optind; argv[i]; ) { int r = show_image(argv[i],&vo); if(!r) break; i += r; if(i < optind) i = optind; } } setup_console(0); if(opt_hide_cursor) { printf("\033[?25h"); fflush(stdout); } vo_uninit(&vo); return(0); }
int main(int argc, char **argv) { signed char op; parserinfo_mv_t pinfo; filelist_t fl; struct option longopts[] = { { "version", 0, NULL, MV_VERSION }, { "help", 0, NULL, MV_HELP }, { "write-files", 0, NULL, MV_FILES }, { "prepend", 0, NULL, MV_PREPEND }, { "replace", 0, NULL, MV_REPLACE }, { "append", 0, NULL, MV_APPEND }, { 0 } }; progname = "xml-mv"; inputfile = ""; inputline = 0; if( create_parserinfo_mv(&pinfo) ) { while( (op = getopt_long(argc, argv, "", longopts, NULL)) > -1 ) { set_option_mv(op, optarg, &pinfo); } init_signal_handling(SIGNALS_DEFAULT); init_file_handling(); init_tempfile_handling(); init_rollback_handling(); if( !checkflag(pinfo.rcm.flags,RCM_CP_PREPEND|RCM_CP_APPEND) ) { setflag(&pinfo.rcm.flags,RCM_CP_APPEND); setflag(&pinfo.rcm.flags,RCM_CP_REPLACE); } if( create_filelist(&fl, -1, argv + optind, FILELIST_MIN2) ) { pinfo.files = getfiles_filelist(&fl); pinfo.xpaths = getxpaths_filelist(&fl); pinfo.n = getsize_filelist(&fl); if( pinfo.n < 2 ) { errormsg(E_FATAL, "no target specified (try --help).\n"); } pinfo.target = pinfo.files[pinfo.n - 1]; pinfo.tpaths = pinfo.xpaths[pinfo.n - 1]; if( !checkflag(pinfo.rcm.flags,RCM_WRITE_FILES) ) { /* When --write-files is not selected, we cannot write * to the files on the command line. So we use the following * trick to implement moves within the target file (last on command * line): we replace all instances of the target with a common * tempfile, which we can write to as required. The first instance * of the target is not replaced, since it must be read (to copy * its contents into the tempfile). */ substitute_target(&pinfo); } if( stdparse2(pinfo.n - 1, pinfo.files, pinfo.xpaths, &pinfo.std) ) { if( reinit_parserinfo_mv(&pinfo) ) { /* output always to stdout */ setflag(&pinfo.rcm.flags, RCM_CP_OUTPUT); clearflag(&pinfo.rcm.flags, RCM_RM_OUTPUT); stdparse2(1, &pinfo.files[pinfo.n - 1], &pinfo.xpaths[pinfo.n - 1], &pinfo.std); } } free_filelist(&fl); } exit_rollback_handling(); exit_tempfile_handling(); exit_file_handling(); exit_signal_handling(); free_parserinfo_mv(&pinfo); } return EXIT_SUCCESS; }
bool sbbs_t::pack_qwk(char *packet, ulong *msgcnt, bool prepack) { char str[MAX_PATH+1],ch,*p; char tmp[MAX_PATH+1],tmp2[MAX_PATH+1]; char* fname; char* fmode; int mode; uint i,j,k,conf; long l,size,msgndx,posts,ex; long mailmsgs=0; ulong totalcdt,totaltime,lastmsg ,files,submsgs,msgs,netfiles=0,preqwk=0; ulong subs_scanned=0; float f; /* Sparky is responsible */ time_t start; node_t node; mail_t *mail; post_t *post; glob_t g; FILE *stream,*qwk,*personal,*ndx; DIR* dir; DIRENT* dirent; struct tm tm; smbmsg_t msg; ex=EX_OUTL|EX_OUTR; /* Need sh for wildcard expansion */ if(prepack) ex|=EX_OFFLINE; delfiles(cfg.temp_dir,ALLFILES); sprintf(str,"%sfile/%04u.qwk",cfg.data_dir,useron.number); if(fexistcase(str)) { for(k=0;k<cfg.total_fextrs;k++) if(!stricmp(cfg.fextr[k]->ext,useron.tmpext) && chk_ar(cfg.fextr[k]->ar,&useron)) break; if(k>=cfg.total_fextrs) k=0; p=cmdstr(cfg.fextr[k]->cmd,str,ALLFILES,NULL); if((i=external(p,ex))==0) preqwk=1; else errormsg(WHERE,ERR_EXEC,p,i); } if(useron.rest&FLAG('Q') && useron.qwk&QWK_RETCTLA) useron.qwk|=(QWK_NOINDEX|QWK_NOCTRL|QWK_VIA|QWK_TZ|QWK_MSGID); if(useron.qwk&QWK_EXPCTLA) mode=A_EXPAND; else if(useron.qwk&QWK_RETCTLA) mode=A_LEAVE; else mode=0; if(useron.qwk&QWK_TZ) mode|=QM_TZ; if(useron.qwk&QWK_VIA) mode|=QM_VIA; if(useron.qwk&QWK_MSGID) mode|=QM_MSGID; (*msgcnt)=0L; if(/* !prepack && */ !(useron.qwk&QWK_NOCTRL)) { /***************************/ /* Create CONTROL.DAT file */ /***************************/ sprintf(str,"%sCONTROL.DAT",cfg.temp_dir); if((stream=fopen(str,"wb"))==NULL) { errormsg(WHERE,ERR_OPEN,str,0); return(false); } now=time(NULL); if(localtime_r(&now,&tm)==NULL) return(false); fprintf(stream,"%s\r\n%s\r\n%s\r\n%s, Sysop\r\n0000,%s\r\n" "%02u-%02u-%u,%02u:%02u:%02u\r\n" ,cfg.sys_name ,cfg.sys_location ,cfg.node_phone ,cfg.sys_op ,cfg.sys_id ,tm.tm_mon+1,tm.tm_mday,tm.tm_year+1900 ,tm.tm_hour,tm.tm_min,tm.tm_sec); k=0; for(i=0;i<usrgrps;i++) for(j=0;j<usrsubs[i];j++) k++; /* k is how many subs */ fprintf(stream,"%s\r\n\r\n0\r\n0\r\n%u\r\n",useron.alias,k); fprintf(stream,"0\r\nE-mail\r\n"); /* first conference is e-mail */ char confname[256]; for(i=0;i<usrgrps;i++) for(j=0;j<usrsubs[i];j++) { if(useron.qwk&QWK_EXT) /* 255 char max */ sprintf(confname,"%s %s" ,cfg.grp[cfg.sub[usrsub[i][j]]->grp]->sname ,cfg.sub[usrsub[i][j]]->lname); else /* 10 char max */ strcpy(confname,cfg.sub[usrsub[i][j]]->qwkname); fprintf(stream,"%u\r\n%s\r\n" ,cfg.sub[usrsub[i][j]]->qwkconf ? cfg.sub[usrsub[i][j]]->qwkconf : ((i+1)*1000)+j+1,confname); } fprintf(stream,"HELLO\r\nBBSNEWS\r\nGOODBYE\r\n"); fclose(stream); /***********************/ /* Create DOOR.ID File */ /***********************/ sprintf(str,"%sDOOR.ID",cfg.temp_dir); if((stream=fopen(str,"wb"))==NULL) { errormsg(WHERE,ERR_OPEN,str,0); return(false); } p="CONTROLTYPE = "; fprintf(stream,"DOOR = %.10s\r\nVERSION = %s%c\r\n" "SYSTEM = %s\r\n" "CONTROLNAME = SBBS\r\n" "%sADD\r\n" "%sDROP\r\n" "%sYOURS\r\n" "%sRESET\r\n" "%sRESETALL\r\n" "%sFILES\r\n" "%sATTACH\r\n" "%sOWN\r\n" "%smail\r\n" "%sDELMAIL\r\n" "%sCTRL-A\r\n" "%sFREQ\r\n" "%sNDX\r\n" "%sTZ\r\n" "%sVIA\r\n" "%sCONTROL\r\n" "MIXEDCASE = YES\r\n" ,VERSION_NOTICE ,VERSION,REVISION ,VERSION_NOTICE ,p,p,p,p ,p,p,p,p ,p,p,p,p ,p,p,p,p ); fclose(stream); if(useron.rest&FLAG('Q')) { /***********************/ /* Create NETFLAGS.DAT */ /***********************/ sprintf(str,"%sNETFLAGS.DAT",cfg.temp_dir); if((stream=fopen(str,"wb"))==NULL) { errormsg(WHERE,ERR_CREATE,str,0); return(false); } ch=1; /* Net enabled */ if(usrgrps) for(i=0;i<(usrgrps*1000)+usrsubs[usrgrps-1];i++) fputc(ch,stream); fclose(stream); } } /****************************************************/ /* Create MESSAGES.DAT, write header and leave open */ /****************************************************/ sprintf(str,"%sMESSAGES.DAT",cfg.temp_dir); if(fexistcase(str)) fmode="r+b"; else fmode="w+b"; if((qwk=fopen(str,fmode))==NULL) { errormsg(WHERE,ERR_OPEN,str,0); return(false); } l=filelength(fileno(qwk)); if(l<1) { fprintf(qwk,"%-128.128s","Produced by " VERSION_NOTICE " " COPYRIGHT_NOTICE); msgndx=1; } else { msgndx=l/QWK_BLOCK_LEN; fseek(qwk,0,SEEK_END); } sprintf(str,"%sNEWFILES.DAT",cfg.temp_dir); remove(str); if(!(useron.rest&FLAG('T')) && useron.qwk&QWK_FILES) files=create_filelist("NEWFILES.DAT",FL_ULTIME); else files=0; start=time(NULL); if(useron.rest&FLAG('Q')) useron.qwk|=(QWK_EMAIL|QWK_ALLMAIL|QWK_DELMAIL); if(!(useron.qwk&QWK_NOINDEX)) { sprintf(str,"%sPERSONAL.NDX",cfg.temp_dir); if((personal=fopen(str,"ab"))==NULL) { fclose(qwk); errormsg(WHERE,ERR_OPEN,str,0); return(false); } } else personal=NULL; if(useron.qwk&(QWK_EMAIL|QWK_ALLMAIL) /* && !prepack */) { sprintf(smb.file,"%smail",cfg.data_dir); smb.retry_time=cfg.smb_retry_time; smb.subnum=INVALID_SUB; if((i=smb_open(&smb))!=0) { fclose(qwk); if(personal) fclose(personal); errormsg(WHERE,ERR_OPEN,smb.file,i,smb.last_error); return(false); } /***********************/ /* Pack E-mail, if any */ /***********************/ qwkmail_last=0; mail=loadmail(&smb,&mailmsgs,useron.number,0,useron.qwk&QWK_ALLMAIL ? 0 : LM_UNREAD); if(mailmsgs && !(sys_status&SS_ABORT)) { bputs(text[QWKPackingEmail]); if(!(useron.qwk&QWK_NOINDEX)) { sprintf(str,"%s000.NDX",cfg.temp_dir); if((ndx=fopen(str,"ab"))==NULL) { fclose(qwk); if(personal) fclose(personal); smb_close(&smb); errormsg(WHERE,ERR_OPEN,str,0); free(mail); return(false); } } else ndx=NULL; if(useron.rest&FLAG('Q')) mode|=QM_TO_QNET; else mode&=~QM_TO_QNET; for(l=0;l<mailmsgs;l++) { bprintf("\b\b\b\b\b\b\b\b\b\b\b\b%4lu of %-4lu" ,l+1,mailmsgs); memset(&msg,0,sizeof(msg)); msg.idx=mail[l]; if(msg.idx.number>qwkmail_last) qwkmail_last=msg.idx.number; if(!loadmsg(&msg,mail[l].number)) continue; if(msg.hdr.auxattr&MSG_FILEATTACH && useron.qwk&QWK_ATTACH) { sprintf(str,"%sfile/%04u.in/%s" ,cfg.data_dir,useron.number,msg.subj); sprintf(tmp,"%s%s",cfg.temp_dir,msg.subj); if(fexistcase(str) && !fexistcase(tmp)) mv(str,tmp,1); } size=msgtoqwk(&msg,qwk,mode,INVALID_SUB,0); smb_unlockmsghdr(&smb,&msg); smb_freemsgmem(&msg); if(ndx) { msgndx++; f=ltomsbin(msgndx); /* Record number */ ch=0; /* Sub number, not used */ if(personal) { fwrite(&f,4,1,personal); fwrite(&ch,1,1,personal); } fwrite(&f,4,1,ndx); fwrite(&ch,1,1,ndx); msgndx+=size/QWK_BLOCK_LEN; } YIELD(); /* yield */ } bprintf(text[QWKPackedEmail],mailmsgs); if(ndx) fclose(ndx); } smb_close(&smb); /* Close the e-mail */ if(mailmsgs) free(mail); } /*********************/ /* Pack new messages */ /*********************/ for(i=0;i<usrgrps;i++) { for(j=0;j<usrsubs[i] && !msgabort();j++) { if(subscan[usrsub[i][j]].cfg&SUB_CFG_NSCAN || (!(useron.rest&FLAG('Q')) && cfg.sub[usrsub[i][j]]->misc&SUB_FORCED)) { if(!chk_ar(cfg.sub[usrsub[i][j]]->read_ar,&useron)) continue; lncntr=0; /* defeat pause */ if(useron.rest&FLAG('Q') && !(cfg.sub[usrsub[i][j]]->misc&SUB_QNET)) continue; /* QWK Net Node and not QWK networked, so skip */ subs_scanned++; msgs=getlastmsg(usrsub[i][j],&lastmsg,0); if(!msgs || lastmsg<=subscan[usrsub[i][j]].ptr) { /* no msgs */ if(subscan[usrsub[i][j]].ptr>lastmsg) { /* corrupted ptr */ outchar('*'); subscan[usrsub[i][j]].ptr=lastmsg; /* so fix automatically */ subscan[usrsub[i][j]].last=lastmsg; } bprintf(text[NScanStatusFmt] ,cfg.grp[cfg.sub[usrsub[i][j]]->grp]->sname ,cfg.sub[usrsub[i][j]]->lname,0L,msgs); continue; } sprintf(smb.file,"%s%s" ,cfg.sub[usrsub[i][j]]->data_dir,cfg.sub[usrsub[i][j]]->code); smb.retry_time=cfg.smb_retry_time; smb.subnum=usrsub[i][j]; if((k=smb_open(&smb))!=0) { errormsg(WHERE,ERR_OPEN,smb.file,k,smb.last_error); continue; } k=0; if(useron.qwk&QWK_BYSELF) k|=LP_BYSELF; if(useron.rest&FLAG('Q') || !(subscan[usrsub[i][j]].cfg&SUB_CFG_YSCAN)) k|=LP_OTHERS; post=loadposts(&posts,usrsub[i][j],subscan[usrsub[i][j]].ptr,k); bprintf(text[NScanStatusFmt] ,cfg.grp[cfg.sub[usrsub[i][j]]->grp]->sname ,cfg.sub[usrsub[i][j]]->lname,posts,msgs); if(!posts) { /* no new messages */ smb_close(&smb); continue; } bputs(text[QWKPackingSubboard]); submsgs=0; conf=cfg.sub[usrsub[i][j]]->qwkconf; if(!conf) conf=((i+1)*1000)+j+1; if(!(useron.qwk&QWK_NOINDEX)) { sprintf(str,"%s%u.NDX",cfg.temp_dir,conf); if((ndx=fopen(str,"ab"))==NULL) { fclose(qwk); if(personal) fclose(personal); smb_close(&smb); errormsg(WHERE,ERR_OPEN,str,0); free(post); return(false); } } else ndx=NULL; for(l=0;l<posts && !msgabort();l++) { bprintf("\b\b\b\b\b%-5lu",l+1); subscan[usrsub[i][j]].ptr=post[l].number; /* set ptr */ subscan[usrsub[i][j]].last=post[l].number; /* set last read */ memset(&msg,0,sizeof(msg)); msg.idx=post[l]; if(!loadmsg(&msg,post[l].number)) continue; if(useron.rest&FLAG('Q')) { if(msg.from_net.type && msg.from_net.type!=NET_QWK && !(cfg.sub[usrsub[i][j]]->misc&SUB_GATE)) { /* From other */ smb_freemsgmem(&msg); /* net, don't gate */ smb_unlockmsghdr(&smb,&msg); continue; } mode|=(QM_TO_QNET|QM_TAGLINE); if(msg.from_net.type==NET_QWK) { mode&=~QM_TAGLINE; if(route_circ((char *)msg.from_net.addr,useron.alias) || !strnicmp(msg.subj,"NE:",3)) { smb_freemsgmem(&msg); smb_unlockmsghdr(&smb,&msg); continue; } } } else mode&=~(QM_TAGLINE|QM_TO_QNET); size=msgtoqwk(&msg,qwk,mode,usrsub[i][j],conf); smb_unlockmsghdr(&smb,&msg); if(ndx) { msgndx++; f=ltomsbin(msgndx); /* Record number */ ch=0; /* Sub number, not used */ if(personal && (!stricmp(msg.to,useron.alias) || !stricmp(msg.to,useron.name))) { fwrite(&f,4,1,personal); fwrite(&ch,1,1,personal); } fwrite(&f,4,1,ndx); fwrite(&ch,1,1,ndx); msgndx+=size/QWK_BLOCK_LEN; } smb_freemsgmem(&msg); (*msgcnt)++; submsgs++; if(cfg.max_qwkmsgs && !(useron.exempt&FLAG('O')) && (*msgcnt)>=cfg.max_qwkmsgs) { bputs(text[QWKmsgLimitReached]); break; } if(!(l%50)) YIELD(); /* yield */ } if(!(sys_status&SS_ABORT)) bprintf(text[QWKPackedSubboard],submsgs,(*msgcnt)); if(ndx) { fclose(ndx); sprintf(str,"%s%u.NDX",cfg.temp_dir,conf); if(!flength(str)) remove(str); } smb_close(&smb); free(post); if(l<posts) break; YIELD(); /* yield */ } } if(j<usrsubs[i]) /* if sub aborted, abort all */ break; } if(online==ON_LOCAL) /* event */ eprintf(LOG_INFO,"%s scanned %lu sub-boards for new messages" ,useron.alias,subs_scanned); else lprintf(LOG_INFO,"Node %d %s scanned %lu sub-boards for new messages" ,cfg.node_num,useron.alias,subs_scanned); if((*msgcnt)+mailmsgs && time(NULL)-start) { bprintf("\r\n\r\n\1n\1hPacked %lu messages (%lu bytes) in %lu seconds " "(%lu messages/second)." ,(*msgcnt)+mailmsgs ,ftell(qwk) ,time(NULL)-start ,((*msgcnt)+mailmsgs)/(time(NULL)-start)); sprintf(str,"Packed %lu messages (%lu bytes) in %lu seconds (%lu msgs/sec)" ,(*msgcnt)+mailmsgs ,ftell(qwk) ,(ulong)(time(NULL)-start) ,((*msgcnt)+mailmsgs)/(time(NULL)-start)); if(online==ON_LOCAL) /* event */ eprintf(LOG_INFO,"%s",str); else lprintf(LOG_INFO,"%s",str); } fclose(qwk); /* close MESSAGE.DAT */ if(personal) { fclose(personal); /* close PERSONAL.NDX */ sprintf(str,"%sPERSONAL.NDX",cfg.temp_dir); if(!flength(str)) remove(str); } CRLF; if(!prepack && (sys_status&SS_ABORT || !online)) return(false); if(/*!prepack && */ useron.rest&FLAG('Q')) { /* If QWK Net node, check for files */ sprintf(str,"%sqnet/%s.out/",cfg.data_dir,useron.alias); dir=opendir(str); while(dir!=NULL && (dirent=readdir(dir))!=NULL) { /* Move files into temp dir */ sprintf(str,"%sqnet/%s.out/%s",cfg.data_dir,useron.alias,dirent->d_name); if(isdir(str)) continue; sprintf(tmp2,"%s%s",cfg.temp_dir,dirent->d_name); lncntr=0; /* Default pause */ if(online==ON_LOCAL) eprintf(LOG_INFO,"Including %s in packet",str); else lprintf(LOG_INFO,"Including %s in packet",str); bprintf(text[RetrievingFile],str); if(!mv(str,tmp2,1)) netfiles++; } if(dir!=NULL) closedir(dir); if(netfiles) CRLF; } if(batdn_total) { for(i=0,totalcdt=0;i<batdn_total;i++) if(!is_download_free(&cfg,batdn_dir[i],&useron)) totalcdt+=batdn_cdt[i]; if(totalcdt>useron.cdt+useron.freecdt) { bprintf(text[YouOnlyHaveNCredits] ,ultoac(useron.cdt+useron.freecdt,tmp)); } else { for(i=0,totaltime=0;i<batdn_total;i++) { if(!(cfg.dir[batdn_dir[i]]->misc&DIR_TFREE) && cur_cps) totaltime+=batdn_size[i]/(ulong)cur_cps; } if(!(useron.exempt&FLAG('T')) && !SYSOP && totaltime>timeleft) bputs(text[NotEnoughTimeToDl]); else { for(i=0;i<batdn_total;i++) { lncntr=0; unpadfname(batdn_name[i],tmp); sprintf(tmp2,"%s%s",cfg.temp_dir,tmp); if(!fexistcase(tmp2)) { seqwait(cfg.dir[batdn_dir[i]]->seqdev); bprintf(text[RetrievingFile],tmp); sprintf(str,"%s%s" ,batdn_alt[i]>0 && batdn_alt[i]<=cfg.altpaths ? cfg.altpath[batdn_alt[i]-1] : cfg.dir[batdn_dir[i]]->path ,tmp); mv(str,tmp2,1); /* copy the file to temp dir */ getnodedat(cfg.node_num,&thisnode,1); thisnode.aux=0xfe; putnodedat(cfg.node_num,&thisnode); CRLF; } } } } } if(!(*msgcnt) && !mailmsgs && !files && !netfiles && !batdn_total && (prepack || !preqwk)) { bputs(text[QWKNoNewMessages]); return(false); } if(!(useron.rest&FLAG('Q'))) { /* Don't include in network */ /***********************/ /* packets */ /* Copy QWK Text files */ /***********************/ sprintf(str,"%sQWK/HELLO",cfg.text_dir); if(fexistcase(str)) { sprintf(tmp2,"%sHELLO",cfg.temp_dir); mv(str,tmp2,1); } sprintf(str,"%sQWK/BBSNEWS",cfg.text_dir); if(fexistcase(str)) { sprintf(tmp2,"%sBBSNEWS",cfg.temp_dir); mv(str,tmp2,1); } sprintf(str,"%sQWK/GOODBYE",cfg.text_dir); if(fexistcase(str)) { sprintf(tmp2,"%sGOODBYE",cfg.temp_dir); mv(str,tmp2,1); } sprintf(str,"%sQWK/BLT-*",cfg.text_dir); glob(str,0,NULL,&g); for(i=0;i<(uint)g.gl_pathc;i++) { /* Copy BLT-*.* files */ fname=getfname(g.gl_pathv[i]); padfname(fname,str); if(isdigit(str[4]) && isdigit(str[9])) { sprintf(str,"%sQWK/%s",cfg.text_dir,fname); sprintf(tmp2,"%s%s",cfg.temp_dir,fname); mv(str,tmp2,1); } } globfree(&g); } if(prepack) { for(i=1;i<=cfg.sys_nodes;i++) { getnodedat(i,&node,0); if((node.status==NODE_INUSE || node.status==NODE_QUIET || node.status==NODE_LOGON) && node.useron==useron.number) break; } if(i<=cfg.sys_nodes) /* Don't pre-pack with user online */ return(false); } /*******************/ /* Compress Packet */ /*******************/ sprintf(tmp2,"%s%s",cfg.temp_dir,ALLFILES); i=external(cmdstr(temp_cmd(),packet,tmp2,NULL) ,ex|EX_WILDCARD); if(!fexist(packet)) { bputs(text[QWKCompressionFailed]); if(i) errormsg(WHERE,ERR_EXEC,cmdstr(temp_cmd(),packet,tmp2,NULL),i); else errorlog("Couldn't compress QWK packet"); return(false); } if(prepack) /* Early return if pre-packing */ return(true); l=flength(packet); sprintf(str,"%s.qwk",cfg.sys_id); bprintf(text[FiFilename],str); bprintf(text[FiFileSize],ultoac(l,tmp)); if(l>0L && cur_cps) i=l/(ulong)cur_cps; else i=0; bprintf(text[FiTransferTime],sectostr(i,tmp)); CRLF; if(!(useron.exempt&FLAG('T')) && i>timeleft) { bputs(text[NotEnoughTimeToDl]); return(false); } if(useron.rest&FLAG('Q')) { sprintf(str,"%s.qwk",cfg.sys_id); dir=opendir(cfg.temp_dir); while(dir!=NULL && (dirent=readdir(dir))!=NULL) { if(!stricmp(str,dirent->d_name)) /* QWK packet */ continue; sprintf(tmp,"%s%s",cfg.temp_dir,dirent->d_name); if(!isdir(tmp)) remove(tmp); } if(dir!=NULL) closedir(dir); } return(true); }