Changeset b363d83 for owl.c


Ignore:
Timestamp:
Jul 8, 2007, 3:37:43 PM (14 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
be98ba5
Parents:
93f65b6
Message:
Adding a -s switch to change the location of the config dir (~/.owl)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • owl.c

    r13a3c1db rb363d83  
    6464owl_global g;
    6565
     66char * owl_get_datadir() {
     67    char * datadir = getenv("BARNOWL_DATA_DIR");
     68    if(datadir != NULL)
     69        return strchr(datadir, '=') + 1;
     70    return DATADIR;
     71}
     72
    6673int main(int argc, char **argv, char **env)
    6774{
     
    7380  struct sigaction sigact;
    7481  char *configfile, *tty, *perlout, *perlerr, **argvsave, buff[LINE], startupmsg[LINE];
     82  char *confdir;
    7583  owl_filter *f;
    7684  owl_style *s;
     
    8795  argvsave=argv;
    8896  configfile=NULL;
     97  confdir = NULL;
    8998  tty=NULL;
    9099  debug=0;
     
    101110    } else if (!strcmp(argv[0], "-c")) {
    102111      if (argc<2) {
    103         fprintf(stderr, "Too few arguments to -c\n");
    104         usage();
    105         exit(1);
     112        fprintf(stderr, "Too few arguments to -c\n");
     113        usage();
     114        exit(1);
    106115      }
    107116      configfile=argv[1];
     
    110119    } else if (!strcmp(argv[0], "-t")) {
    111120      if (argc<2) {
    112         fprintf(stderr, "Too few arguments to -t\n");
    113         usage();
    114         exit(1);
     121        fprintf(stderr, "Too few arguments to -t\n");
     122        usage();
     123        exit(1);
    115124      }
    116125      tty=argv[1];
     126      argv+=2;
     127      argc-=2;
     128    } else if (!strcmp(argv[0], "-s")){
     129      if (argc<2) {
     130        fprintf(stderr, "Too few arguments to -s\n");
     131        usage();
     132        exit(1);
     133      }
     134      confdir = argv[1];
    117135      argv+=2;
    118136      argc-=2;
     
    191209  /* owl global init */
    192210  owl_global_init(&g);
    193     if (debug) owl_global_set_debug_on(&g);
     211  if (debug) owl_global_set_debug_on(&g);
     212  if (confdir) owl_global_set_confdir(&g, confdir);
    194213  owl_function_debugmsg("startup: first available debugging message");
    195214  owl_global_set_startupargs(&g, argcsave, argvsave);
     
    213232  /* create the owl directory, in case it does not exist */
    214233  owl_function_debugmsg("startup: creating owl directory, if not present");
    215   dir=owl_sprintf("%s/%s", owl_global_get_homedir(&g), OWL_CONFIG_DIR);
     234  dir=owl_global_get_confdir(&g);
    216235  mkdir(dir, S_IRWXU);
    217   owl_free(dir);
    218236
    219237  /* set the tty, either from the command line, or by figuring it out */
     
    697715{
    698716  fprintf(stderr, "Owl version %s\n", OWL_VERSION_STRING);
    699   fprintf(stderr, "Usage: owl [-n] [-d] [-D] [-v] [-h] [-c <configfile>] [-t <ttyname>]\n");
     717  fprintf(stderr, "Usage: owl [-n] [-d] [-D] [-v] [-h] [-c <configfile>] [-s <confdir>] [-t <ttyname>]\n");
    700718  fprintf(stderr, "  -n      don't load zephyr subscriptions\n");
    701719  fprintf(stderr, "  -d      enable debugging\n");
     
    704722  fprintf(stderr, "  -h      print this help message\n");
    705723  fprintf(stderr, "  -c      specify an alternate config file\n");
     724  fprintf(stderr, "  -s      specify an alternate config dir (default ~/.owl)\n");
    706725  fprintf(stderr, "  -t      set the tty name\n");
    707726}
Note: See TracChangeset for help on using the changeset viewer.