diff --git a/src/sbbs3/sbbs.h b/src/sbbs3/sbbs.h index 280781e0a339c9db680ce5c4c83f7f3eb4524278..3e0ec88d3ba24e84b55b260fe96d98bdeb9d0789 100644 --- a/src/sbbs3/sbbs.h +++ b/src/sbbs3/sbbs.h @@ -880,6 +880,7 @@ extern "C" { ,const char* fpath, const char* fspec, char* cmd); /* semfile.c */ + DLLEXPORT BOOL DLLCALL semfile_signal(const char* fname, const char* text); DLLEXPORT BOOL DLLCALL semfile_check(time_t* t, const char* fname); DLLEXPORT char* DLLCALL semfile_list_check(time_t* t, link_list_t* filelist); DLLEXPORT void DLLCALL semfile_list_init(link_list_t* filelist, const char* parent, diff --git a/src/sbbs3/semfile.c b/src/sbbs3/semfile.c index e041c4c8ba0172e72dca4d9a0d308fd115f4ef8c..6e68004fc48fd07961f1225d081cdbba5b121a3e 100644 --- a/src/sbbs3/semfile.c +++ b/src/sbbs3/semfile.c @@ -46,6 +46,9 @@ BOOL DLLCALL semfile_check(time_t* t, const char* fname) { time_t ft; + if(*t==0) /* uninitialized */ + *t=time(NULL); + if((ft=fdate(fname))==-1 || ft<=*t) return(FALSE); @@ -77,17 +80,17 @@ void DLLCALL semfile_list_init(link_list_t* filelist, const char* parent, char path[MAX_PATH+1]; char hostname[128]; - gethostname(hostname,sizeof(hostname)); - listInit(filelist,0); SAFEPRINTF2(path,"%s%s",parent,action); listPushNodeString(filelist,path); - SAFEPRINTF3(path,"%s%s.%s",parent,action,hostname); - listPushNodeString(filelist,path); SAFEPRINTF3(path,"%s%s.%s",parent,action,service); listPushNodeString(filelist,path); - SAFEPRINTF4(path,"%s%s.%s.%s",parent,action,hostname,service); - listPushNodeString(filelist,path); + if(gethostname(hostname,sizeof(hostname))==0) { + SAFEPRINTF3(path,"%s%s.%s",parent,action,hostname); + listPushNodeString(filelist,path); + SAFEPRINTF4(path,"%s%s.%s.%s",parent,action,hostname,service); + listPushNodeString(filelist,path); + } } void DLLCALL semfile_list_add(link_list_t* filelist, const char* path) @@ -99,3 +102,18 @@ void DLLCALL semfile_list_free(link_list_t* filelist) { listFree(filelist); } + +BOOL DLLCALL semfile_signal(const char* fname, const char* text) +{ + int file; + char hostname[128]; + + if((file=nopen(fname,O_CREAT|O_WRONLY))<0) + return(FALSE); + if(text==NULL && gethostname(hostname,sizeof(hostname))==0) + text=hostname; + if(text!=NULL) + write(file,text,strlen(text)); + close(file); + return(TRUE); +}