home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
BEEHIVE
/
UTILITYS
/
XWP11SRC.ARC
/
XWPUSER.C
< prev
Wrap
Text File
|
1990-07-21
|
2KB
|
100 lines
/* XWPUSER.C
**
** User-defined menu for XWP
*/
#include "a:stdio.h"
#include "b:oxege.h"
char FLuser, *GLuser;
int GLusnums;
extern char FLerror;
/* USER -- User-defined menu
**
** FLuser = status of user menu initialization:
** 0 = not initialized
** 1 = initialized and ok
** 127 = attempt to initialize failed
**
** GLuser data structure:
** 10 possible fields of:
** 10 bytes identifier string
** 15 bytes command string
** GLusnums = number of program options found by userinit()
*/
user()
{
int counter, choice;
char *pointer;
/* First check FLuser status and initialize if necessary */
if( FLuser == NULL )
{
userinit();
}
if( FLuser == 127 )
{
error( "XWP.USR NOT FOUND" );
FLerror = 0;
return;
}
/* Now set up menu areas */
pointer = GLuser;
counter = 0;
while( counter < GLusnums )
{
strcpy( scratch, " " );
strcat( scratch, pointer );
setmenu( counter+1, 12, scratch );
pointer += 25;
++counter;
}
setmenu( counter+1, 12, " RETURN " );
/* Save the environment */
savewindow( 1, 50, 4+GLusnums, 62, 0, 1 );
/* get menu choice */
choice = menu( 1, 50, 1, GLusnums+1, 12, 1 );
/* restore environment */
savewindow( 1, 50, 4+GLusnums, 62, 1, 1);
/* execute the choice */
if( choice <= GLusnums )
{
pointer = GLuser-15+( choice * 25 );
check( pointer );
if ( !FLerror )
{
strcpy( scratch, pointer );
strcat( scratch, "!xwp" );
execl( scratch );
}
}
FLerror = 0;
}
userinit()
{
int udatfile, counter;
char *pointer;
if( ( udatfile = fopen( "XWP.USR", "r" ) ) == NULL )
{
FLuser = 127;
return;
}
FLuser = 1;
pointer = GLuser = malloc( 500 );
counter = 0;
while( !feof( udatfile ) )
{
fgets( pointer, 11, udatfile );
fgets( pointer+10, 16, udatfile );
xcr( pointer );
xcr( pointer+10 );
pointer += 25;
++counter;
}
GLusnums = counter-1; /* subtract the last (null) line */
}
xcr( pointer+10 );
pointer +