Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 4dffb615 authored by rswindell's avatar rswindell

Created C-exported version of cmdstr() - for use in ftpsrvr.c and postmsg.cpp.

parent b4f744e2
......@@ -1161,6 +1161,7 @@ int sockreadline(SOCKET socket, char* buf, int len, time_t* lastactive)
return(rd);
}
#if 0 /* now exported from in xtrn.cpp */
/*****************************************************************************/
/* Returns command line generated from instr with %c replacments */
/*****************************************************************************/
......@@ -1287,7 +1288,7 @@ static char* cmdstr(user_t* user, char *instr, char *fpath, char *fspec, char *c
return(cmd);
}
#endif
void DLLCALL ftp_terminate(void)
{
......@@ -1771,12 +1772,12 @@ static void receive_thread(void* arg)
sprintf(tmp,"%sFILE_ID.DIZ",scfg.temp_dir);
if(fexistcase(tmp))
remove(tmp);
system(cmdstr(xfer.user,scfg.fextr[i]->cmd,fname,"FILE_ID.DIZ",cmd));
system(cmdstr(&scfg,xfer.user,scfg.fextr[i]->cmd,fname,"FILE_ID.DIZ",cmd));
if(!fexistcase(tmp)) {
sprintf(tmp,"%sDESC.SDI",scfg.temp_dir);
if(fexistcase(tmp))
remove(tmp);
system(cmdstr(xfer.user,scfg.fextr[i]->cmd,fname,"DESC.SDI",cmd));
system(cmdstr(&scfg,xfer.user,scfg.fextr[i]->cmd,fname,"DESC.SDI",cmd));
fexistcase(tmp); /* fixes filename case */
}
if((file=nopen(tmp,O_RDONLY))!=-1) {
......
......@@ -443,7 +443,6 @@ public:
/* postmsg.cpp */
bool postmsg(uint subnum, smbmsg_t* msg, long wm_mode);
void signal_sub_sem(uint subnum);
/* mail.cpp */
int delmail(uint usernumber,int which);
......@@ -759,6 +758,7 @@ extern "C" {
DLLEXPORT void DLLCALL delfattach(scfg_t*, smbmsg_t*);
/* postmsg.cpp */
DLLEXPORT int DLLCALL savemsg(scfg_t* cfg, smb_t* smb, smbmsg_t* msg, char* msgbuf);
DLLEXPORT void DLLCALL signal_sub_sem(scfg_t* cfg, uint subnum);
/* filedat.c */
DLLEXPORT BOOL DLLCALL getfileixb(scfg_t* cfg, file_t* f);
......@@ -843,6 +843,10 @@ extern "C" {
DLLEXPORT int DLLCALL sockopt(char* str, int* level);
DLLEXPORT int DLLCALL set_socket_options(scfg_t* cfg, SOCKET sock, char* error);
/* xtrn.cpp */
DLLEXPORT char* DLLCALL cmdstr(scfg_t* cfg, user_t* user, const char* instr
,const char* fpath, const char* fspec, char* cmd);
#ifdef JAVASCRIPT
typedef struct {
......
......@@ -1583,3 +1583,163 @@ char* sbbs_t::cmdstr(char *instr, char *fpath, char *fspec, char *outstr)
return(cmd);
}
/****************************************************************************/
/* Returns command line generated from instr with %c replacments */
/* This is the C-exported version */
/****************************************************************************/
extern "C" char* cmdstr(scfg_t* cfg, user_t* user, const char* instr, const char* fpath
,const char* fspec, char* cmd)
{
char str[256];
int i,j,len;
len=strlen(instr);
for(i=j=0;i<len && j<MAX_PATH;i++) {
if(instr[i]=='%') {
i++;
cmd[j]=0;
char ch=instr[i];
if(isalpha(ch))
ch=toupper(ch);
switch(ch) {
case 'A': /* User alias */
if(user!=NULL)
strcat(cmd,user->alias);
break;
case 'B': /* Baud (DTE) Rate */
break;
case 'C': /* Connect Description */
break;
case 'D': /* Connect (DCE) Rate */
break;
case 'E': /* Estimated Rate */
break;
case 'F': /* File path */
strcat(cmd,fpath);
break;
case 'G': /* Temp directory */
strcat(cmd,cfg->temp_dir);
break;
case 'H': /* Port Handle or Hardware Flow Control */
break;
case 'I': /* UART IRQ Line */
strcat(cmd,ultoa(cfg->com_irq,str,10));
break;
case 'J':
strcat(cmd,cfg->data_dir);
break;
case 'K':
strcat(cmd,cfg->ctrl_dir);
break;
case 'L': /* Lines per message */
if(user!=NULL)
strcat(cmd,ultoa(cfg->level_linespermsg[user->level],str,10));
break;
case 'M': /* Minutes (credits) for user */
if(user!=NULL)
strcat(cmd,ultoa(user->min,str,10));
break;
case 'N': /* Node Directory (same as SBBSNODE environment var) */
strcat(cmd,cfg->node_dir);
break;
case 'O': /* SysOp */
strcat(cmd,cfg->sys_op);
break;
case 'P': /* COM Port */
break;
case 'Q': /* QWK ID */
strcat(cmd,cfg->sys_id);
break;
case 'R': /* Rows */
if(user!=NULL)
strcat(cmd,ultoa(user->rows,str,10));
break;
case 'S': /* File Spec */
strcat(cmd,fspec);
break;
case 'T': /* Time left in seconds */
break;
case 'U': /* UART I/O Address (in hex) */
strcat(cmd,ultoa(cfg->com_base,str,16));
break;
case 'V': /* Synchronet Version */
sprintf(str,"%s%c",VERSION,REVISION);
break;
case 'W': /* Time-slice API type (mswtype) */
#if 0 //ndef __FLAT__
strcat(cmd,ultoa(mswtyp,str,10));
#endif
break;
case 'X':
if(user!=NULL)
strcat(cmd,cfg->shell[user->shell]->code);
break;
case '&': /* Address of msr */
sprintf(str,"%lu",(DWORD)&fakeriobp);
strcat(cmd,str);
break;
case 'Y':
break;
case 'Z':
strcat(cmd,cfg->text_dir);
break;
case '~': /* DOS-compatible (8.3) filename */
#ifdef _WIN32
char sfpath[MAX_PATH+1];
SAFECOPY(sfpath,fpath);
GetShortPathName(fpath,sfpath,sizeof(sfpath));
strcat(cmd,sfpath);
#else
strcat(cmd,fpath);
#endif
break;
case '!': /* EXEC Directory */
strcat(cmd,cfg->exec_dir);
break;
case '#': /* Node number (same as SBBSNNUM environment var) */
sprintf(str,"%d",cfg->node_num);
strcat(cmd,str);
break;
case '*':
sprintf(str,"%03d",cfg->node_num);
strcat(cmd,str);
break;
case '$': /* Credits */
if(user!=NULL)
strcat(cmd,ultoa(user->cdt+user->freecdt,str,10));
break;
case '%': /* %% for percent sign */
strcat(cmd,"%");
break;
case '.': /* .exe for DOS/OS2/Win32, blank for Unix */
#ifndef __unix__
strcat(cmd,".exe");
#endif
break;
case '?': /* Platform */
#ifdef __OS2__
strcpy(str,"OS2");
#else
strcpy(str,PLATFORM_DESC);
#endif
strlwr(str);
strcat(cmd,str);
break;
default: /* unknown specification */
if(isdigit(instr[i]) && user!=NULL) {
sprintf(str,"%0*d",instr[i]&0xf,user->number);
strcat(cmd,str);
}
break;
}
j=strlen(cmd);
}
else
cmd[j++]=instr[i];
}
cmd[j]=0;
return(cmd);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment