Пример #1
0
int config68_init(int argc, char * argv[])
{
  config68_cat = msg68_cat("conf","config file", DEBUG_CONFIG68_O);
  option68_append(opts,sizeof(opts)/sizeof(*opts));
  argc = option68_parse(argc,argv);
  config68_use_registry = !config68_force_file && registry68_support();
  TRACE68(config68_cat,
          "conf68: will use %s\n",
          config68_use_registry?"registry":"config file");
  return argc;
}
Пример #2
0
int file68_init(int argc, char **argv)
{
  char tmp[1024];
  option68_t * opt;

  if (init) {
    const int i = init & 3;
    const char *message[4] = {
      "clean","initialized","shutdowning","initializing"
    };
    error68("file68: init error -- *%s*", message[i]);
    argc = -1;
    goto out_no_init;
  }
  init = 3;

  /* Options */
  option68_init();

  /* Zlib */
  istream68_z_init();

  /* Curl */
  istream68_curl_init();

  /* Xiph AO */
  istream68_ao_init();

  /* Init resource */
  rsc68_init();

  /* Loader */
  file68_loader_init();

  option68_append(opts,sizeof(opts)/sizeof(*opts));
  argc = option68_parse(argc, argv, 1);

  /* Check for --sc68-no-debug */
  opt = option68_get("no-debug", 1);
  if (opt && opt->val.num) {
    /* Remove all debug messages whatsoever. */
    msg68_set_handler(0);
  }

  /* Check for --sc68-asid=off|safe|force */
  if (opt = option68_get("asid",1), opt) {
    if (!strcmp68(opt->val.str,"no"))
      aSIDify = 0;
    else if (!strcmp68(opt->val.str,"safe"))
      aSIDify = 1;
    else if (!strcmp68(opt->val.str,"force"))
      aSIDify = 2;
    else
      msg68_notice("file68: ignore invalid mode for --sc68-asid -- *%s*\n", opt->val.str);
  }

  /* Check for --sc68-debug= */

  /* postpone: at this point most debug features have not been created
     yet. it is pretty much useless to set the mask right now. It will
     be done after all inits.
  */
#if 0
  opt = option68_get("debug", 1);
  if (op) {
    debugmsg68_mask = opt->val.num;
  }
#endif

  /* Get share path from registry */
  opt = option68_get("data", 0);
  if (opt) {

    /* Get data path from registry */
    if (!option68_isset(opt)) {
      char * e;
      const char path[] = "Resources";
      e = get_reg_path(registry68_rootkey(REGISTRY68_LMK),
                       "SOFTWARE/sashipa/sc68/Install_Dir",
                       tmp, sizeof(tmp));
      if (e && (e+sizeof(path) < tmp+sizeof(tmp))) {
        memcpy(e, path, sizeof(path));
        option68_set(opt,tmp);
      }
    }

    /* Setup new data path */
    if (option68_isset(opt)) {
      rsc68_set_share(opt->val.str);
#if 0 /* not needed anynore since option68 properly alloc strings */
      if (opt->val.str == tmp)
        option68_unset(opt);    /* Must release tmp ! */
#endif
    }

  }

  /* Get user path  */
  opt = option68_get("home", 0);
  if (opt) {

    /* Get user path from HOME */
    if (!option68_isset(opt)) {
      const char path[] = "/.sc68";
      const char * env = mygetenv("HOME");
      if(env && strlen(env)+sizeof(path) < sizeof(tmp)) {
        strncpy(tmp,env,sizeof(tmp));
        strcat68(tmp,path,sizeof(tmp));
        /* $$$ We should test if this directory actually exists */
        option68_set(opt,tmp);
      }
    }


    /* Get user path from registry */
    if (!option68_isset(opt)) {
      char * e;
      const char path[] = "sc68";
      e = get_reg_path(registry68_rootkey(REGISTRY68_CUK),
                       "Volatile Environment/APPDATA",
                       tmp, sizeof(tmp));
      if (e && (e+sizeof(path) < tmp+sizeof(tmp))) {
        memcpy(e, path, sizeof(path));
        option68_set(opt,tmp);
      }
    }


    /* Setup new user path */
    if (option68_isset(opt)) {
      rsc68_set_user(opt->val.str);
      if (opt->val.str == tmp)
        option68_unset(opt);    /* Must release tmp ! */
    }

  }

  /* Setup new music path */
  opt = option68_get("music", 1);
  if (opt) {
    rsc68_set_music(opt->val.str);
  }

  /* Setup new remote path */
  opt = option68_get("remote", 1);
  if (opt) {
    rsc68_set_remote_music(opt->val.str);
  }

  init = 1;
out_no_init:
  return argc;
}