From 9b0a1395071e204c7f85473809c751e39e5adbb8 Mon Sep 17 00:00:00 2001 From: alfredoport Date: Fri, 19 Aug 2011 03:47:39 +0000 Subject: Fix Graphics components startup --- src/ChangeLog | 8 +++++++ src/include/cfuns.h | 4 ++-- src/lib/cfuns-c.c | 4 ++-- src/sman/sman.c | 64 +++++++++++++++++++++++++++++++++-------------------- 4 files changed, 52 insertions(+), 28 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 09c94978..a955a89f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2011-08-18 Alfredo Portes + + * sman/sman.c: Do not try to start graphic components + if binaries are not present. + * include/cfuns.h: Make writeablep and readablep + arguments const. + * lib/cfuns-c.c: Likewise. + 2011-08-18 Gabriel Dos Reis * interp/momdemap.boot: Fold content into compiler.boot and diff --git a/src/include/cfuns.h b/src/include/cfuns.h index 9697cf06..d3a82fec 100644 --- a/src/include/cfuns.h +++ b/src/include/cfuns.h @@ -43,8 +43,8 @@ namespace OpenAxiom { OPENAXIOM_C_EXPORT int addtopath(char*); OPENAXIOM_C_EXPORT int directoryp(char*); OPENAXIOM_C_EXPORT int make_path_from_file(char*, char*); -OPENAXIOM_C_EXPORT int writeablep(char*); -OPENAXIOM_C_EXPORT int readablep(char*); +OPENAXIOM_C_EXPORT int writeablep(const char*); +OPENAXIOM_C_EXPORT int readablep(const char*); OPENAXIOM_C_EXPORT long findString(char*, char*); OPENAXIOM_C_EXPORT int copyEnvValue(char*, char*); OPENAXIOM_C_EXPORT int oa_chdir(const char*); diff --git a/src/lib/cfuns-c.c b/src/lib/cfuns-c.c index f0b7aed7..ca582164 100644 --- a/src/lib/cfuns-c.c +++ b/src/lib/cfuns-c.c @@ -238,7 +238,7 @@ axiom_has_write_access(const struct stat* file_info) has write access to the dirname of path. */ OPENAXIOM_C_EXPORT int -writeablep(char *path) +writeablep(const char *path) { struct stat buf; int code; @@ -274,7 +274,7 @@ writeablep(char *path) 1 if the file exists and read access is granted. */ OPENAXIOM_C_EXPORT int -readablep(char *path) +readablep(const char *path) { struct stat buf; int code; diff --git a/src/sman/sman.c b/src/sman/sman.c index be21226d..ae117040 100644 --- a/src/sman/sman.c +++ b/src/sman/sman.c @@ -75,8 +75,8 @@ static SpadProcess* spawn_of_hell(const char* , int); static void start_the_spadclient(void); static void start_the_local_spadclient(void); static void start_the_session_manager(void); -static void start_the_hypertex(void); -static void start_the_graphics(void); +static void start_the_hypertex(Command*); +static void start_the_graphics(Command*); static void fork_Axiom(Command*); static void start_the_Axiom(Command*); static void clean_up_sockets(void); @@ -105,10 +105,9 @@ int server_num; /* OpenAxiom server number */ /* definitions of programs which sman can start */ /************************************************/ -const char *GraphicsProgram = "$AXIOM/lib/viewman"; -const char *HypertexProgram = "$AXIOM/lib/hypertex -s"; -const char *ClefProgram = - "$AXIOM/bin/clef -f $AXIOM/lib/command.list -e "; +const char *GraphicsProgram = "/lib/viewman"; +const char *HypertexProgram = "/lib/hypertex"; +const char *ClefProgram = "$AXIOM/bin/clef -f $AXIOM/lib/command.list -e "; const char *SessionManagerProgram = "$AXIOM/lib/session"; const char *SpadClientProgram = "$AXIOM/lib/spadclient"; char *PasteFile = NULL; @@ -445,29 +444,44 @@ start_the_session_manager(void) } static void -start_the_hypertex(void) +start_the_hypertex(Command* cmd) { - char prog[512]; + const char* root_dir = cmd->root_dir; + const char* command = oa_concatenate_string(root_dir,HypertexProgram); + if (readablep(command) != 1) { + fprintf(stderr, "Hypertex program not found.\n"); + return; + } if (PasteFile){ - sprintf(prog, "%s -k -ip %s", HypertexProgram, PasteFile); - spawn_of_hell(prog, NadaDelShitsky); + command = oa_concatenate_string(command, " -s -k -ip "); + command = oa_concatenate_string(command, PasteFile); + spawn_of_hell(command, NadaDelShitsky); } else if (MakeRecordFile){ - sprintf(prog, "%s -k -rm %s", HypertexProgram,MakeRecordFile ); - spawn_of_hell(prog, NadaDelShitsky); + command = oa_concatenate_string(command, " -s -k -rm "); + command = oa_concatenate_string(command, MakeRecordFile); + spawn_of_hell(command, NadaDelShitsky); } else if (VerifyRecordFile){ - sprintf(prog, "%s -k -rv %s", HypertexProgram, VerifyRecordFile); - spawn_of_hell(prog, NadaDelShitsky); + command = oa_concatenate_string(command, " -s -k -rv "); + command = oa_concatenate_string(command, VerifyRecordFile); + spawn_of_hell(command, NadaDelShitsky); } - else spawn_of_hell(HypertexProgram, CleanHypertexSocket); + else + spawn_of_hell(command, CleanHypertexSocket); } static void -start_the_graphics(void) +start_the_graphics(Command* cmd) { - spawn_of_hell(GraphicsProgram, DoItAgain); + const char* root_dir = cmd -> root_dir; + const char* command = oa_concatenate_string(root_dir,GraphicsProgram); + + if (readablep(command) == 1) + spawn_of_hell(command, DoItAgain); + else + fprintf(stderr, "Graphics program not found.\n"); } /* Start the core executable session in a separate process, */ @@ -758,9 +772,9 @@ monitor_children(void) int main(int argc, char *argv[]) { - Command command; - command.root_dir = get_systemdir(argc, argv); - process_options(&command, argc, argv); + Command command; + command.root_dir = get_systemdir(argc, argv); + process_options(&command, argc, argv); putenv((char*) "LC_ALL=C"); setlocale(LC_ALL, ""); @@ -774,12 +788,14 @@ main(int argc, char *argv[]) exit(-1); } start_the_session_manager(); - if (start_spadclient) start_the_spadclient(); - if (start_local_spadclient) start_the_local_spadclient(); + if (start_spadclient) + start_the_spadclient(); + if (start_local_spadclient) + start_the_local_spadclient(); if (start_ht and in_X()) - start_the_hypertex(); + start_the_hypertex(&command); if (start_graphics and in_X()) - start_the_graphics(); + start_the_graphics(&command); openaxiom_sleep(1); if (fork_you(Die) != NULL) { -- cgit v1.2.3