[gq-commit] gq/src configfile.c,1.51,1.52 state.c,1.12,1.13
Status: Beta
Brought to you by:
sur5r
From: <sta...@us...> - 2003-11-03 21:19:56
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv3397 Modified Files: configfile.c state.c Log Message: * Allow to use environment variables GQRC and GQSTATE to override configuration an state file names Index: configfile.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/configfile.c,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** configfile.c 3 Nov 2003 21:07:57 -0000 1.51 --- configfile.c 3 Nov 2003 21:19:53 -0000 1.52 *************** *** 299,318 **** { gchar *rcpath = NULL; - /* static char rcpath[128]; */ char *home; ! home = homedir(); ! if(home == NULL) { ! error_push(context, _("You have no home directory!")); ! return(NULL); } - - /* need add'l "/", thus add some extra chars */ - rcpath = g_malloc(strlen(home) + strlen(RCFILE) + 3); - - sprintf(rcpath, "%s/%s", home, RCFILE); - g_free(home); - - return(rcpath); } --- 299,321 ---- { gchar *rcpath = NULL; char *home; + char *env = getenv("GQRC"); + + if (env) { + return g_strdup(env); + } else { + home = homedir(); + if(home == NULL) { + error_push(context, _("You have no home directory!")); + return(NULL); + } ! /* need add'l "/", thus add some extra chars */ ! rcpath = g_malloc(strlen(home) + strlen(RCFILE) + 3); ! ! sprintf(rcpath, "%s/%s", home, RCFILE); ! g_free(home); ! return(rcpath); } } Index: state.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/state.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** state.c 3 Nov 2003 21:07:58 -0000 1.12 --- state.c 3 Nov 2003 21:19:54 -0000 1.13 *************** *** 491,508 **** gchar *rcpath = NULL; char *home; ! home = homedir(); ! if(home == NULL) { ! error_push(context, _("You have no home directory!")); ! return(NULL); } - - /* need add'l "/", thus add some extra chars */ - rcpath = g_malloc(strlen(home) + strlen(STATEFILE) + 3); - - sprintf(rcpath, "%s/%s", home, STATEFILE); - g_free(home); - - return(rcpath); } --- 491,513 ---- gchar *rcpath = NULL; char *home; + char *env = getenv("GQSTATE"); ! if (env) { ! return g_strdup(env); ! } else { ! home = homedir(); ! if(home == NULL) { ! error_push(context, _("You have no home directory!")); ! return(NULL); ! } ! ! /* need add'l "/", thus add some extra chars */ ! rcpath = g_malloc(strlen(home) + strlen(STATEFILE) + 3); ! ! sprintf(rcpath, "%s/%s", home, STATEFILE); ! g_free(home); ! ! return(rcpath); } } |