#if !defined( tmBundle_EXISTS ) #include "tmcilib.h" static struct TMBundle tmBundle = {"eviadm.pc",NULL,NULL,NULL,NULL}; #define tmBundle_EXISTS #endif /****************************************************************************** eviadm.pc Database Administration Package for FormFusion Suite (C) Copyright 1999-2000 Evisions, Inc. All rights reserved. ****************************************************************************** AUDIT TRAIL: 0.9 Betsy Oswald Created administrator package and most routines. 1.0 Clayton M. Arends Updated routines, removed SCT references and modified file compiling. Added EVIPROGRAM_COMPILE flag. Changed hexadecimal escape sequence references to octal (Digital UNIX fix). 1.0.1 Clayton M. Arends Slight changes for visuals on WinNT. Added flag to leave source files in filesystem. Added ability to run scripts. Added frename() to support renaming across platforms. Fixed the WinNT compile script. 1.0.2 Clayton M. Arends Changed NT compile script. Also changed execution scripts for NT. Prompting for import command now instead of assuming 'imp' 1.0.3 Clayton M. Arends Added HIDE_STR and stty() to turn on/off the displaying of characters. Converted create_file back to original filemode for VMS systems. "w" rather than "wb, rat=" etc 1.2.0 Clayton M. Arends Removed all user management functions since the Windows GUI tool is now used for these purposes. Left only importing of tables and compiling of software. 1.3.2 Clayton M. Arends Added SQLCHECK=LIMITED for VMS and UNIX compiles. 1.3.3 Clayton M. Arends Small prompt changes. 1.3.4 Clayton M. Arends Version change to keep with evilp version 1.5.0 Clayton M. Arends The new evilp doesn't include any SCT objects or header files and must therefore compile in the secret seeds. Added a series of options to allow the user a variety of options of how to assist evilp in determining the seed values. 1.6.0 Clayton M. Arends Seperated compile and execute scripts to allow user to choose seperately. 1.6.1 Clayton M. Arends Fixed Win NT bug in ExecuteFile() 1.9.4 Mike Nowakowski Changed getline() to evi_getline() to correct problems with custom libraries being used. ******************************************************************************/ #include #include #undef true #define true 1 #undef false #define false 0 #ifndef __BORLANDC__ EXEC SQL INCLUDE guaorac.c; #else #include "guarpfe.h" #endif /* #ifndef __BORLANDC__ */ #define ESC_CHAR "\033" #if OPSYS != OS_VMS && OPSYS == OS_WINNT #define BOLD_STR "" #define HIDE_STR "" #define NORM_STR "" #else #define BOLD_STR ESC_CHAR "[7m" #define HIDE_STR ESC_CHAR "[8m" #define NORM_STR ESC_CHAR "[m" #endif #define MAX_FILE_SIZE 500000 static char SQLPlusSilentFlag[4] = ""; typedef struct { int len; char buf[MAX_FILE_SIZE]; } long_varchar; #ifndef __BORLANDC__ EXEC SQL type long_varchar is long varchar (MAX_FILE_SIZE); #endif /* #ifndef __BORLANDC__ */ #ifndef __BORLANDC__ EXEC SQL BEGIN DECLARE SECTION; #endif /* #ifndef __BORLANDC__ */ static int compile; static TMCHAR fname[15]; static long_varchar lvr; static TMCHAR evi_passwd[20] = {0}; static TMCHAR ProgVersion[20]; static TMCHAR evi_ts[30]; short ind_01; short ind_02; short ind_03; short ind_04; short ind_05; short ind_06; short ind_07; short ind_08; short ind_09; short ind_10; #ifndef __BORLANDC__ EXEC SQL END DECLARE SECTION; #endif /* #ifndef __BORLANDC__ */ static char* H1=" "; static char* H2=" Evision's, Inc. - FormFusion Server Administrative Package v1.9.4 "; static TMCHAR* SEEDFILE; /* these don't appear to be used static CHAR100 TableSpace=""; static CHAR100 TempTableSpace=""; */ static char *evi_user="EVISIONS"; static TMCHAR name[30]={0}; static TMCHAR shellcommand[100]; static int evi_exists = 0; static int leaveFiles = 0; static int evi_connected = 0; int auto_detect_seeds(void); int check_connect(void); void check_evi_pass(void); int check_seeds_file(void); void clear(void); void compile_server(void); UFILE* create_file(TMCHAR* FileName); void create_seeds_dummy_file(void); void create_seeds_file(TMCHAR const* seed1, TMCHAR const* seed3); int choose_version(void); void evisleep(int count); int fexists(TMCHAR* fname); int frename(char* oldname, char* newname); int evi_getline(UFILE *fptr, TMCHAR *buf, int maxlen); void header_routine(void); void help_install(void); void initial_import(void); void install(void); void manually_enter_seeds(void); void remove_extension(TMCHAR* srcfilename, TMCHAR* desfilename); int sqlplus(char* User, char* Pass, char* FileName); void stty(int flag); int write_file(TMCHAR *filename, TMCHAR *buf, long bufsize); /****************************************************************************** main ******************************************************************************/ int main(int argc, TMCHAR *argv[]) { SEEDFILE=_TMC("eviseeds.h"); int index; TMCHAR ans[32]; tmstrcpy(evi_ts, _TMC("1.0")); /* Parse command line */ for (index = 1; index < argc; index++) { if (!tmstrcmp(argv[index], _TMC("-l")) || !tmstrcmp(argv[index], _TMC("-L"))) leaveFiles = 1; if (!tmstrcmp(argv[index], _TMC("-s")) || !tmstrcmp(argv[index], _TMC("-S"))) strcpy(SQLPlusSilentFlag, "-s"); } /* for (index) */ install(); if (fexists(SEEDFILE)) { tmprintf(&tmBundle,_TMC("\n\n" "The seeds file still exists in your file system. By not removing this\n" "file from your system you can potentially create a security hole in which\n" "unauthorized users can see the values of your secret seeds.\n\n" " Remove the file {0} (y/n)? "), SEEDFILE); evi_getline(tmstdin, ans, sizeof(ans)/sizeof(TMCHAR)); if (ans[0] == 'y' || ans[0] == 'Y') remove(tmtochar8(SEEDFILE)); else tmprintf(&tmBundle,_TMC("\n" "The file {0} remains in your file system. Be sure to take standard\n" "security precautions with this file.\n\n"), SEEDFILE); } return EXIT_SUCCESS; } /* main */ /*** BEGIN UNIT FUNCTIONS ***/ /***************************************************************************** auto_detect_seeds Called from check_seeds_file() to auto determine the seed values. Returns 0 if the seeds could not be detected, 1 if successful. *****************************************************************************/ int auto_detect_seeds(void) { TMCHAR dbauser[64]; TMCHAR dbapass[32]; TMCHAR8* dbaUser8; TMCHAR8* dbaPass8; char* tmpstr; TMCHAR ans[32]; static TMCHAR seed1[20]; static TMCHAR seed3[20]; evi_connected = 0; while (1) { *dbauser = '\0'; *dbapass = '\0'; tmprintf(&tmBundle,_TMC("\n\n" "To automatically detect the seed values from Banner you must connect\n" "as a DBA user\n\n" " Please type the DBA username: ")); evi_getline(tmstdin, dbauser, sizeof(dbauser)/sizeof(TMCHAR)); /* It is possible for user to use the user/password notation, check if used */ tmstrtok(dbauser, _TMV("/")); tmpstr = strtok(NULL, "/"); if (tmpstr) tmstrcpy(dbapass, _TMV(tmpstr)); if (dbapass[0] == '\0') { tmprintf(&tmBundle,_TMC(" Please type the password for {0}:"), dbauser); printf(BOLD_STR); stty(false); evi_getline(tmstdin, dbapass, sizeof(dbapass)/sizeof(TMCHAR)); printf(NORM_STR); } dbaUser8 = tmtochar8(dbauser); dbaPass8 = tmtochar8(dbapass); printf("USER%s\n",dbaUser8); printf("PASS%s\n",dbaPass8); #ifndef __BORLANDC__ EXEC SQL whenever sqlerror continue; EXEC SQL CONNECT :dbaUser8 IDENTIFIED by :dbaPass8; if (sqlca.sqlcode != 0) { tmprintf(&tmBundle,_TMC("Wrong password for {0} entered. Try again (y/n)?"), dbauser); evi_getline(tmstdin, ans, sizeof(ans)/sizeof(TMCHAR)); if (ans[0] == 'y' || ans[0] == 'Y') continue; return 0; } EXEC SQL DECLARE auto_detect_cursor CURSOR FOR SELECT GUBIPRF_SEED1, GUBIPRF_SEED3 FROM BANSECR.GUBIPRF; EXEC SQL OPEN auto_detect_cursor; if (sqlca.sqlcode != 0) { tmprintf(&tmBundle,_TMC("Couldn't find table GUBIPRF. {0} might not be a DBA.\n" "Try again (y/n)?"), dbauser); evi_getline(tmstdin, ans, sizeof(ans)/sizeof(TMCHAR)); if (ans[0] == 'y' || ans[0] == 'Y') continue; return 0; } EXEC SQL FETCH auto_detect_cursor INTO :seed1:ind_01, :seed3:ind_02; #else strcpy(seed1, "12345678"); strcpy(seed3, "87651234"); #endif /* #ifdef __BORLANDC__ */ create_seeds_file(seed1, seed3); return 1; } } /* auto_detect_seeds */ /***************************************************************************** check_connect Connects to the database as EVISIONS. *****************************************************************************/ int check_connect(void) { TMCHAR ans[5]; TMCHAR8* evi_passwd8; while (!evi_connected) { check_evi_pass(); evi_passwd8 = tmtochar8(evi_passwd); #ifndef __BORLANDC__ EXEC SQL whenever sqlerror continue; EXEC SQL CONNECT :evi_user IDENTIFIED by :evi_passwd8; if (sqlca.sqlcode != 0) { tmprintf(&tmBundle,_TMC("Wrong password for EVISIONS entered. Try again (y/n)?")); evi_getline(tmstdin, ans, sizeof(ans)/sizeof(TMCHAR)); if (ans[0] == 'y' || ans[0] == 'Y') continue; return -1; } #endif /* #ifndef __BORLANDC__ */ evi_connected = 1; break; } return evi_connected; } /* check_connect */ /***************************************************************************** check_evi_pass get password for evisions userid. Verify if userid already exists and if it owns tables. ******************************************************************************/ void check_evi_pass(void) { tmprintf(&tmBundle,_TMC("\n\n Enter the password for EVISIONS: ")); printf(BOLD_STR); stty(false); evi_getline(tmstdin, evi_passwd, sizeof(evi_passwd)/sizeof(TMCHAR)); printf(NORM_STR); } /* check_evi_pass */ /***************************************************************************** check_seeds_file Checks for the existence of the "eviseeds.h" file. Will prompt the user if the file does not exist. If the user wants to cancel compiling then 0 is returned. If compiling should continue then 1 is returned. *****************************************************************************/ int check_seeds_file(void) { TMCHAR ans[32]; while (!fexists(SEEDFILE)) { /* Prompt the user on method of creating the seed file */ tmprintf(&tmBundle,_TMC("\n\nCreate the seeds.h file:\n\n" "Banner 2000 provides additional security beyond that supplied by Oracle\n" "security. This is accomplished by using a password protected role which\n" "gives appropriate access to tables in the Banner database. In order for\n" "FormFusion to become part of the Banner system it must know two \"seed\"\n" "values.\n\n" "These seed values allow FormFusion (and any other Banner process) to decrypt\n" "the password used to enable the correct Oracle role. The seeds will be\n" "stored in a local file named \"{0}\". You will be prompted to destroy\n" "this file when FormFusion Administrator closes.\n\n" "To populate this file you may either manually type the values, allow\n" "FormFusion Administrator to automatically detect the values, or reference\n" "the existing \"guassed.h\" Banner include file which contains these seed\n" "values. The third option is how all other Banner processes are compiled\n" "however Evisions has provided option 1 and option 2 for institutions which\n" "have hidden the guassed.h file or cannot access it during the compile.\n" "Which option would you prefer?\n\n" " 1. Manually type these values\n" " 2. Automatically detect (requires a DBA user)\n" " 3. Reference seed values in \"guassed.h\"\n" " X. Cancel compile\n" "> "), SEEDFILE); evi_getline(tmstdin, ans, sizeof(ans)/sizeof(TMCHAR)); switch (ans[0]) { case '1': manually_enter_seeds(); return 1; case '2': return auto_detect_seeds(); case '3': create_seeds_dummy_file(); return 1; case 'x': case 'X': return 0; default: tmprintf(&tmBundle, _TMC("\n{0} {1} {2} is an invalid option. Please choose again.\n"), _TMV(BOLD_STR), ans, _TMV(NORM_STR)); evisleep(2); } } /* while */ /* File already existed */ return 1; } /* check_seeds_file */ /***************************************************************************** clear *****************************************************************************/ void clear(void) { #if OPSYS!=OS_VMS && OPSYS==OS_WINNT int index; for (index = 0; index < 25; index++) printf("\n"); #else printf(ESC_CHAR "[2J" ESC_CHAR "[1;1H"); /* Clear screen */ #endif /* #if OPSYS!=OS_VMS && OPSYS==OS_WINNT */ } /* clear */ /***************************************************************************** ExecuteFile Execute the specified executable file *****************************************************************************/ void ExecuteFile(TMCHAR* FileName, TMCHAR rm_files[100][20], int* file_count) { TMCHAR syscall[1024]; tmprintf(&tmBundle,_TMC("Executing: {0} ... "), FileName); tmfflush(tmstdout); #if OPSYS != OS_VMS && OPSYS == OS_WINNT /* Don't know why yet but on NT systems the execution of initial file doesn't work, but copy does...CMA */ tmsprintf(&tmBundle,syscall, _TMC("copy {0} 2{0}"), FileName); tmsystem(syscall); tmsprintf(&tmBundle, (TMCHAR*) rm_files[*file_count], _TMC("2{0}"), FileName); if (tmsystem((TMCHAR*) rm_files[*file_count++]) == -1) #else if (tmsystem(FileName) == -1) #endif tmprintf(&tmBundle,_TMC("{0} failed\n"), FileName); else printf("success\n"); } /* ExecuteFile */ /***************************************************************************** CompileFile Compile the specified executable file *****************************************************************************/ void CompileFile(const TMCHAR* FileName) { TMCHAR tmpname[20]; #if OPSYS == OS_VMS tmsprintf(&tmBundle,shellcommand, _TMC("$@gen$com:sctproc {0} \"full userid=evisions/{1}\""), FileName, evi_passwd); #elif OPSYS == OS_UNIX tmsprintf(&tmBundle, shellcommand, _TMC("make -f $BANNER_LINKS/sctproc.mk {0}" " CHECKOPT=\"sqlcheck=full userid=evisions/{1}\""), FileName, evi_passwd); #else tmsprintf(&tmBundle, shellcommand, _TMC("perl %%BANNER_HOME%%\\general\\misc\\sctproc.pl" " -prog=\"%%EVIPATH%%\\{0}\"" " -checkopt=\"sqlcheck=full userid=evisions/{1} include=%%EVIPATH%%\""), FileName, evi_passwd); #endif if (tmsystem(shellcommand) == 0) tmprintf(&tmBundle,_TMC("{0}: Compiled\n"), FileName); else tmprintf(&tmBundle,_TMC("{0}: Error during compile\n"), FileName); tmsprintf(&tmBundle,tmpname, _TMC("{0}.c"), FileName); remove(tmtochar8(tmpname)); } /* CompileFile */ /***************************************************************************** compile_server compile main server program for FormFusion (evilp) *****************************************************************************/ void compile_server(void) { int compile_count = 0; int execute_count = 0; int file_count = 0; int num_written; TMCHAR rm_files[100][20]; TMCHAR compile_file[20][20]; TMCHAR execute_file[20][20]; TMCHAR defaultVersion[16]; /* Make sure seeds.h exists */ if (check_seeds_file() == 0) { tmprintf(&tmBundle,_TMC("\n{0}Compile of evilp cancelled.{1}\n"), _TMV(BOLD_STR), _TMV(NORM_STR)); evisleep(2); return; } clear(); header_routine(); if (check_connect() == -1) return; if (!choose_version()) goto _sleep; #ifndef __BORLANDC__ EXEC SQL DECLARE compileserver_cursor CURSOR FOR select eviprogram_prog_text, eviprogram_prog_name, eviprogram_compile from evisions.eviprogram where eviprogram_version = :ProgVersion; EXEC SQL OPEN compileserver_cursor; EXEC SQL FETCH compileserver_cursor INTO :lvr:ind_01, :fname:ind_02, :compile:ind_03; if (NO_ROWS_FOUND) { tmfprintf(&tmBundle,tmstderr, _TMC("\n\n0 files found for version \"{0}\"\n"), ProgVersion); goto _sleep; } else { do { num_written = write_file(fname, _TMV(lvr.buf), lvr.len); /*DEBUG if (num_written != lvr.len) { tmfprintf(&tmBundle,tmstderr,_TMC("\n\nError writing file. Can't create output file.")); tmfprintf(&tmBundle,tmstderr,_TMC("\nCheck to make sure you have write permission in ")); tmfprintf(&tmBundle,tmstderr,_TMC("\nthe directory and that there is enough disk space.")); goto _sleep; } */ tmstrcpy(rm_files[file_count++], fname); if (ind_03 == 0) { if (compile == 1) /* Compilable source file */ #if OPSYS != OS_VMS && OPSYS == OS_WINNT tmstrcpy(compile_file[compile_count++], fname); #else remove_extension(fname, compile_file[compile_count++]); #endif #if OPSYS == OS_VMS else if (compile == 3) /* VMS executable script file */ tmsprintf(&tmBundle,execute_file[execute_count++], _TMC("@{0}"), fname); #elif OPSYS == OS_UNIX else if (compile == 2) /* UNIX executable script file */ tmsprintf(&tmBundle,execute_file[execute_count++], _TMC("sh {0}"), fname); #else /* WinNT */ else if (compile == 4) /* WinNT/DOS executable script file */ tmstrcpy(execute_file[execute_count++], fname); #endif /* #if OPSYS == OS_VMS */ } EXEC SQL FETCH compileserver_cursor INTO :lvr:ind_01, :fname:ind_02, :compile:ind_03; } while (ROWS_FOUND); } #endif /* #ifndef __BORLANDC__ */ if (execute_count + compile_count > 1) { TMCHAR ans[32]; while (true) { int index; int choiceIndex = 0; printf("\n\nChoose the operation to perform:\n\n"); printf(" A. Compile/Execute all\n"); for (index = 0; index < execute_count; ++index) tmprintf(&tmBundle,_TMC(" {0,number,integer}. Execute \"{1}\"\n"), ++choiceIndex, execute_file[index]); for (index = 0; index < compile_count; ++index) tmprintf(&tmBundle,_TMC(" {0,number,integer}. Compile \"{1}\"\n"), ++choiceIndex, compile_file[index]); printf(" X. Exit this menu\n"); printf("> "); /* Prompt the user on which file to execute or compile */ evi_getline(tmstdin, ans, sizeof(ans)/sizeof(TMCHAR)); if (*ans == 'A' || *ans == 'a') { printf("\nCompiling and executing all files\n"); for (index = 0; index < execute_count; ++index) ExecuteFile(execute_file[index], rm_files, &file_count); for (index = 0; index < compile_count; ++index) CompileFile(compile_file[index]); goto _sleep; } else if (*ans == 'X' || *ans == 'x') { goto _exit; } else { int choice = tmatoi(ans); if (choice <= 0 || choice > execute_count + compile_count) { tmfprintf(&tmBundle,tmstderr, _TMC("\nThat is an invalid choice. Try again.")); evisleep(3); } else { if (choice - 1 < execute_count) ExecuteFile(execute_file[choice - 1], rm_files, &file_count); else CompileFile(compile_file[choice - execute_count - 1]); } } } /* while */ } else if (execute_count == 1) { ExecuteFile(execute_file[0], rm_files, &file_count); } else if (compile_count == 1) { CompileFile(execute_file[0]); } else { tmfprintf(&tmBundle,tmstderr, _TMC("There are no files to compile or execute.\n")); } _sleep: evisleep(5); _exit: if (!leaveFiles) { /* Remove all of the temporary files */ while (file_count-- > 0) remove(tmtochar8(rm_files[file_count])); } #ifndef __BORLANDC__ EXEC SQL CLOSE compileserver_cursor; #endif /* #ifndef __BORLANDC__ */ } /* compile_server */ /****************************************************************************** create_file Creates a new file for output. ******************************************************************************/ UFILE* create_file(TMCHAR* FileName) { UFILE* fout; fout = tmfopen(&tmBundle,FileName, #if OPSYS == OS_VMS _TMV("w")); /* "wb", "rat=none", "rfm=fix", "mrs=512", "ctx=stm", "mbc=20"); */ #else _TMV("wb")); #endif /* #if OPSYS == OS_VMS */ if (!fout) tmfprintf(&tmBundle,tmstderr, _TMC("\nCouldn't create file \"{0}\", aborting!\n"), FileName); return fout; } /* create_file */ /***************************************************************************** create_seeds_dummy_file Creates the seeds.h include file that will be compiled in to evilp. *****************************************************************************/ void create_seeds_dummy_file(void) { TMCHAR buffer[1024]; tmsprintf(&tmBundle,buffer, _TMC("/*************************************************************************\n" " {0}\n\n" " This file was generated by eviadm for use during compiling of evilp.pc\n" " *************************************************************************/\n" "#include \"guassed.h\"\n"), SEEDFILE); write_file(SEEDFILE, buffer, tmstrlen(buffer)); } /* create_seeds_dummy_file */ /***************************************************************************** create_seeds_file Creates the seeds.h include file that will be compiled in to evilp. *****************************************************************************/ void create_seeds_file(TMCHAR const* seed1, TMCHAR const* seed3) { TMCHAR buffer[1024]; tmsprintf(&tmBundle,buffer, _TMC("/*************************************************************************\n" " {0}\n\n" " This file was generated by eviadm for use during compiling of evilp.pc\n" " Use of this file for any other purpose than to compile evilp is\n" " prohibited. Evisions, Inc. is not to be held responsible for misuse of\n" " this file.\n" " *************************************************************************/\n" "#ifndef SEEDSH\n" "#define SEEDSH\n\n" "#define SECRET_SEED1 {1}L\n" "#define SECRET_SEED3 {2}L\n\n" "#endif /* #ifndef SEEDSH */\n"), SEEDFILE, seed1, seed3); write_file(SEEDFILE, buffer, tmstrlen(buffer)); } /* create_seeds_file */ /***************************************************************************** choose_version Displays the versions of the software in the database. Asks the user to choose the version to compile. *****************************************************************************/ int choose_version(void) { TMCHAR ver[15]; int col; TMCHAR defaultVersion[16]; #ifndef __BORLANDC__ *defaultVersion = '\0'; EXEC SQL DECLARE displayversions_cursor CURSOR FOR select eviprogram_version from eviprogram group by eviprogram_version; EXEC SQL OPEN displayversions_cursor; EXEC SQL FETCH displayversions_cursor INTO :ver:ind_01; col = 0; printf("\nFormFusion versions in database:\n"); if (ROWS_FOUND) { do { tmprintf(&tmBundle,_TMC("{0} "), ver); if (++col >= 5) { printf("\n"); col = 0; } tmstrcpy(defaultVersion, ver); EXEC SQL FETCH displayversions_cursor INTO :ver:ind_01; } while (ROWS_FOUND); printf("\n"); } EXEC SQL CLOSE displayversions_cursor; #endif /* #ifndef __BORLANDC__ */ if (*defaultVersion) { tmprintf(&tmBundle,_TMC("Please type the version to compile and install (default {0}): "), defaultVersion); evi_getline(tmstdin, ProgVersion, sizeof(ProgVersion)/sizeof(TMCHAR)); if (!*ProgVersion) tmstrcpy(ProgVersion, defaultVersion); } else { printf("There are no programs in the EVIPROGRAM table.\n"); return 0; } return 1; } /* display_versions */ /****************************************************************************** evisleep ******************************************************************************/ void evisleep(int count) { #if OPSYS==OS_VMS time_t timer; struct tm *tblock; int lastSec; timer = time(NULL); tblock = localtime(&timer); lastSec = tblock->tm_sec; while (count) { timer = time(NULL); tblock = localtime(&timer); if (tblock->tm_sec != lastSec) { count--; lastSec = tblock->tm_sec; } } #else sleep(count); #endif /* #if OPSYS==OS_VMS */ } /* evisleep */ /****************************************************************************** fexists Returns !0 if the file exists. 0 if it doesn't exist. ******************************************************************************/ int fexists(TMCHAR* fname) { UFILE* fptr; fptr = tmfopen(&tmBundle, fname, _TMC("r")); if (fptr) { tmfclose(fptr); return 1; } return 0; } /* fexists */ /****************************************************************************** frename Renames the source file to the destination file. Don't know why UNIX doesn't define this function. If a suitable function can be found it would be better than calling system(). ******************************************************************************/ int frename(char* oldname, char* newname) { #if OPSYS!=OS_VMS && OPSYS==OS_UNIX char runstr[256]; sprintf(runstr, "mv %s %s", oldname, newname); return system(runstr); #else return rename(oldname, newname); #endif /* #if OPSYS!=OS_VMS && OPSYS==OS_UNIX */ } /* frename */ /****************************************************************************** evi_getline Retrieves a line from the input stream and stores the results in buf Inputs: fptr - The file to read characters from buf - The buffer to store characters in maxlen- The maximum length of the input buffer Returns: 1 if the string was successfully retrieved 0 otherwise. ******************************************************************************/ int evi_getline(UFILE *fptr, TMCHAR *buf, int maxlen) { int ch; if (tmfeof(fptr)) return 0; /* Get the entire line, leave room for NULL character if string longer than maxlen */ ch = 0; while (!tmfeof(fptr) && ch != 10 && maxlen > 1) { if ((ch = tmgetc(fptr)) >= 0) { if (ch != 10 && ch != 13) *buf++ = ch; maxlen--; } } *buf = 0; return 1; } /* evi_getline */ /***************************************************************************** header_routine Print the header information on each screen *****************************************************************************/ void header_routine(void) { printf(BOLD_STR); printf("%s\n", H1); printf("%s\n", H2); printf("%s\n\n", H1); printf(NORM_STR); } /* header_routine */ /****************************************************************************** help_install ******************************************************************************/ void help_install(void) { TMCHAR ans[5]; clear(); header_routine(); printf("Install FormFusion Server Help:\n\n"); printf( "Before running this application, the administrator must have\n" "executed the \"ffadmin\" application installed on the Windows-based\n" "client-side computer. \"eviadm\" requires that the EVISIONS user has\n" "been created correctly.\n\n" "PRESS TO CONTINUE\n"); evi_getline(tmstdin, ans, sizeof(ans)/sizeof(TMCHAR)); clear(); header_routine(); printf("Install FormFusion Server Help:\n\n"); printf( "A - Launches the Oracle \"import\" utility to import the\n" " \"formfusion.dmp\" file. If tables do not already exist they will\n" " be created using the Evisions defaults for all table options.\n" " Whether the tables previously existed or not, the data contained\n" " in the DMP file will be imported into these tables. The only table\n" " that contains data in the DMP file is EVIPROGRAM. This table will\n" " be used in option B to compile the FormFusion server software. If\n" " the error message \"Unique constraint error\" is displayed during\n" " import, this means that the database already contains the version\n" " of the FormFusion server software that exists in the DMP file.\n\n" "PRESS TO CONTINUE\n"); evi_getline(tmstdin, ans, sizeof(ans)/sizeof(TMCHAR)); clear(); header_routine(); printf("Install FormFusion Server Help:\n\n"); printf( "B - Will compile the FormFusion Server software for your platform.\n" " The executable file will be named \"evilp\" and will exist in your\n" " Banner executable directory. There may be secondary executables\n" " compiled by running this command that are necessary for evilp to\n" " function properly. These too will be placed into your Banner\n" " executable directory.\n\n" "PRESS TO RETURN TO THE MENU\n"); evi_getline(tmstdin, ans, sizeof(ans)/sizeof(TMCHAR)); } /* help_install */ /****************************************************************************** initial_import Import tables and data. ******************************************************************************/ void initial_import(void) { TMCHAR import_file[15]={0}; tmstrcpy(import_file,_TMC("import_tab.par")); int i,l,a,e; UFILE* fout; TMCHAR importCommand[32]; clear(); header_routine(); if (check_connect() == -1) return; if ((fout = create_file(import_file)) == NULL) return; printf("\n\n Please type the Oracle import program name (imp): "); evi_getline(tmstdin, importCommand, sizeof(importCommand)/sizeof(TMCHAR)); if (!*importCommand) tmstrcpy(importCommand, _TMC("imp")); printf("\n\n Importing files and sample data.\n\n"); tmfprintf(&tmBundle,fout, _TMC("FILE=(formfusion.dmp)\n")); tmfprintf(&tmBundle,fout, _TMC("FULL=Y\n")); tmfprintf(&tmBundle,fout, _TMC("IGNORE=Y\n")); tmfprintf(&tmBundle,fout, _TMC("GRANTS=N\n")); tmfprintf(&tmBundle,fout, _TMC("BUFFER=4000000\n")); tmfclose(fout)/*, fout = NULL*/; tmsprintf(&tmBundle, shellcommand, _TMC("{0} evisions/{1} parfile={2}"), importCommand, evi_passwd, import_file); tmsystem(shellcommand); remove(tmtochar8(import_file)); printf("\n Import complete.\n"); _exit: evisleep(2); } /* initial_import */ /****************************************************************************** install Menu displays all options available to administrative user on the server. ******************************************************************************/ void install(void) { TMCHAR ans[5]; while (true) { clear(); header_routine(); printf(" INSTALL FormFusion Server \n\n\n\n"); printf(" A - IMPORT TABLES\n\n"); printf(" B - COMPILE FORMFUSION SERVER SOFTWARE\n\n"); printf(" H - HELP\n\n\n"); printf(" X - EXIT INSTALL MENU\n\n\n\n"); printf(" Please enter your choice: "); printf(BOLD_STR); evi_getline(tmstdin, ans, sizeof(ans)/sizeof(TMCHAR)); printf(NORM_STR); switch (ans[0]) { case 'a': case 'A': initial_import(); break; case 'b': case 'B': compile_server(); break; case 'h': case 'H': help_install(); break; case 'x': case 'X': clear(); printf("\n\n You are now returning to shell...\n\n\n"); return; default: tmprintf(&tmBundle, _TMC("\n\n\n <{0}> IS NOT A VALID CHOICE!!! \n"), ans); evisleep(2); } /* switch */ } /* while (true) */ } /* install */ /***************************************************************************** manually_enter_seeds Called from check_seeds_file() to allow the user to manually enter the secret seed values. *****************************************************************************/ void manually_enter_seeds(void) { TMCHAR seed1[32]; TMCHAR seed3[32]; printf("\n Please type the value for SEED1: "); printf(BOLD_STR); stty(false); evi_getline(tmstdin, seed1, sizeof(seed1)/sizeof(TMCHAR)); printf(NORM_STR); printf("\n Please type the value for SEED3: "); printf(BOLD_STR); stty(false); evi_getline(tmstdin, seed3, sizeof(seed3)/sizeof(TMCHAR)); printf(NORM_STR); create_seeds_file(seed1, seed3); } /* manually_enter_seeds */ /***************************************************************************** remove_extension Removes the extension of the filename. *****************************************************************************/ void remove_extension(TMCHAR* srcfilename, TMCHAR* desfilename) { tmstrcpy(desfilename, srcfilename); tmstrtok(desfilename, _TMV(".")); } /* remove_extension */ /****************************************************************************** sqlplus Invokes the system command to execute "sqlplus". Return commands are the same ones for a call to system(). ******************************************************************************/ int sqlplus(char* User, char* Pass, char* FileName) { char execstr[1024]; sprintf(execstr, "sqlplus %s %s/%s @%s", SQLPlusSilentFlag, User, Pass, FileName); return system(execstr); } /* sqlplus */ /****************************************************************************** stty Turns on or off the echoing of characters on the terminal. ******************************************************************************/ void stty(int flag) { if (flag) printf(NORM_STR); else printf(HIDE_STR); } /* stty */ /****************************************************************************** write_file ******************************************************************************/ int write_file(TMCHAR *filename, TMCHAR *buf, long bufsize) { UFILE* fout; int numWritten; if ((fout = create_file(filename)) == NULL) return -1; /* numWritten = fwrite(tmtochar8(buf), 1, bufsize, fout); */ numWritten = u_file_write(buf,bufsize, fout); tmfclose(fout); return(numWritten); } /* write_file */