void AddDupeBuf(char *buf,uint16_t size) { uint32_t offset; uint32_t crc32,*crc32p; osSeek(dupefh,0,OFFSET_END); offset=osFTell(dupefh); crc32p=(uint32_t *)buf; crc32=*crc32p; if(!osWrite(dupefh,&size,sizeof(uint16_t))) { uint32_t err=osError(); LogWrite(1,SYSTEMERR,"Failed to write to dupe file"); LogWrite(1,SYSTEMERR,"Error: %s",osErrorMsg(err)); return; } if(!osWrite(dupefh,buf,size)) { uint32_t err=osError(); LogWrite(1,SYSTEMERR,"Failed to write to dupe file"); LogWrite(1,SYSTEMERR,"Error: %s",osErrorMsg(err)); return; } adddupeindex(offset,crc32); dupechanged=TRUE; }
void copydupe(uint16_t c,osFile oldfh,osFile newfh) { char buf[300]; uint16_t size; osSeek(oldfh,dupebuf[c].offset,OFFSET_BEGINNING); if(osRead(oldfh,&size,sizeof(uint16_t))!=sizeof(uint16_t)) return; if(osRead(oldfh,buf,size) != size) return; if(!osWrite(newfh,&size,sizeof(uint16_t))) { uint32_t err=osError(); LogWrite(1,SYSTEMERR,"Failed to write to temporary dupe file"); LogWrite(1,SYSTEMERR,"Error: %s",osErrorMsg(err)); return; } if(!osWrite(newfh,buf,size)) { uint32_t err=osError(); LogWrite(1,SYSTEMERR,"Failed to write to temporary dupe file"); LogWrite(1,SYSTEMERR,"Error: %s",osErrorMsg(err)); return; } }
long cmdRemoveCommand(CommandRepository *repository, CommandInfo *cmd) { /* Validate our arguments. */ if (! repository) return eSRV_INSUFF_ARGUMENTS; if (! cmd) return eSRV_INSUFF_ARGUMENTS; /* Make sure the command isn't read-only. */ if (cmd->readonly) return ePERMISSION_DENIED; /* Remove this command from the command list. */ cmd_KeyedListRemove(repository->commands, cmd); /* Remove the command definition file. */ if (remove(cmd->pathname) != 0) { cmd_Error("remove: %s", osError( )); cmd_Error("Could not remove command definition file \"%s\"", cmd->pathname); return osErrno( ); } /* Free memory associated with this command. */ cmdFreeCommand(cmd); return eOK; }
long cmdRemoveTrigger(CommandRepository *repository, TriggerInfo *trg) { /* Validate our arguments. */ if (! repository) return eSRV_INSUFF_ARGUMENTS; if (! trg) return eSRV_INSUFF_ARGUMENTS; /* Make sure the trigger isn't read-only. */ if (trg->readonly) return ePERMISSION_DENIED; /* Remove this trigger from the trigger list. */ cmd_KeyedListRemove(repository->triggers, trg); /* Remove the trigger definition file. */ if (remove(trg->pathname) != 0) { cmd_Error("remove: %s", osError( )); cmd_Error("Could not remove trigger definition file \"%s\"", trg->pathname); return osErrno( ); } /* Free memory associated with this trigger. */ cmdFreeTrigger(trg); return eOK; }
void CloseDupeDB(void) { osFile newfh; uint32_t c; char duptemp[200]; if(!dupechanged) { osClose(dupefh); return; } strcpy(duptemp,config.cfg_DupeFile); strcat(duptemp,".tmp"); if(!(newfh=osOpen(duptemp,MODE_NEWFILE))) { uint32_t err=osError(); LogWrite(1,SYSTEMERR,"Failed to open temporary dupe file %s for writing",duptemp); LogWrite(1,SYSTEMERR,"Error: %s",osErrorMsg(err)); osFree(dupebuf); osClose(dupefh); return; } osWrite(newfh,DUPES_IDENTIFIER,4); for(c=dupeentrynum;c<dupeentrymax;c++) copydupe(c,dupefh,newfh); for(c=0;c<dupeentrynum;c++) copydupe(c,dupefh,newfh); osClose(dupefh); osClose(newfh); osFree(dupebuf); dupechanged=FALSE; osDelete(config.cfg_DupeFile); osRename(duptemp,config.cfg_DupeFile); return; }
void *tmain(void *arg) { mccClientInfo *client; long status; int threadno = (int)arg; printf("T%03d: Connecting\n", threadno); client = mccInit("localhost", 9900, NULL); if (!client) { printf("T%03d error connecting %s\n", threadno, osError()); return NULL; } printf("T%03d: Executing\n", threadno); status = mccExecStr(client, TEST_CMD, NULL); if (status != eOK) { printf("T%03d error status %d -- exiting\n", threadno, status); return NULL; } printf("T%03d: Sleeping\n", threadno); osSleep(2, 0); printf("T%03d: Begin\n", threadno); while (1) { status = mccExecStr(client, TEST_CMD, NULL); if (status != eOK) { printf("T%03d error status %d -- exiting\n", threadno, status); return NULL; } osSleep(0, 100); } }
int main(int argc, char **argv) { OS_THREAD threads[100]; void *result; int i; int max; max = atoi(argv[1]); if (max > 100 || max < 1) max = 100; for (i = 0; i < max; i++) { long status = osCreateThread(&threads[i], tmain, (void *)i); if (status != eOK) { printf("Error Starting Thread: %s", osError()); } osSleep(1, 0); } osSleep(3600 * 24 * 365, 0); }
int main(int argc, char **argv) { char *var; struct fileentry *fe; if(!osInit()) exit(OS_EXIT_ERROR); if(argc > 1 && (strcmp(argv[1],"?")==0 || strcmp(argv[1],"-h")==0 || strcmp(argv[1],"--help")==0 || strcmp(argv[1],"help")==0 || strcmp(argv[1],"/h")==0 || strcmp(argv[1],"/?")==0 )) { printargs(args); osEnd(); exit(OS_EXIT_OK); } if(!parseargs(args,argc,argv)) { osEnd(); exit(OS_EXIT_ERROR); } jbNewList(&list); /* get outbound dir */ if((var=getenv("CMOUTBOUND"))) cfg_Dir=var; else cfg_Dir=OS_CURRENT_DIR; if(args[ARG_DIRECTORY].data) cfg_Dir=(char *)args[ARG_DIRECTORY].data; /* Get zone */ if((var=getenv("CMOUTBOUNDZONE"))) cfg_Zone=atoi(var); else cfg_Zone=2; if(args[ARG_ZONE].data) cfg_Zone=atoi((char *)args[ARG_ZONE].data); /* Get pattern */ strcpy(cfg_Pattern.Zone,"*"); strcpy(cfg_Pattern.Net,"*"); strcpy(cfg_Pattern.Node,"*"); strcpy(cfg_Pattern.Point,"*"); if(args[ARG_PATTERN].data) { if(!Parse4DPat((char *)args[ARG_PATTERN].data,&cfg_Pattern)) { printf("Invalid node pattern \"%s\"\n",(char *)args[ARG_PATTERN].data); osEnd(); exit(OS_EXIT_ERROR); } } /* Get verbose flag */ cfg_Verbose=FALSE; if(args[ARG_VERBOSE].data) cfg_Verbose=TRUE; /* Real program starts here */ printf("CrashListOut " VERSION "\n\n"); scandir_dir = NULL; scandir_boss = NULL; if(!osScanDir(cfg_Dir,scandirfunc)) { uint32_t err=osError(); printf("Failed to scan directory %s\n",cfg_Dir); printf("Error: %s",osErrorMsg(err)); return(FALSE); } sortlist(&list); printf("%-8.8s %-17.17s %-16.16s %7.7s %s\n\n", "Type","Node","Last Change","B/F","File"); if(list.First) { for(fe=(struct fileentry *)list.First;fe;fe=fe->Next) { if(fe->type == TYPE_REQUEST) DisplayReq(fe); else if(fe->flow) DisplayFlow(fe); else DisplayPkt(fe); } if(!cfg_Verbose) printf("\n"); printf("Totally %s bytes in %u files to send, %u requests.\n",unit(TotalBytes),TotalFiles,TotalRequests); } else { printf("Outbound directory is empty.\n"); } jbFreeList(&list); exit(OS_EXIT_OK); }
int main(int argc, char **argv) { osFile fh; uint32_t total,areas,totaldupes; time_t firsttime,t; uint32_t DayStatsWritten; char buf[200],date[30],date2[30]; struct DiskAreaStats dastat; struct DiskNodeStats dnstat; struct StatsNode *sn; struct NodeStatsNode *nsn; struct jbList StatsList; struct jbList NodesList; uint32_t c,num,tot; uint16_t total8days[8]; char sortmode; struct tm *tp; char *monthnames[]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","???"}; signal(SIGINT,breakfunc); if(!osInit()) exit(OS_EXIT_ERROR); if(argc > 1 && (strcmp(argv[1],"?")==0 || strcmp(argv[1],"-h")==0 || strcmp(argv[1],"--help")==0 || strcmp(argv[1],"help")==0 || strcmp(argv[1],"/h")==0 || strcmp(argv[1],"/?")==0 )) { printargs(args); osEnd(); exit(OS_EXIT_OK); } if(!parseargs(args,argc,argv)) { osEnd(); exit(OS_EXIT_ERROR); } sortmode='a'; if(args[ARG_SORT].data) sortmode=tolower(((char *)args[ARG_SORT].data)[0]); if(!strchr("amtdlu",sortmode)) { printf("Unknown sort mode %c\n",sortmode); osEnd(); exit(OS_EXIT_ERROR); } if(args[ARG_NOAREAS].data && args[ARG_NONODES].data) { printf("Nothing to do\n"); osEnd(); exit(OS_EXIT_ERROR); } printf("CrashStats "VERSION" © " COPYRIGHT " Johan Billing\n"); if(!(fh=osOpen(args[ARG_FILE].data,MODE_OLDFILE))) { uint32_t err=osError(); printf("Error opening %s\n",(char *)args[ARG_FILE].data); printf("Error: %s\n",osErrorMsg(err)); osEnd(); exit(OS_EXIT_ERROR); } osRead(fh,buf,4); buf[4]=0; if(strcmp(buf,STATS_IDENTIFIER)!=0) { printf("Unknown format of stats file\n"); osClose(fh); osEnd(); exit(OS_EXIT_ERROR); } osRead(fh,&DayStatsWritten,sizeof(uint32_t)); total=0; totaldupes=0; firsttime=0; areas=0; for(c=0;c<8;c++) total8days[c]=0; jbNewList(&StatsList); jbNewList(&NodesList); osRead(fh,&num,sizeof(uint32_t)); c=0; if(!args[ARG_NOAREAS].data) { while(c<num && osRead(fh,&dastat,sizeof(struct DiskAreaStats))==sizeof(struct DiskAreaStats)) { if(!args[ARG_GROUP].data || CheckFlags(dastat.Group,args[ARG_GROUP].data)) { if(!(sn=osAlloc(sizeof(struct StatsNode)))) { printf("Out of memory\n"); jbFreeList(&StatsList); osClose(fh); osEnd(); exit(OS_EXIT_ERROR); } jbAddNode(&StatsList,(struct jbNode *)sn); strcpy(sn->Tagname,dastat.Tagname); sn->Dupes=dastat.Dupes; sn->Total=dastat.TotalTexts; sn->FirstTime=dastat.FirstTime; sn->LastTime=dastat.LastTime; memcpy(&sn->Last8Days[0],&dastat.Last8Days[0],8*sizeof(uint16_t)); sn->Average=CalculateAverage(&dastat.Last8Days[0],dastat.TotalTexts,DayStatsWritten,sn->FirstTime / (24*60*60)); } if(dastat.FirstTime!=0) if(firsttime==0 || firsttime > dastat.FirstTime) firsttime=dastat.FirstTime; c++; } } else { while(c<num && osRead(fh,&dastat,sizeof(struct DiskAreaStats))==sizeof(struct DiskAreaStats)) c++; } osRead(fh,&num,sizeof(uint32_t)); c=0; if(!args[ARG_NONODES].data) { while(c<num && osRead(fh,&dnstat,sizeof(struct DiskNodeStats))==sizeof(struct DiskNodeStats)) { if(!(nsn=osAlloc(sizeof(struct NodeStatsNode)))) { printf("Out of memory\n"); jbFreeList(&NodesList); jbFreeList(&StatsList); osClose(fh); osEnd(); exit(OS_EXIT_ERROR); } jbAddNode(&NodesList,(struct jbNode *)nsn); Copy4D(&nsn->Node,&dnstat.Node); nsn->GotNetmails=dnstat.GotNetmails; nsn->GotNetmailBytes=dnstat.GotNetmailBytes; nsn->SentNetmails=dnstat.SentNetmails; nsn->SentNetmailBytes=dnstat.SentNetmailBytes; nsn->GotEchomails=dnstat.GotEchomails; nsn->GotEchomailBytes=dnstat.GotEchomailBytes; nsn->SentEchomails=dnstat.SentEchomails; nsn->SentEchomailBytes=dnstat.SentEchomailBytes; nsn->Dupes=dnstat.Dupes; nsn->Days=DayStatsWritten-dnstat.FirstTime % (24*60*60); if(nsn->Days==0) nsn->Days=1; nsn->FirstTime=dnstat.FirstTime; if(dnstat.FirstTime!=0) if(firsttime==0 || firsttime > dnstat.FirstTime) firsttime=dnstat.FirstTime; c++; } } else { while(c<num && osRead(fh,&dnstat,sizeof(struct DiskNodeStats))==sizeof(struct DiskNodeStats)) c++; } osClose(fh); t=(time_t)DayStatsWritten * 24*60*60; tp=localtime(&firsttime); sprintf(date,"%02d-%s-%02d",tp->tm_mday,monthnames[tp->tm_mon],tp->tm_year%100); tp=localtime(&t); sprintf(date2,"%02d-%s-%02d",tp->tm_mday,monthnames[tp->tm_mon],tp->tm_year%100); printf("\nStatistics from %s to %s\n",date,date2); if(!ctrlc && !args[ARG_NOAREAS].data) { Sort(&StatsList,'a'); Sort(&StatsList,sortmode); printf("\n"); if(args[ARG_LAST7].data) { printf("Area "); for(c=1;c<8;c++) { t=(DayStatsWritten-c)*24*60*60; tp=localtime(&t); printf(" %02d",tp->tm_mday); } printf(" Total\n============================================================================\n"); if(!ctrlc) { for(sn=(struct StatsNode *)StatsList.First;sn && !ctrlc;sn=sn->Next) { tot=0; for(c=1;c<8;c++) tot+=sn->Last8Days[c]; printf("%-33.33s %4d %4d %4d %4d %4d %4d %4d : %5d\n", sn->Tagname, sn->Last8Days[1], sn->Last8Days[2], sn->Last8Days[3], sn->Last8Days[4], sn->Last8Days[5], sn->Last8Days[6], sn->Last8Days[7], tot); for(c=1;c<8;c++) total8days[c]+=sn->Last8Days[c]; areas++; } if(!ctrlc) { tot=0; for(c=1;c<8;c++) tot+=total8days[c]; printf("=============================================================================\n"); sprintf(buf,"Totally in all %u areas",areas); printf("%-33.33s %4d %4d %4d %4d %4d %4d %4d : %5d\n", buf, total8days[1], total8days[2], total8days[3], total8days[4], total8days[5], total8days[6], total8days[7], tot); } } } else { printf("Area First Last Msgs Msgs/day Dupes\n"); printf("============================================================================\n"); if(!ctrlc) { for(sn=(struct StatsNode *)StatsList.First;sn && !ctrlc;sn=sn->Next) { if(sn->LastTime==0) { strcpy(date2,"<Never>"); } else { tp=localtime(&sn->LastTime); sprintf(date2,"%02d-%s-%02d",tp->tm_mday,monthnames[tp->tm_mon],tp->tm_year%100); } if(sn->FirstTime==0) { strcpy(date,"<Never>"); } else { tp=localtime(&sn->FirstTime); sprintf(date,"%02d-%s-%02d",tp->tm_mday,monthnames[tp->tm_mon],tp->tm_year%100); } for(c=0;c<8;c++) total8days[c]+=sn->Last8Days[c]; total+=sn->Total; totaldupes+=sn->Dupes; areas++; printf("%-29.30s %-9.9s %-9.9s %7d %7d %7d\n",sn->Tagname,date,date2,sn->Total,sn->Average,sn->Dupes); } } if(!ctrlc) { printf("============================================================================\n"); sprintf(buf,"Totally in all %u areas",areas); printf("%-42s %7d %7d %7d\n", buf, total, CalculateAverage(&total8days[0],total,DayStatsWritten,firsttime / (24*60*60)), totaldupes); } } } if(!ctrlc && !args[ARG_NONODES].data) { SortNodes(&NodesList); printf("\n"); printf("Nodes statistics\n"); printf("================\n"); for(nsn=(struct NodeStatsNode *)NodesList.First;nsn && !ctrlc;nsn=nsn->Next) { if(nsn->FirstTime==0) { strcpy(date,"<Never>"); } else { tp=localtime(&nsn->FirstTime); sprintf(date,"%0d-%s-%0d",tp->tm_mday,monthnames[tp->tm_mon],tp->tm_year%100); } sprintf(buf,"%u:%u/%u.%u",nsn->Node.Zone,nsn->Node.Net,nsn->Node.Node,nsn->Node.Point); printf("%-30.40s Statistics since: %s\n\n",buf,date); printf(" Sent netmails: %u/%s\n",nsn->SentNetmails,unit(nsn->SentNetmailBytes)); printf(" Received netmails: %u/%s\n",nsn->GotNetmails,unit(nsn->GotNetmailBytes)); printf(" Sent echomails: %u/%s\n",nsn->SentEchomails,unit(nsn->SentEchomailBytes)); printf(" Received echomails: %u/%s\n",nsn->GotEchomails,unit(nsn->GotEchomailBytes)); printf(" Dupes: %u\n",nsn->Dupes); printf("\n"); } } if(ctrlc) { printf("*** Break\n"); } else { printf("\n"); } jbFreeList(&StatsList); jbFreeList(&NodesList); osEnd(); exit(OS_EXIT_OK); }
bool OpenDupeDB(void) { char buf[300]; uint32_t offset,crc32,*crc32p; uint16_t size,res; if(!(dupebuf=osAlloc(config.cfg_DupeSize*sizeof(struct dupeentry)))) { LogWrite(1,SYSTEMERR,"Not enough memory for dupe-check buffer\n"); return(FALSE); } dupeentrynum=0; dupeentrymax=0; dupechanged=FALSE; if(!(dupefh=osOpen(config.cfg_DupeFile,MODE_READWRITE))) { uint32_t err=osError(); LogWrite(1,SYSTEMERR,"Failed to open dupe file %s in read/write mode",config.cfg_DupeFile); LogWrite(1,SYSTEMERR,"Error: %s",osErrorMsg(err)); return(FALSE); } res=osRead(dupefh,buf,4); buf[4]=0; if(res == 0) { /* New file */ LogWrite(3,TOSSINGINFO,"Creating new dupe file %s",config.cfg_DupeFile); strcpy(buf,DUPES_IDENTIFIER); osWrite(dupefh,buf,4); } else if(res != 4 || strcmp(buf,DUPES_IDENTIFIER)!=0) { LogWrite(1,SYSTEMERR,"Invalid format of dupe file %s, exiting...",config.cfg_DupeFile); osClose(dupefh); return(FALSE); } offset=4; while(osRead(dupefh,&size,sizeof(uint16_t))==sizeof(uint16_t)) { if(size == 0 || size > 300) /* Unreasonably big */ { LogWrite(1,SYSTEMERR,"Error in dupe file %s, exiting...",config.cfg_DupeFile); osClose(dupefh); return(FALSE); } if(osRead(dupefh,buf,(uint32_t)size) != size) { LogWrite(1,SYSTEMERR,"Error in dupe file %s, exiting...",config.cfg_DupeFile); osClose(dupefh); return(FALSE); } crc32p=(uint32_t *)buf; crc32=*crc32p; adddupeindex(offset,crc32); offset += size+2; } dupechanged=FALSE; return(TRUE); }
void * listdir(struct OBJ *objCalled,EN_MESSAGE cmd,LONG info,CHAR *str) { #define MAX_X 50 #define MAX_Y 30 static struct WINSCR buf[MAX_Y]; static struct WS_INFO ws; struct WS_DISPEXT *DExt; // static TCHAR *PathNow=NULL; LONG a; LONG pt; CHAR *FlagFine; static SINT scrhdl=-1; // FFBLK file; SINT fine=0; static CHAR *p,*pmem=NULL; CHAR *ptr; //CHAR bb[80]; CHAR serv[MAXPATH]; CHAR icotype[12]; // CHAR Bsys.szMouseCursorName[NOMEICONE_SIZE+1]; // Icone corrente del mouse // SINT BMS_ax,BMS_ay; //------------------------------------------------- if (cmd==WS_INF) return &ws; switch (cmd) { case WS_BUF : // Richiesta buffer if (scrhdl==-1) break; for (a=0;a<ws.numcam;a++) { pt=a+ws.offset; if (pt>=ws.maxcam) break; buf[(SINT) a].keypt=pmem+((SINT) pt*MAX_X); } break; case WS_DISPLAY : // Richiesta buffer DExt=(struct WS_DISPEXT *) str; //boxp(DExt->px,DExt->py,DExt->px+5,DExt->py+5,14,SET); ptr=pmem+((SINT) info*MAX_X); if (!strcmp(ptr,"..")) strcpy(icotype,"path1"); else { if (ws.selez==info) strcpy(icotype,"path2"); else strcpy(icotype,"path3"); } ico_disp(DExt->px+1,DExt->py,icotype); dispfm_h(DExt->px+20,DExt->py,DExt->col1,DExt->col2,DExt->hdl,ptr); break; case WS_OFF : // Settaggio offset //ws.koffset=ws.offset; ws.offset=info; break; case WS_KEYPRESS : if (key_press(9)||key_press2(_FDX)) strcpy(str,"ESC:->"); if (key_press2(15)||key_press2(_FSX)) strcpy(str,"ESC:<-"); // if (key_press(9)) strcpy(str,"ESC:->"); // if (key_press2(15)) strcpy(str,"ESC:<-"); if (key_press(' ')) strcpy(str,"CR:SPC"); break; case WS_FINDKEY : case WS_FIND : // Ricerca la Chiave selezionata if (scrhdl==-1) break; strupr(str); a=ws.selez+1; if (memcmp(str,pmem+((SINT) a*MAX_X),strlen(str))==0) {listdir(NULL,WS_OFF,a,""); if (ws.offset>(ws.maxcam-ws.numcam)) ws.offset=(ws.maxcam-ws.numcam); if (ws.offset<0) ws.offset=0; listdir(NULL,WS_SEL,a,""); break;} { for(a=0;a<ws.maxcam;a++) { if (memcmp(str,pmem+((SINT) a*MAX_X),strlen(str))<=0) {listdir(NULL,WS_OFF,a,""); if (ws.offset>(ws.maxcam-ws.numcam)) {ws.offset=(ws.maxcam-ws.numcam);} if (ws.offset<0) ws.offset=0; listdir(NULL,WS_SEL,a,""); break;} } } break; case WS_SEL : // Settaggio selez ws.selez=info; break; case WS_PTREC : // Restituisce pt alla chiave selezionata buf[0].record=ws.selez; buf[0].keypt=pmem+((SINT) ws.selez*MAX_X); break; case WS_REFON : // Richiesta di refresh schermo ws.refre=ON; break; case WS_REFOFF : // Schermo rifreshato ws.refre=OFF; break; case WS_OPEN : // PREPARA I DATI if ((info<4)||(info>MAX_Y)) { ehExit("Errore di assegnazione campi in listfile"); } ws.sizecam=MAX_X; ws.numcam=info;// Assegna il numero di campi da visualizzare case WS_LOAD : if (scrhdl>-1) memoFree(scrhdl,"Cr4");// Libera la memoria scrhdl=-1; ws.maxcam=0; ws.offset=0; ws.selez=-1; ws.koffset=-1; ws.kselez=-1; ws.dispext=ON; ws.refre=ON; if (!*szFolder) break; // Conta i file *serv=0; //if (*str) strcpy(serv,str); strcpy(serv,szFolder); AddBs(serv); strcat(serv,"*."); strcat(serv,"*"); //strcat(serv,extcur); // Cambia il mouse // strcpy(Bsys.szMouseCursorName,sys.szMouseCursorName); // BMS_ax=MS_ax; BMS_ay=MS_ay; mouse_graph(0,0,"CLEX"); printf("Da fare"); /* fine=f_findFirst(serv,&file,FA_DIREC); while (!fine) {if (file.ff_attrib!=FA_DIREC) goto av2; if (strcmp(file.ff_name,".")) ws.maxcam++; av2: fine=f_findNext(&file); } f_findClose(&file); */ // Non ci sono pi— files //printf("listdir: %x - %x\n\r",fine,DE_coden); // if ((fine)&&(DE_coden==0x12)) {fine=0;} //printf("Fine %d",fine); if (fine) goto FINEC; if (ws.maxcam==0) goto FINEC;// No file scrhdl=memoAlloc(M_HEAP,(LONG) ws.maxcam*MAX_X,"listdir()"); if (scrhdl<0) ehExit("Memoria insufficiente in listdir"); pmem=(CHAR *) memoPtr(scrhdl,NULL); // Copia i nomi dei file in memoria /* fine=f_findFirst(serv,&file,FA_DIREC); if (fine) {goto FINEC;} p=pmem; a=0; while (!fine) { if (file.ff_attrib!=FA_DIREC) goto avanti; if (!strcmp(file.ff_name,".")) goto avanti; if (a>ws.maxcam) ehExit("Errore in listdir"); strcpy(p,file.ff_name); *p=(BYTE) toupper((SINT) *p); p+=MAX_X; avanti: fine=f_findNext(&file); } f_findClose(&file); */ // if ((fine)&&(DE_coden==0x12)) {fine=0;} if (fine) goto FINEC; // ORDINA I FILE IN MODO ALFABETICO sort(pmem,(SINT) ws.maxcam,MAX_X); FINEC: // mouse_graph(BMS_ax,BMS_ay,Bsys.szMouseCursorName); MouseCursorDefault(); if (fine) {osError(FALSE,GetLastError(),"listdir()");FlagFine=NULL;} else FlagFine=serv; return FlagFine; // Ritorna Null se qualcosa Š andato sorto //break; case WS_CHANGE : // Legge la directory prescelta //sc=listdir(LEGGI,info); //strcpy(serv,&sc->key[1]); // Toglie le parentesi quadre strcpy(serv,str); //Adispm(0,0,15,1,ON,SET,serv); //for (a=strlen(serv);(serv[a]!=' ');a--); //serv[a]=0; // Gestisce il torna indietro if (!strcmp(serv,"..")) {//efx2(); for (a=strlen(szFolder)-2;(szFolder[(SINT) a]!='\\');a--); szFolder[(SINT) (a+1)]=0; //if (pathcur[a-1]==':') strcat(pathcur,"\\"); } else {if (szFolder[strlen(szFolder)-1]!='\\') strcat(szFolder,"\\"); strcat(szFolder,serv); strcat(szFolder,"\\");} //chdir(pathcur); // listdir(WS_LOAD,0,""); // e le subdirectory //sprintf(serv,"path=%s",pathcur); //Adispm(0,30,15,1,ON,SET,serv); break; case WS_CLOSE : // LIBERA LA MEMORIA if (scrhdl>-1) memoFree(scrhdl,"Cr5");// Libera la memoria scrhdl=-1; break; case WS_REALSET : strcpy(szFolder,str); break; //default : //efx1();efx1(); } return &buf; #undef MAX_X #undef MAX_Y }