command.c | command.c | |||
---|---|---|---|---|
skipping to change at line 18 | skipping to change at line 18 | |||
*------------------------------------------------------------------------- --- | *------------------------------------------------------------------------- --- | |||
* | * | |||
* | * | |||
* Private Routines and Data | * Private Routines and Data | |||
* | * | |||
* | * | |||
*------------------------------------------------------------------------- --- | *------------------------------------------------------------------------- --- | |||
*/ | */ | |||
/* this is the static xpa struct that holds the reserved commands */ | /* this is the static xpa struct that holds the reserved commands */ | |||
static XPA rxpa; | static XPA rxpa=NULL; | |||
/* | /* | |||
*------------------------------------------------------------------------- --- | *------------------------------------------------------------------------- --- | |||
* | * | |||
* Routine: XPACmdParseNames | * Routine: XPACmdParseNames | |||
* | * | |||
* Purpose: massage a name string, changing multiple sequential spaces | * Purpose: massage a name string, changing multiple sequential spaces | |||
* into a single space | * into a single space | |||
* | * | |||
* Returns: new name, with spaces massaged (also number of spacess) | * Returns: new name, with spaces massaged (also number of spacess) | |||
skipping to change at line 342 | skipping to change at line 342 | |||
if( !paramlist || !*paramlist ){ | if( !paramlist || !*paramlist ){ | |||
if( xpa->version != NULL ){ | if( xpa->version != NULL ){ | |||
snprintf(lbuf, SZ_LINE, "XPA version: %s\n", xpa->version); | snprintf(lbuf, SZ_LINE, "XPA version: %s\n", xpa->version); | |||
send(xpa_datafd(xpa), lbuf, strlen(lbuf), 0); | send(xpa_datafd(xpa), lbuf, strlen(lbuf), 0); | |||
} | } | |||
} | } | |||
if( xpa->commands == NULL ){ | if( xpa->commands == NULL ){ | |||
if( xpa->help != NULL ){ | if( xpa->help != NULL ){ | |||
slen = strlen(xpa->help)+SZ_LINE; | slen = strlen(xpa->help)+SZ_LINE; | |||
sbuf = xmalloc(slen); | sbuf = (char *)xmalloc(slen); | |||
snprintf(sbuf, slen, "%s\n", xpa->help); | snprintf(sbuf, slen, "%s\n", xpa->help); | |||
send(xpa_datafd(xpa), sbuf, strlen(sbuf), 0); | send(xpa_datafd(xpa), sbuf, strlen(sbuf), 0); | |||
xfree(sbuf); | xfree(sbuf); | |||
} | } | |||
else{ | else{ | |||
strcpy(lbuf, "\n"); | strcpy(lbuf, "\n"); | |||
send(xpa_datafd(xpa), lbuf, strlen(lbuf), 0); | send(xpa_datafd(xpa), lbuf, strlen(lbuf), 0); | |||
} | } | |||
} | } | |||
else{ | else{ | |||
if( paramlist && *paramlist ){ | if( paramlist && *paramlist ){ | |||
while( word(paramlist, tbuf, &lp) ){ | while( word(paramlist, tbuf, &lp) ){ | |||
for(cmd=xpa->commands; cmd!=NULL; cmd=cmd->next){ | for(cmd=xpa->commands; cmd!=NULL; cmd=cmd->next){ | |||
if( !strcmp(tbuf, cmd->name) ){ | if( !strcmp(tbuf, cmd->name) ){ | |||
if( cmd->help != NULL ){ | if( cmd->help != NULL ){ | |||
slen = strlen(cmd->name)+strlen(cmd->help)+SZ_LINE; | slen = strlen(cmd->name)+strlen(cmd->help)+SZ_LINE; | |||
sbuf = xmalloc(slen); | sbuf = (char *)xmalloc(slen); | |||
snprintf(sbuf, slen, "%s:\t%s\n", cmd->name, cmd->help); | snprintf(sbuf, slen, "%s:\t%s\n", cmd->name, cmd->help); | |||
send(xpa_datafd(xpa), sbuf, strlen(sbuf), 0); | send(xpa_datafd(xpa), sbuf, strlen(sbuf), 0); | |||
xfree(sbuf); | xfree(sbuf); | |||
} | } | |||
else{ | else{ | |||
snprintf(lbuf, SZ_LINE, "%s:\t(no help available)\n", cmd->nam e); | snprintf(lbuf, SZ_LINE, "%s:\t(no help available)\n", cmd->nam e); | |||
send(xpa_datafd(xpa), lbuf, strlen(lbuf), 0); | send(xpa_datafd(xpa), lbuf, strlen(lbuf), 0); | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
else{ | else{ | |||
for(cmd=xpa->commands; cmd!=NULL; cmd=cmd->next){ | for(cmd=xpa->commands; cmd!=NULL; cmd=cmd->next){ | |||
if( cmd->help != NULL ){ | if( cmd->help != NULL ){ | |||
slen = strlen(cmd->name)+strlen(cmd->help)+SZ_LINE; | slen = strlen(cmd->name)+strlen(cmd->help)+SZ_LINE; | |||
sbuf = xmalloc(slen); | sbuf = (char *)xmalloc(slen); | |||
snprintf(sbuf, slen, "%s:\t%s\n", cmd->name, cmd->help); | snprintf(sbuf, slen, "%s:\t%s\n", cmd->name, cmd->help); | |||
send(xpa_datafd(xpa), sbuf, strlen(sbuf), 0); | send(xpa_datafd(xpa), sbuf, strlen(sbuf), 0); | |||
xfree(sbuf); | xfree(sbuf); | |||
} | } | |||
else{ | else{ | |||
snprintf(lbuf, SZ_LINE, "%s:\t(no help available)\n", cmd->name); | snprintf(lbuf, SZ_LINE, "%s:\t(no help available)\n", cmd->name); | |||
send(xpa_datafd(xpa), lbuf, strlen(lbuf), 0); | send(xpa_datafd(xpa), lbuf, strlen(lbuf), 0); | |||
} | } | |||
} | } | |||
} | } | |||
skipping to change at line 456 | skipping to change at line 456 | |||
* | * | |||
*------------------------------------------------------------------------- --- | *------------------------------------------------------------------------- --- | |||
*/ | */ | |||
#ifdef ANSI_FUNC | #ifdef ANSI_FUNC | |||
void | void | |||
XPAInitReserved (void) | XPAInitReserved (void) | |||
#else | #else | |||
void XPAInitReserved() | void XPAInitReserved() | |||
#endif | #endif | |||
{ | { | |||
static int init=0; | if( !rxpa ){ | |||
if( !init ){ | ||||
if( (rxpa = (XPA)xcalloc(1, sizeof(struct xparec))) == NULL ) | if( (rxpa = (XPA)xcalloc(1, sizeof(struct xparec))) == NULL ) | |||
return; | return; | |||
/* XPACmdAdd requires that the callbacks be defined explicitly in rxpa | ||||
*/ | ||||
rxpa->send_callback = XPASendCommands; | ||||
rxpa->receive_callback = XPAReceiveCommands; | ||||
/* add reserved commands */ | ||||
XPACmdAdd(rxpa, "-acl", | XPACmdAdd(rxpa, "-acl", | |||
"\tget (set) the access control list\n\t\t options: host type acl ", | "\tget (set) the access control list\n\t\t options: host type acl ", | |||
XPASendAcl, NULL, NULL, XPAReceiveAcl, NULL, "fillbuf=false"); | XPASendAcl, NULL, NULL, XPAReceiveAcl, NULL, "fillbuf=false"); | |||
XPACmdAdd(rxpa, "-env", | XPACmdAdd(rxpa, "-env", | |||
"\tget (set) an environment variable\n\t\t options: name (value)" , | "\tget (set) an environment variable\n\t\t options: name (value)" , | |||
XPASendEnv, NULL, NULL, XPAReceiveEnv, NULL, NULL); | XPASendEnv, NULL, NULL, XPAReceiveEnv, NULL, NULL); | |||
XPACmdAdd(rxpa, "-exec", | XPACmdAdd(rxpa, "-exec", | |||
"\texecute commands from buffer\n\t\t options: none", | "\texecute commands from buffer\n\t\t options: none", | |||
NULL, NULL, NULL, XPAReceiveReserved, (void *)"exec", NULL); | NULL, NULL, NULL, XPAReceiveReserved, (void *)"exec", NULL); | |||
XPACmdAdd(rxpa, "-help", | XPACmdAdd(rxpa, "-help", | |||
skipping to change at line 493 | skipping to change at line 496 | |||
XPASendRemote, NULL, NULL, XPAReceiveRemote, NULL, "fillbuf=false" ); | XPASendRemote, NULL, NULL, XPAReceiveRemote, NULL, "fillbuf=false" ); | |||
XPACmdAdd(rxpa, "-clipboard", | XPACmdAdd(rxpa, "-clipboard", | |||
"\tset/get clipboard information \n\t\t options: [cmd] name", | "\tset/get clipboard information \n\t\t options: [cmd] name", | |||
XPASendClipboard, NULL, NULL, XPAReceiveClipboard, NULL, NULL); | XPASendClipboard, NULL, NULL, XPAReceiveClipboard, NULL, NULL); | |||
XPACmdAdd(rxpa, "-stimeout", | XPACmdAdd(rxpa, "-stimeout", | |||
"\tget (set) short timeout\n\t\t options: seconds|reset", | "\tget (set) short timeout\n\t\t options: seconds|reset", | |||
XPASendSTimeout, NULL, NULL, XPAReceiveSTimeout, NULL, NULL); | XPASendSTimeout, NULL, NULL, XPAReceiveSTimeout, NULL, NULL); | |||
XPACmdAdd(rxpa, "-version", | XPACmdAdd(rxpa, "-version", | |||
"\treturn XPA version string\n\t\t options: none", | "\treturn XPA version string\n\t\t options: none", | |||
XPASendVersion, NULL, NULL, NULL, NULL, NULL); | XPASendVersion, NULL, NULL, NULL, NULL, NULL); | |||
init++; | ||||
} | } | |||
} | } | |||
#ifdef ANSI_FUNC | ||||
void | ||||
XPAFreeReserved (void) | ||||
#else | ||||
void XPAFreeReserved() | ||||
#endif | ||||
{ | ||||
XPACmd cmd, tcmd; | ||||
if( !rxpa ) return; | ||||
/* free reserved commands */ | ||||
for(cmd=rxpa->commands; cmd!=NULL; ){ | ||||
tcmd = cmd->next; | ||||
XPACmdDel(rxpa, cmd); | ||||
cmd = tcmd; | ||||
} | ||||
xfree(rxpa); | ||||
rxpa = NULL; | ||||
} | ||||
/* | /* | |||
*------------------------------------------------------------------------- --- | *------------------------------------------------------------------------- --- | |||
* | * | |||
* Routine: XPACmdLookupReserved | * Routine: XPACmdLookupReserved | |||
* | * | |||
* Purpose: lookup a reserved command name | * Purpose: lookup a reserved command name | |||
* | * | |||
* Results: cmd struct or null | * Results: cmd struct or null | |||
* | * | |||
*------------------------------------------------------------------------- --- | *------------------------------------------------------------------------- --- | |||
skipping to change at line 967 | skipping to change at line 988 | |||
char *send_mode; | char *send_mode; | |||
ReceiveCb rec_callback; | ReceiveCb rec_callback; | |||
void *rec_data; | void *rec_data; | |||
char *rec_mode; | char *rec_mode; | |||
#endif | #endif | |||
{ | { | |||
XPACmd xnew; | XPACmd xnew; | |||
XPACmd cur; | XPACmd cur; | |||
XPACmd prev; | XPACmd prev; | |||
/* make sure we have a valid command record */ | ||||
if( !xpa || | ||||
(xpa->send_callback != XPASendCommands) || | ||||
(xpa->receive_callback != XPAReceiveCommands) ){ | ||||
return(NULL); | ||||
} | ||||
/* we need either a send or a receive or both */ | /* we need either a send or a receive or both */ | |||
if( (send_callback == NULL) && (rec_callback == NULL ) ){ | if( (send_callback == NULL) && (rec_callback == NULL ) ){ | |||
return(NULL); | return(NULL); | |||
} | } | |||
/* limit the size of the cmd name designation */ | /* limit the size of the cmd name designation */ | |||
if( strlen(name) > XPA_NAMELEN ){ | if( strlen(name) > XPA_NAMELEN ){ | |||
return(NULL); | return(NULL); | |||
} | } | |||
End of changes. 9 change blocks. | ||||
7 lines changed or deleted | 36 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |