Exemplo n.º 1
0
int main(int argc, char **argv) {
  int32_t ch, index, excl_index;
  const char *name;
  bool load_default, exclusive;

  load_default = true;
  exclusive = false;

  index = 0;
  while (1) {
    if ((ch = getopt_long_only(argc, argv, "", opt_field, &index)) < 0)
      break;
    switch (ch) {
      case OPT_LOG:
        log_load(optarg);
        break;

      case OPT_CONFIG:
        config_load(optarg);
        load_default = false;
        break;

      case OPT_EXCL:
        if (exclusive)
          error("Cannot use --%s with --%s",
              opt_field[index].name,
              opt_field[excl_index].name);
        exclusive = true;
        excl_index = index;

      case OPT_NRML:
        name = opt_field[index].name;
        if (opt_field[index].has_arg)
          config_set(name, optarg);
        else
          config_set(name, "true");
        break;

      case OPT_VERSION:
        version();
        return 1;

      case OPT_HELP:
      default:
        usage();
        return 1;
    }
  }

  if (load_default)
    config_default();

  mt_init();

  store_load();
  bucket_load();
  crypt_load();
  volume_load();
  return 0;
}
Exemplo n.º 2
0
int testLog () 
{
    log_t *log = NULL;
    int* d1 = (int*) malloc( sizeof (int) );
    int* d2 = (int*) malloc( sizeof (int) );
    int* d3 = (int*) malloc( sizeof (int) );
    
    assert( d1 && d2 && d3 );
    
    *d1 = 1;
    *d2 = 10;
    *d3 = 100;
    
    /*Test des fonctions log_create et log_insertAfter*/
    log = log_create( sizeof (int) );
    if (log != NULL) printf("log created\n");
    else return -1;
    
    log_freeForward(log);
    
    /*25 est à la fois start, selected et end car seul maillon de la chaine*/
    log_insertAfter( log, ((void*)d1) ); log_next(log);
    log_insertAfter( log, ((void*)d2) ); log_next(log);
    log_insertAfter( log, ((void*)d3) ); log_next(log);
    printf("a "); _log_view(log);

    log_start(log);
    printf("b "); _log_view(log);
    
    log_freeForward(log);
    log_freeForward(log);
    log_freeForward(log);
    printf("c "); _log_view(log);

    /*Test de log_insertBefore : cas elt selected est premier */
    log_insertAfter( log, ((void*)d2) );
    printf("b "); _log_view(log);
    
    log_next(log);
    log_freeSelected(log);
    printf("B "); _log_view(log);
    
    /*Test de log_insertBefore : cas elt selected milieu */
    log_insertBefore( log , ((void*)d3) );
    log_previous( log );
    printf("c "); _log_view(log);
    
    /*Test de log_insertBefore : cas elt selected milieu */
    log_end( log );
    printf("d "); _log_view(log);
    


    /*Test de la fct de sauvegarde*/
    log_save( log, "save1" );
    printf("log save to save1\n");
    
    /* destroy */
    log_destroy(log);
    printf("log destroyed\n");
    
    /*Test de la fct de chargement*/
    log = log_load( "save1", sizeof(int) );
    _log_view(log);
    


    return (0);
}