summaryrefslogtreecommitdiff
path: root/systems/msdos/tx/src/txcomm.c
diff options
context:
space:
mode:
Diffstat (limited to 'systems/msdos/tx/src/txcomm.c')
-rw-r--r--systems/msdos/tx/src/txcomm.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/systems/msdos/tx/src/txcomm.c b/systems/msdos/tx/src/txcomm.c
new file mode 100644
index 0000000000..f1806e3007
--- /dev/null
+++ b/systems/msdos/tx/src/txcomm.c
@@ -0,0 +1,45 @@
+#include "tx.h"
+
+extern int ExpandNames(char *, char *, int);
+
+int ExpandAction(char *action,char **argum,char *notexpand,int limit)
+{
+ int i ;
+ char provis[128] ;
+
+ if ( ! ExpandNames(provis,notexpand,limit) )
+ return 0; /* Exceeded limit */
+
+/* To overcome limits to the size of the environment, we must
+ execute the actions by a call to "command", with the /e
+ option set to a sufficiently high value */
+
+ strcpy(action,getenv("COMSPEC"));
+ strcat(action," /e:");
+ strcat(action,ch_env_size); /* size of the environment for child proc */
+ strcat(action," /c ");
+ strcat(action,provis);
+
+/* The command line is now held in string "action". We must
+ parse it to get the arguments. */
+
+ limit = MAX_ARGS ;
+ for ( i = 0 ; i < MAX_ARGS ; i++ )
+ argum[i] = '\0' ; /* initialize with 0's the pointers */
+
+ i = 0 ;
+ while ( *action ) {
+ for (; *action == ' ' ; action++ ) ; /* skip spaces */
+ if ( *action ) {
+ if ( !limit ) /* exceeded max number of args */
+ return 0;
+ limit-- ;
+ argum[i++]=action ; /* new argument */
+ /* What follows is a sleek way of putting a '\0' at the
+ end of the substrings */
+ for ( ; *action &&
+ ( *action != ' ' || (*action++ = '\0')) ; action++ ) ;
+ }
+ }
+ return i ; /* Return number of args on successful completion */
+}