コード例 #1
0
ファイル: testhash.c プロジェクト: ohmann/checkapi
/* This is kind of a hack, but I am just keeping an existing test.  This is
 * really testing apr_hash_first, apr_hash_next, and apr_hash_this which
 * should be tested in three separate tests, but this will do for now.
 */
static void hash_traverse(abts_case *tc, void *data)
{
    apr_hash_t *h;
    char StrArray[MAX_DEPTH][MAX_LTH];

    h = apr_hash_make(p);
    ABTS_PTR_NOTNULL(tc, h);

    apr_hash_set(h, "OVERWRITE", APR_HASH_KEY_STRING, "should not see this");
    apr_hash_set(h, "FOO3", APR_HASH_KEY_STRING, "bar3");
    apr_hash_set(h, "FOO3", APR_HASH_KEY_STRING, "bar3");
    apr_hash_set(h, "FOO1", APR_HASH_KEY_STRING, "bar1");
    apr_hash_set(h, "FOO2", APR_HASH_KEY_STRING, "bar2");
    apr_hash_set(h, "FOO4", APR_HASH_KEY_STRING, "bar4");
    apr_hash_set(h, "SAME1", APR_HASH_KEY_STRING, "same");
    apr_hash_set(h, "SAME2", APR_HASH_KEY_STRING, "same");
    apr_hash_set(h, "OVERWRITE", APR_HASH_KEY_STRING, "Overwrite key");

    dump_hash(p, h, StrArray);

    ABTS_STR_EQUAL(tc, "Key FOO1 (4) Value bar1\n", StrArray[0]);
    ABTS_STR_EQUAL(tc, "Key FOO2 (4) Value bar2\n", StrArray[1]);
    ABTS_STR_EQUAL(tc, "Key FOO3 (4) Value bar3\n", StrArray[2]);
    ABTS_STR_EQUAL(tc, "Key FOO4 (4) Value bar4\n", StrArray[3]);
    ABTS_STR_EQUAL(tc, "Key OVERWRITE (9) Value Overwrite key\n", StrArray[4]);
    ABTS_STR_EQUAL(tc, "Key SAME1 (5) Value same\n", StrArray[5]);
    ABTS_STR_EQUAL(tc, "Key SAME2 (5) Value same\n", StrArray[6]);
    ABTS_STR_EQUAL(tc, "#entries 7\n", StrArray[7]);
}
コード例 #2
0
ファイル: util.c プロジェクト: gunnihinn/devel-quickcover
void dump_value(pTHX_ SV* val, Buffer* buf)
{
    if (!val) {
      return;
    }

    if (SvIOK(val)) {
        char str[50];
        int len = sprintf(str, "%ld", (long) SvIV(val));
        buffer_append(buf, str, len);
    } else if (SvNOK(val)) {
        char str[50];
        int len = sprintf(str, "%lf", (double) SvNV(val));
        buffer_append(buf, str, len);
    } else if (SvPOK(val)) {
        STRLEN len;
        char* str = SvPV(val, len);
        buffer_append(buf, "\"", 1);
        buffer_append(buf, str, len);
        buffer_append(buf, "\"", 1);
    } else if (SvROK(val)) {
        SV* rv = SvRV(val);
        if (SvTYPE(rv) == SVt_PVAV) {
            dump_array(aTHX_ (AV*) rv, buf);
        } else if (SvTYPE(rv) == SVt_PVHV) {
            dump_hash(aTHX_ (HV*) rv, buf);
        }
    }
}
コード例 #3
0
ファイル: testhash.c プロジェクト: ohmann/checkapi
static void overlay_same(abts_case *tc, void *data)
{
    apr_hash_t *base = NULL;
    apr_hash_t *result = NULL;
    int count;
    char StrArray[MAX_DEPTH][MAX_LTH];

    base = apr_hash_make(p);
    ABTS_PTR_NOTNULL(tc, base);

    apr_hash_set(base, "base1", APR_HASH_KEY_STRING, "value1");
    apr_hash_set(base, "base2", APR_HASH_KEY_STRING, "value2");
    apr_hash_set(base, "base3", APR_HASH_KEY_STRING, "value3");
    apr_hash_set(base, "base4", APR_HASH_KEY_STRING, "value4");
    apr_hash_set(base, "base5", APR_HASH_KEY_STRING, "value5");

    result = apr_hash_overlay(p, base, base);

    count = apr_hash_count(result);
    ABTS_INT_EQUAL(tc, 5, count);

    dump_hash(p, result, StrArray);

    ABTS_STR_EQUAL(tc, "Key base1 (5) Value value1\n", StrArray[0]);
    ABTS_STR_EQUAL(tc, "Key base2 (5) Value value2\n", StrArray[1]);
    ABTS_STR_EQUAL(tc, "Key base3 (5) Value value3\n", StrArray[2]);
    ABTS_STR_EQUAL(tc, "Key base4 (5) Value value4\n", StrArray[3]);
    ABTS_STR_EQUAL(tc, "Key base5 (5) Value value5\n", StrArray[4]);
    ABTS_STR_EQUAL(tc, "#entries 5\n", StrArray[5]);
}
コード例 #4
0
ファイル: testhash.c プロジェクト: ohmann/checkapi
static void overlay_empty(abts_case *tc, void *data)
{
    apr_hash_t *base = NULL;
    apr_hash_t *overlay = NULL;
    apr_hash_t *result = NULL;
    int count;
    char StrArray[MAX_DEPTH][MAX_LTH];

    base = apr_hash_make(p);
    overlay = apr_hash_make(p);
    ABTS_PTR_NOTNULL(tc, base);
    ABTS_PTR_NOTNULL(tc, overlay);

    apr_hash_set(base, "key1", APR_HASH_KEY_STRING, "value1");
    apr_hash_set(base, "key2", APR_HASH_KEY_STRING, "value2");
    apr_hash_set(base, "key3", APR_HASH_KEY_STRING, "value3");
    apr_hash_set(base, "key4", APR_HASH_KEY_STRING, "value4");
    apr_hash_set(base, "key5", APR_HASH_KEY_STRING, "value5");

    result = apr_hash_overlay(p, overlay, base);

    count = apr_hash_count(result);
    ABTS_INT_EQUAL(tc, 5, count);

    dump_hash(p, result, StrArray);

    ABTS_STR_EQUAL(tc, "Key key1 (4) Value value1\n", StrArray[0]);
    ABTS_STR_EQUAL(tc, "Key key2 (4) Value value2\n", StrArray[1]);
    ABTS_STR_EQUAL(tc, "Key key3 (4) Value value3\n", StrArray[2]);
    ABTS_STR_EQUAL(tc, "Key key4 (4) Value value4\n", StrArray[3]);
    ABTS_STR_EQUAL(tc, "Key key5 (4) Value value5\n", StrArray[4]);
    ABTS_STR_EQUAL(tc, "#entries 5\n", StrArray[5]);
}
コード例 #5
0
int main(/* int argc, char **argv */)
{
    ngx_pool_t *pool = NULL;
    ngx_array_t *array = NULL;
    ngx_hash_t *hash;


    printf("--------------------------------\n");
    printf("create a new pool:\n");
    printf("--------------------------------\n");


    pool = ngx_create_pool(1024, &ngx_log);

    dump_pool(pool);

    printf("--------------------------------\n");
    printf("create and add urls to it:\n");
    printf("--------------------------------\n");
    array = add_urls_to_array(pool);  //in fact, here should validate array
    dump_hash_array(array);

    printf("--------------------------------\n");
    printf("the pool:\n");
    printf("--------------------------------\n");
    dump_pool(pool);

    hash = init_hash(pool, array);
    if (hash == NULL)
    {
        printf("Failed to initialize hash!\n");
        return -1;
    }

    printf("--------------------------------\n");
    printf("the hash:\n");
    printf("--------------------------------\n");
    dump_hash(hash, array);
    printf("\n");

    printf("--------------------------------\n");
    printf("the pool:\n");
    printf("--------------------------------\n");
    dump_pool(pool);

    //find test
    printf("--------------------------------\n");
    printf("find test:\n");
    printf("--------------------------------\n");
    find_test(hash, urls, Max_Num);
    printf("\n");

    find_test(hash, urls2, Max_Num2);

    //release
    ngx_array_destroy(array);
    ngx_destroy_pool(pool);

    return 0;
}
コード例 #6
0
ファイル: testhash.c プロジェクト: TaoheGit/hmi_sdl_android
static void overlay_same(abts_case *tc, void *data)
{
    apr_hash_t *base = NULL;
    apr_hash_t *result = NULL;
    int count;
    char str[8196];

    base = apr_hash_make(p);
    ABTS_PTR_NOTNULL(tc, base);

    apr_hash_set(base, "base1", APR_HASH_KEY_STRING, "value1");
    apr_hash_set(base, "base2", APR_HASH_KEY_STRING, "value2");
    apr_hash_set(base, "base3", APR_HASH_KEY_STRING, "value3");
    apr_hash_set(base, "base4", APR_HASH_KEY_STRING, "value4");
    apr_hash_set(base, "base5", APR_HASH_KEY_STRING, "value5");

    result = apr_hash_overlay(p, base, base);

    count = apr_hash_count(result);
    ABTS_INT_EQUAL(tc, 5, count);

    dump_hash(p, result, str);
    /* I don't know why these are out of order, but they are.  I would probably
     * consider this a bug, but others should comment.
     */
    ABTS_STR_EQUAL(tc, "Key base5 (5) Value value5\n"
                          "Key base1 (5) Value value1\n"
                          "Key base2 (5) Value value2\n"
                          "Key base3 (5) Value value3\n"
                          "Key base4 (5) Value value4\n"
                          "#entries 5\n", str);
}
コード例 #7
0
ファイル: testhash.c プロジェクト: TaoheGit/hmi_sdl_android
/* This is kind of a hack, but I am just keeping an existing test.  This is
 * really testing apr_hash_first, apr_hash_next, and apr_hash_this which 
 * should be tested in three separate tests, but this will do for now.
 */
static void hash_traverse(abts_case *tc, void *data)
{
    apr_hash_t *h;
    char str[8196];

    h = apr_hash_make(p);
    ABTS_PTR_NOTNULL(tc, h);

    apr_hash_set(h, "OVERWRITE", APR_HASH_KEY_STRING, "should not see this");
    apr_hash_set(h, "FOO3", APR_HASH_KEY_STRING, "bar3");
    apr_hash_set(h, "FOO3", APR_HASH_KEY_STRING, "bar3");
    apr_hash_set(h, "FOO1", APR_HASH_KEY_STRING, "bar1");
    apr_hash_set(h, "FOO2", APR_HASH_KEY_STRING, "bar2");
    apr_hash_set(h, "FOO4", APR_HASH_KEY_STRING, "bar4");
    apr_hash_set(h, "SAME1", APR_HASH_KEY_STRING, "same");
    apr_hash_set(h, "SAME2", APR_HASH_KEY_STRING, "same");
    apr_hash_set(h, "OVERWRITE", APR_HASH_KEY_STRING, "Overwrite key");

    dump_hash(p, h, str);
    ABTS_STR_EQUAL(tc, "Key FOO1 (4) Value bar1\n"
                          "Key FOO2 (4) Value bar2\n"
                          "Key OVERWRITE (9) Value Overwrite key\n"
                          "Key FOO3 (4) Value bar3\n"
                          "Key SAME1 (5) Value same\n"
                          "Key FOO4 (4) Value bar4\n"
                          "Key SAME2 (5) Value same\n"
                          "#entries 7\n", str);
}
コード例 #8
0
ファイル: main.c プロジェクト: cherry-wb/Hot-Fuzz
PUBLIC int main(int ac, char **av)
{
     int i, n_files;
     char **files;

     argc = ac; argv = av;

     while (--argc > 0 && (*++argv)[0] == '-')
          do_flags(*argv);
     files = argv;
     n_files = argc;

     if (debflag('v')) {
	  fprintf(errout, "%s\n%s\n%s\n", 
		  fuzz_banner, fuzz_rcsid, fuzz_copyright);
	  fflush(errout);
     }

     debugging = debflag('p');
     init_sym();
     init_type();
     init_dict();
     open_prelude();
     read_a_file();
     if (dflag) {
	  check_file();
	  clear_temp((univ) NULL);
     }

     debugging = TRUE;
     if (n_files == 0) {
	  /* Finished prelude, no args: read stdin */
	  file_name = "standard input";
	  yyrestart(stdin);
	  read_a_file();
     }
     else {
	  for (i = 0; i < n_files; i++) {
	       reopen_input(files[i]);
	       yyrestart(yyin);
	       read_a_file();
	  }
     }
     if (dflag) {
	  check_file();
	  clear_temp((univ) NULL);
     }

#ifdef DEBUG
     if (debflag('h'))
	  dump_hash();
#endif

     return (n_errors > 0 ? 1 : 0);
}
コード例 #9
0
ファイル: ParallelHashing.cpp プロジェクト: bioinf/bayecho
int main(int argc, char** argv) {
  Options opt(argc, argv);

  kmers_map_type kmers_map;

  MMAPReads readfile(opt.readFName);

#pragma omp parallel
  {
#pragma omp single
    {
      std::cout << "Using " << omp_get_num_threads() << " threads" << std::endl;
    }

#pragma omp for
    for(int read_index = opt.read_st; read_index < opt.read_ed; read_index++) {
      bool orig = readfile.isOrig(read_index);
      inner_map_type occ_map;
      std::tr1::shared_ptr<DNASeq> cur_read(new DNASeq(readfile[read_index]));

      for (int pos = 0; pos <= cur_read->size() - opt.K; pos++) {
        Kmer kmer(cur_read, pos, opt.K);
        if (occ_map.find(kmer) == occ_map.end() || !orig) {
          occ_map[kmer] = KmerOccurrence(read_index, pos);
        }
      }

      for(inner_map_type::iterator it = occ_map.begin(); it != occ_map.end(); it++) {
        kmers_map_type::const_accessor ac;
        if (kmers_map.find(ac, it->first)) {
          if (ac->second.size() > KmerHashMap::MaxBinSize) {
            continue;
          }
        } else {
          kmers_map.insert(ac, it->first);
        }
        ac.release();

        kmers_map_type::accessor acw;
        if (kmers_map.find(acw, it->first)) {
          acw->second.push_back(it->second);
        } else {
          std::cout << "ERROR: read is not found" << std::endl; 
        }
        acw.release();
      }
    }
  }

  dump_hash(kmers_map, opt.fpre, opt.fsuf);

  return 0;
}
コード例 #10
0
ファイル: testhash.c プロジェクト: ohmann/checkapi
static void overlay_2unique(abts_case *tc, void *data)
{
    apr_hash_t *base = NULL;
    apr_hash_t *overlay = NULL;
    apr_hash_t *result = NULL;
    int count;
    char StrArray[MAX_DEPTH][MAX_LTH];

    base = apr_hash_make(p);
    overlay = apr_hash_make(p);
    ABTS_PTR_NOTNULL(tc, base);
    ABTS_PTR_NOTNULL(tc, overlay);

    apr_hash_set(base, "base1", APR_HASH_KEY_STRING, "value1");
    apr_hash_set(base, "base2", APR_HASH_KEY_STRING, "value2");
    apr_hash_set(base, "base3", APR_HASH_KEY_STRING, "value3");
    apr_hash_set(base, "base4", APR_HASH_KEY_STRING, "value4");
    apr_hash_set(base, "base5", APR_HASH_KEY_STRING, "value5");

    apr_hash_set(overlay, "overlay1", APR_HASH_KEY_STRING, "value1");
    apr_hash_set(overlay, "overlay2", APR_HASH_KEY_STRING, "value2");
    apr_hash_set(overlay, "overlay3", APR_HASH_KEY_STRING, "value3");
    apr_hash_set(overlay, "overlay4", APR_HASH_KEY_STRING, "value4");
    apr_hash_set(overlay, "overlay5", APR_HASH_KEY_STRING, "value5");

    result = apr_hash_overlay(p, overlay, base);

    count = apr_hash_count(result);
    ABTS_INT_EQUAL(tc, 10, count);

    dump_hash(p, result, StrArray);

    ABTS_STR_EQUAL(tc, "Key base1 (5) Value value1\n", StrArray[0]);
    ABTS_STR_EQUAL(tc, "Key base2 (5) Value value2\n", StrArray[1]);
    ABTS_STR_EQUAL(tc, "Key base3 (5) Value value3\n", StrArray[2]);
    ABTS_STR_EQUAL(tc, "Key base4 (5) Value value4\n", StrArray[3]);
    ABTS_STR_EQUAL(tc, "Key base5 (5) Value value5\n", StrArray[4]);
    ABTS_STR_EQUAL(tc, "Key overlay1 (8) Value value1\n", StrArray[5]);
    ABTS_STR_EQUAL(tc, "Key overlay2 (8) Value value2\n", StrArray[6]);
    ABTS_STR_EQUAL(tc, "Key overlay3 (8) Value value3\n", StrArray[7]);
    ABTS_STR_EQUAL(tc, "Key overlay4 (8) Value value4\n", StrArray[8]);
    ABTS_STR_EQUAL(tc, "Key overlay5 (8) Value value5\n", StrArray[9]);
    ABTS_STR_EQUAL(tc, "#entries 10\n", StrArray[10]);
}
コード例 #11
0
ファイル: findhash.c プロジェクト: Azarien/open-watcom-v2
bool hash_search( void )
/*************************/
{
    unsigned i,j;
    bool ok;

    hashsize = num_keywords;
    for( hashmask = 1; hashmask < hashsize; hashmask <<= 1 ) {
        // set hashmask to 2^n greater than or equal to hashsize
    }
    if( flags.mask_hash ) {
        hashsize = hashmask;
    }
    do {
        for( i = 0; i < max_len; ++i ) {
            for( j = 0; j < max_len + 1; ++j ) {
                ok = hash_func( j, i );
                if( ok ) {
                    if( hashsize == num_keywords ) {
                        output( "Perfect hash function found!\n" );
                    } else {
                        output( "Hash function found.\n" );
                    }
                    if( flags.tiny_output ) {
                        dump_tiny( j, i );
                    } else {
                        dump_weights( j, i );
                        dump_hash();
                    }
                    return( true );
                }
            }
        }
        if( !flags.imperfect )
            break;
        ++hashsize;
    } while( hashsize <= hashmask );
    return( false );
}
コード例 #12
0
ファイル: http-auth.c プロジェクト: LazyZhu/redsocks
char* digest_authentication_encode(const char *line, const char *user, const char *passwd, 
		const char *method, const char *path, int count, const char *cnonce)
{
	char *realm = NULL, *opaque = NULL, *nonce = NULL, *qop = NULL;
	char nc[9];
	sprintf(nc, "%08x", count);

	const char *ptr = line;
	param_token name, value;

	while (extract_param(&ptr, &name, &value, ',')) {
		int namelen = name.e - name.b;
		int valuelen = value.e - value.b;
		
		if (strncasecmp(name.b, "realm" , namelen) == 0) {
			strncpy(realm  = calloc(valuelen + 1, 1), value.b, valuelen);
			realm[valuelen] = '\0';
		}
		else if (strncasecmp(name.b, "opaque", namelen) == 0) {
			strncpy(opaque = calloc(valuelen + 1, 1), value.b, valuelen);
			opaque[valuelen] = '\0';
		}
		else if (strncasecmp(name.b, "nonce" , namelen) == 0) {
			strncpy(nonce  = calloc(valuelen + 1, 1), value.b, valuelen);
			nonce[valuelen] = '\0';
		}
		else if (strncasecmp(name.b, "qop"   , namelen) == 0) {
			strncpy(qop    = calloc(valuelen + 1, 1), value.b, valuelen);
			qop[valuelen] = '\0';
		}
	}

	if (!realm || !nonce || !user || !passwd || !path || !method) {
		free(realm);
		free(opaque);
		free(nonce);
		free(qop);
		return NULL;
	}

	if (qop && strncasecmp(qop, "auth", 5) != 0) {
		/* FIXME: currently don't support auth-int, only "auth" is supported */
		free(realm);
		free(opaque);
		free(nonce);
		free(qop);
		return NULL;
	}

	/* calculate the digest value */
	md5_state_t ctx;
	md5_byte_t hash[MD5_HASHLEN];
	char a1buf[MD5_HASHLEN * 2 + 1], a2buf[MD5_HASHLEN * 2 + 1];
	char response[MD5_HASHLEN * 2 + 1];

	/* A1 = username-value ":" realm-value ":" passwd */
	md5_init(&ctx);
	md5_append(&ctx, (md5_byte_t*)user, strlen(user));
	md5_append(&ctx, (md5_byte_t*)":", 1);
	md5_append(&ctx, (md5_byte_t*)realm, strlen(realm));
	md5_append(&ctx, (md5_byte_t*)":", 1);
	md5_append(&ctx, (md5_byte_t*)passwd, strlen(passwd));
	md5_finish(&ctx, hash);
	dump_hash(a1buf, hash);

	/* A2 = Method ":" digest-uri-value */
	md5_init(&ctx);
	md5_append(&ctx, (md5_byte_t*)method, strlen(method));
	md5_append(&ctx, (md5_byte_t*)":", 1);
	md5_append(&ctx, (md5_byte_t*)path, strlen(path));
	md5_finish(&ctx, hash);
	dump_hash(a2buf, hash);

	/* qop set: request-digest = H(A1) ":" nonce-value ":" nc-value ":" cnonce-value ":" qop-value ":" H(A2) */
	/* not set: request-digest = H(A1) ":" nonce-value ":" H(A2) */
	md5_init(&ctx);
	md5_append(&ctx, (md5_byte_t*)a1buf, strlen(a1buf));
	md5_append(&ctx, (md5_byte_t*)":", 1);
	md5_append(&ctx, (md5_byte_t*)nonce, strlen(nonce));
	md5_append(&ctx, (md5_byte_t*)":", 1);
	if (qop) {
		md5_append(&ctx, (md5_byte_t*)nc, strlen(nc));
		md5_append(&ctx, (md5_byte_t*)":", 1);
		md5_append(&ctx, (md5_byte_t*)cnonce, strlen(cnonce));
		md5_append(&ctx, (md5_byte_t*)":", 1);
		md5_append(&ctx, (md5_byte_t*)qop, strlen(qop));
		md5_append(&ctx, (md5_byte_t*)":", 1);
	}
	md5_append(&ctx, (md5_byte_t*)a2buf, strlen(a2buf));
	md5_finish(&ctx, hash);
	dump_hash(response, hash);

	/* prepare the final string */
	int len = 256;
	len += strlen(user);
	len += strlen(realm);
	len += strlen(nonce);
	len += strlen(path);
	len += strlen(response);

	if (qop) {
		len += strlen(qop);
		len += strlen(nc);
		len += strlen(cnonce);
	}

	if (opaque) {
		len += strlen(opaque);
	}

	char *res = (char*)malloc(len);
	if (!qop) {
		sprintf(res, "username=\"%s\", realm=\"%s\", nonce=\"%s\", uri=\"%s\", response=\"%s\"", 
				user, realm, nonce, path, response);
	} else {
		sprintf(res, "username=\"%s\", realm=\"%s\", nonce=\"%s\", uri=\"%s\", response=\"%s\", qop=%s, nc=%s, cnonce=\"%s\"",
				user, realm, nonce, path, response, qop, nc, cnonce);
	}

	if (opaque) {
		char *p = res + strlen(res);
		strcat (p, ", opaque=\"");
		strcat (p, opaque);
		strcat (p, "\"");
	}

	free(realm);
	free(opaque);
	free(nonce);
	free(qop);
	return res;
}
コード例 #13
0
int main (int argc, char *argv[])
{
	int i;
	char *groupname = NULL;
	char *membername = NULL;
	ToolAction action = DUMPMAPS;
	char *configdir = NULL;
	char *objtype = NULL;
	OSyncError *error = NULL;
	OSyncGroupEnv *env = NULL;
	
	if (argc == 1)
		usage (argv[0], 1);

	groupname = argv[1];
	for (i = 2; i < argc; i++) {
		char *arg = argv[i];
		if (!strcmp (arg, "--mappings")) {
			action = DUMPMAPS;
			objtype = argv[i + 1];
			i++;
			if (!objtype)
				usage (argv[0], 1);
		} else if (!strcmp (arg, "--hash")) {
			action = DUMPHASH;
			objtype = argv[i + 1];
			membername = argv[i + 2];
			i += 2;
			if (!objtype || !membername)
				usage (argv[0], 1);
		} else if (!strcmp (arg, "--reset")) {
			action = RESET;
		} else if (!strcmp (arg, "--help")) {
			usage (argv[0], 0);
		} else if (!strcmp (arg, "--configdir")) {
			configdir = argv[i + 1];
			i++;
			if (!configdir)
				usage (argv[0], 1);
		} else if (!strcmp (arg, "--")) {
			break;
		} else if (arg[0] == '-') {
			usage (argv[0], 1);
		} else {
			usage (argv[0], 1);
		}
	}
	
	env = osync_group_env_new(&error);
	if (!env)
		goto error;
	
	if (!osync_group_env_load_groups(env, configdir, &error))
		goto error;
	
	switch (action) {
	case DUMPMAPS:
		if (objtype)
			dump_map_objtype(env, objtype, groupname);
		else
			dump_map(env, groupname);
		break;
	case DUMPHASH:
		dump_hash(env, objtype, groupname, membername);
		break;
	case RESET:
		reset(env, groupname);
		break;
	}
	osync_group_env_unref(env);
	return 0;

 error:
	if (env)
		osync_group_env_unref(env);
	printf("ERROR: %s", osync_error_print(&error));
	osync_error_unref(&error);
	return 1;
}
コード例 #14
0
/**
 * pass array pointer to read elts[i].key_hash, then for getting the position - key
 */
void dump_combined_hash(ngx_hash_combined_t *hash, ngx_hash_keys_arrays_t *array)
{
	dump_hash(&hash->hash, &array->keys);
	dump_hash_wildcard(&hash->wc_head->hash);
	dump_hash_wildcard(&hash->wc_tail->hash);
}