summaryrefslogtreecommitdiff
path: root/systems/msdos/tx/src/txmain.c
diff options
context:
space:
mode:
Diffstat (limited to 'systems/msdos/tx/src/txmain.c')
-rw-r--r--systems/msdos/tx/src/txmain.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/systems/msdos/tx/src/txmain.c b/systems/msdos/tx/src/txmain.c
new file mode 100644
index 0000000000..53d53e29bc
--- /dev/null
+++ b/systems/msdos/tx/src/txmain.c
@@ -0,0 +1,72 @@
+#include "tx.h"
+#include <process.h>
+
+extern int ExpandAction(char *, char **, char *, int) ;
+extern void UserPrompt(char *, void *, int) ;
+extern int PrintTextMenu(int) ;
+extern void TxDir(void) ;
+
+
+void TxMain(void)
+{
+ int Choice,CurrentMenu = 0 ; /* Start at main menu */
+ char Action[MAX_ACTION] , /* Command to execute */
+ *Arguments[MAX_ARGS] , /* Pointers to arguments to command */
+ *pMenu ; /* Pointer to menu commands */
+
+ do {
+ Choice = PrintTextMenu(CurrentMenu) ;
+
+ if ( Choice == -1 ) { /* Default */
+ if (!CurrentMenu) /* if in main menu */
+ exit(0) ; /* exit program */
+ CurrentMenu = 0 ; /* otherwise, go back to main menu */
+ continue ;
+ }
+
+ pMenu = *(menu[CurrentMenu]+(2*Choice+1)) ; /* point to menu command */
+
+ if (*pMenu != SUBST_SIGN ) { /* User-defined action */
+ if ( ExpandAction(Action,Arguments,pMenu,(MAX_ACTION-14)) )
+ spawnvp(P_WAIT,Action,Arguments) ;
+ continue ;
+ }
+
+ ++pMenu ; /* Increment pointer if SUBST_SIGN in first position */
+
+ if ( !strnicmp(pMenu,SWITCH_MENUS,L_SWITCH_MENUS) ) { /* change menu */
+ CurrentMenu = atoi(pMenu+L_SWITCH_MENUS) ;
+ if ( ( CurrentMenu < 0) || (CurrentMenu > NumMenus) )
+ CurrentMenu = 0 ; /* switch to main menu if error */
+ }
+ else if ( !strnicmp(pMenu,DOS_COMMAND,L_DOS_COMMAND) ) { /* DOS command */
+ UserPrompt(MSG_DOSCOM,Action,80) ;
+ system(Action) ;
+ }
+ else if ( !strnicmp(pMenu,FIND_NAME,L_FIND_NAME) ) { /* select wf */
+ TxDir() ;
+ }
+ else if ( !strnicmp(pMenu,NEW_NAME,L_NEW_NAME) ) { /* enter new wfname */
+ int OldDrive=CurrDrive;
+ char OldPath[MAXPATH];
+ strcpy(OldPath,Path);
+ UserPrompt(MSG_NEW_FILE,Path,80) ;
+ SplitPath() ;
+ setdisk(CurrDrive) ;
+ if ( chdir(Path) ) {
+ CurrDrive=OldDrive;
+ setdisk(CurrDrive);
+ strcpy(Path,OldPath);
+ }
+ }
+ else if ( !strnicmp(pMenu,END_PROG,L_END_PROG) ) /* end program */
+ exit(0) ; /* Regular way of exiting the program */
+ else { /* Command name begins with a SUBST_SIGN sign (!) */
+ --pMenu ; /* reset pointer */
+ if ( ExpandAction(Action,Arguments,pMenu,(MAX_ACTION-14)) )
+ spawnvp(P_WAIT,Action,Arguments) ;
+ }
+ }
+ while (1) ;
+
+}