Ejemplo n.º 1
0
int main(){
    
    struct gameState g_s;
    int a_cards[10] = {adventurer, council_room, minion, great_hall, cutpurse, mine, gardens, sea_hag, tribute, smithy};
    int test_result1, real_result;   

    printf("\n*****Card test for great hall*****\n");
    initializeGame(2, a_cards, 3, &g_s);

    test_result1 = numHandCards(&g_s);    
    real_result = cardEffect(great_hall, 0, 0, 0, &g_s, 0, 0);  

	if(!assert_result(real_result, 0)) 
         printf("FAILURE 1:  This card cannot be executed\n");
    else{
		printf("PASS 1: This card can be executed\n");

    	real_result = numHandCards(&g_s);
    	if(!assert_result(real_result, test_result1+1-1))
			 printf("Failure 2:  The effact of this card is incorrect\n");   
        else
            printf("PASS 2: The effact of this card is correct\n");
	}
	printf("*********************************\n");
	return 0;
}
Ejemplo n.º 2
0
resource_service_fn_t *rs_simple_create(void *arg, tbx_inip_file_t *kf, char *section)
{
    service_manager_t *ess = (service_manager_t *)arg;
    rs_simple_priv_t *rss;
    resource_service_fn_t *rs;

    //** Create the new RS list
    tbx_type_malloc_clear(rss, rs_simple_priv_t, 1);

    assert_result(apr_pool_create(&(rss->mpool), NULL), APR_SUCCESS);
    apr_thread_mutex_create(&(rss->lock), APR_THREAD_MUTEX_DEFAULT, rss->mpool);
    apr_thread_mutex_create(&(rss->update_lock), APR_THREAD_MUTEX_DEFAULT, rss->mpool);
    apr_thread_cond_create(&(rss->cond), rss->mpool);
    rss->rid_mapping = apr_hash_make(rss->mpool);
    rss->mapping_updates = apr_hash_make(rss->mpool);

    rss->ds = lookup_service(ess, ESS_RUNNING, ESS_DS);
    rss->da = lookup_service(ess, ESS_RUNNING, ESS_DA);

    //** Set the resource service fn ptrs
    tbx_type_malloc_clear(rs, resource_service_fn_t, 1);
    rs->priv = rss;
    rs->get_rid_config = rss_get_rid_config;
    rs->register_mapping_updates = rss_mapping_register;
    rs->unregister_mapping_updates = rss_mapping_unregister;
    rs->translate_cap_set = rss_translate_cap_set;
    rs->query_new = rs_query_base_new;
    rs->query_dup = rs_query_base_dup;
    rs->query_add = rs_query_base_add;
    rs->query_append = rs_query_base_append;
    rs->query_destroy = rs_query_base_destroy;
    rs->query_print = rs_query_base_print;
    rs->query_parse = rs_query_base_parse;
    rs->get_rid_value = rs_simple_get_rid_value;
    rs->data_request = rs_simple_request;
    rs->destroy_service = rs_simple_destroy;
    rs->type = RS_TYPE_SIMPLE;

    //** This is the file to use for loading the RID table
    rss->fname = tbx_inip_get_string(kf, section, "fname", NULL);
    rss->dynamic_mapping = tbx_inip_get_integer(kf, section, "dynamic_mapping", 0);
    rss->check_interval = tbx_inip_get_integer(kf, section, "check_interval", 300);
    rss->check_timeout = tbx_inip_get_integer(kf, section, "check_timeout", 60);
    rss->min_free = tbx_inip_get_integer(kf, section, "min_free", 100*1024*1024);

    //** Set the modify time to force a change
    rss->modify_time = 0;

    //** Load the RID table
    assert_result(_rs_simple_refresh(rs), 0);

    //** Launch the check thread
    tbx_thread_create_assert(&(rss->check_thread), NULL, rss_check_thread, (void *)rs, rss->mpool);

    return(rs);
}
Ejemplo n.º 3
0
void gop_dummy_init()
{
    //** Make the variables
    assert_result(apr_pool_create(&gd_pool, NULL), APR_SUCCESS);
    assert_result(apr_thread_mutex_create(&gd_lock, APR_THREAD_MUTEX_DEFAULT, gd_pool), APR_SUCCESS);
    assert_result(apr_thread_cond_create(&gd_cond, gd_pool), APR_SUCCESS);
    gd_stack = new_stack();

    //** and launch the thread
    thread_create_assert(&gd_thread, NULL, gd_thread_func, NULL, gd_pool);
}
Ejemplo n.º 4
0
void checkSmity(struct gameState *g_s){
    int test_result, real_result;
    test_result = numHandCards(g_s);

    real_result = cardEffect(smithy, 0, 0, 0, g_s, 0, 0); 
    if(!assert_result(real_result, 0))
        error_list[0]++;

    real_result = numHandCards(g_s);
    if(!assert_result(real_result, test_result+3-1))
        error_list[1]++;
}
Ejemplo n.º 5
0
void *gop_control_new(void *arg, int size)
{
    gop_control_t *shelf;
    int i;

    type_malloc_clear(shelf, gop_control_t, size);

    for (i=0; i<size; i++) {
        assert_result(apr_thread_mutex_create(&(shelf[i].lock), APR_THREAD_MUTEX_DEFAULT,_opque_pool), APR_SUCCESS);
        assert_result(apr_thread_cond_create(&(shelf[i].cond), _opque_pool), APR_SUCCESS);
    }

    return((void *)shelf);
}
Ejemplo n.º 6
0
void init_opque_system()
{
    log_printf(15, "init_opque_system: counter=%d\n", _opque_counter);
    if (atomic_inc(_opque_counter) == 0) {   //** Only init if needed
        assert_result(apr_pool_create(&_opque_pool, NULL), APR_SUCCESS);
        _gop_control = new_pigeon_coop("gop_control", 50, sizeof(gop_control_t), NULL, gop_control_new, gop_control_free);
        gop_dummy_init();
        atomic_init();
    }

}
Ejemplo n.º 7
0
gop_thread_pool_context_t *gop_tp_context_create(char *tp_name, int min_threads, int max_threads, int max_recursion_depth)
{
//  char buffer[1024];
    gop_thread_pool_context_t *tpc;
    apr_interval_time_t dt;
    int i;

    log_printf(15, "count=%d\n", _tp_context_count);

    tbx_type_malloc_clear(tpc, gop_thread_pool_context_t, 1);

    if (tbx_atomic_inc(_tp_context_count) == 0) {
        apr_pool_create(&_tp_pool, NULL);
        apr_thread_mutex_create(&_tp_lock, APR_THREAD_MUTEX_DEFAULT, _tp_pool);
        thread_pool_stats_init();
    }

    if (thread_local_depth_key == NULL) apr_threadkey_private_create(&thread_local_depth_key,_thread_pool_destructor, _tp_pool);
    tpc->pc = gop_hp_context_create(&_tp_base_portal);  //** Really just used for the submit

    default_thread_pool_config(tpc);
    if (min_threads > 0) tpc->min_threads = min_threads;
    if (max_threads > 0) tpc->max_threads = max_threads + 1;  //** Add one for the recursion depth starting offset being 1
    tpc->recursion_depth = max_recursion_depth + 1;  //** The min recusion normally starts at 1 so just slap an extra level and we don't care about 0|1 starting location
    tpc->max_concurrency = tpc->max_threads - tpc->recursion_depth;
    if (tpc->max_concurrency <= 0) {
        tpc->max_threads += 5 - tpc->max_concurrency;  //** MAke sure we have at least 5 threads for work
        tpc->max_concurrency = tpc->max_threads - tpc->recursion_depth;
        log_printf(0, "Specified max threads and recursion depth don't work. Adjusting max_threads=%d\n", tpc->max_threads);
    }

    dt = tpc->min_idle * 1000000;
    assert_result(apr_thread_pool_create(&(tpc->tp), tpc->min_threads, tpc->max_threads, _tp_pool), APR_SUCCESS);
    apr_thread_pool_idle_wait_set(tpc->tp, dt);
    apr_thread_pool_threshold_set(tpc->tp, 0);

    tpc->name = (tp_name == NULL) ? NULL : strdup(tp_name);
    tbx_atomic_set(tpc->n_ops, 0);
    tbx_atomic_set(tpc->n_completed, 0);
    tbx_atomic_set(tpc->n_started, 0);
    tbx_atomic_set(tpc->n_submitted, 0);
    tbx_atomic_set(tpc->n_running, 0);

    tbx_type_malloc(tpc->overflow_running_depth, int, tpc->recursion_depth);
    tbx_type_malloc(tpc->reserve_stack, tbx_stack_t *, tpc->recursion_depth);
    for (i=0; i<tpc->recursion_depth; i++) {
        tpc->overflow_running_depth[i] = -1;
        tpc->reserve_stack[i] = tbx_stack_new();
    }

    return(tpc);
}
Ejemplo n.º 8
0
/*
 * Class:     sun_awt_windows_ThemeReader
 * Method:    setWindowTheme
 * Signature: (Ljava/lang/String;)V
 */
JNIEXPORT void JNICALL Java_sun_awt_windows_ThemeReader_setWindowTheme
(JNIEnv *env, jclass klass, jstring subAppName) {

    LPCTSTR str = NULL;
    if (subAppName != NULL) {
        str = (LPCTSTR) JNU_GetStringPlatformChars(env, subAppName, NULL);
    }
    // We need to set the Window theme on the same theme that we opened it with.
    HRESULT hres = SetWindowTheme(AwtToolkit::GetInstance().GetHWnd(), str, NULL);
    assert_result(hres, env);
    if (subAppName != NULL) {
        JNU_ReleaseStringPlatformChars(env, subAppName, str);
    }
}
Ejemplo n.º 9
0
tbx_ns_t *tbx_ns_new()
{
    tbx_ns_t *ns = (tbx_ns_t *)malloc(sizeof(tbx_ns_t));

    if (ns == NULL) {
        log_printf(0, "new_netstream: Failed malloc!!\n");
        abort();
    }

    assert_result(apr_pool_create(&(ns->mpool), NULL), APR_SUCCESS);
    apr_thread_mutex_create(&(ns->read_lock), APR_THREAD_MUTEX_DEFAULT,ns->mpool);
    apr_thread_mutex_create(&(ns->write_lock), APR_THREAD_MUTEX_DEFAULT,ns->mpool);

    _ns_init(ns, 0);
    ns->id = ns->cuid = -1;

    return(ns);
}
Ejemplo n.º 10
0
int main(){

struct gameState g_s;
    int a_cards[10] = {adventurer, council_room, minion, great_hall, cutpurse, mine, gardens, sea_hag, tribute, smithy};
    int real_result;   

    printf("\n****Unit test for fullDeckCount()*****\n");
    initializeGame(2, a_cards, 3, &g_s);

	real_result = fullDeckCount(0, 0, &g_s);	

	if(!assert_result(real_result, 0))
		printf("FAILURE 1: The function is wrong\n");
	else
		printf("PASS 1: The function is correct\n");		

	printf("*********************************\n");
	return 0;
}
Ejemplo n.º 11
0
void run_server()
{
    zctx_t *ctx;
    void *socket;
    int i, n, nclient;
    char buf[256];
    char data[256];
    char client[256];

    ctx = new_context();
    socket = new_socket(ctx, ZMQ_ROUTER);
//  socket = new_socket(ctx, ZMQ_REP);
    assert_result(socket_bind(socket, host), 0);
//  assert_result(zmq_bind(socket, host), 0);

    log_printf(0, "my identity=%s\n", zsocket_identity(socket));

    i = 0;
    for (;;) {
        log_printf(0, "Waiting %d\n", i);
        nclient = zmq_recv(socket, client, sizeof(client), 0);
        client[nclient] = 0;
        log_printf(0, "From %s [%d]\n", client, nclient);
        n = zmq_recv(socket, buf, sizeof(buf), 0);
        buf[n] = 0;
        if (n != 0) log_printf(0, "Missing EMPTY frame! buf=%s\n", buf);
        n = zmq_recv(socket, buf, sizeof(buf), 0);
        buf[n] = 0;
        log_printf(0, "Got %s\n", buf);

        zmq_send(socket, client, nclient, ZMQ_SNDMORE);
        zmq_send(socket, NULL, 0, ZMQ_SNDMORE);
        snprintf(data, sizeof(buf), "(%s) World %d", buf, i);
        zmq_send(socket, data, strlen(data)+1, 0);
        i++;
    }

    destroy_context(ctx);
}
Ejemplo n.º 12
0
tbx_network_t *network_init()
{
    int i;
    tbx_network_t *net;

    //**** Allocate space for the data structures ***
    net = (tbx_network_t *)malloc(sizeof(tbx_network_t));FATAL_UNLESS(net != NULL);


    net->used_ports = 0;
    net->accept_pending = 0;
    net->monitor_index = 0;
    assert_result(apr_pool_create(&(net->mpool), NULL), APR_SUCCESS);
    apr_thread_mutex_create(&(net->ns_lock), APR_THREAD_MUTEX_DEFAULT,net->mpool);
    apr_thread_cond_create(&(net->cond), net->mpool);

    net->used_ports = 0;
    for (i=0; i<NETWORK_MON_MAX; i++) {
        net->nm[i].port = -1;
    }

    return(net);
}
Ejemplo n.º 13
0
portal_context_t *create_hportal_context(portal_fn_t *imp)
{
    portal_context_t *hpc;

//log_printf(1, "create_hportal_context: start\n");

    hpc = (portal_context_t *)malloc(sizeof(portal_context_t)); assert(hpc != NULL);
    memset(hpc, 0, sizeof(portal_context_t));


    assert_result(apr_pool_create(&(hpc->pool), NULL), APR_SUCCESS);
    hpc->table = apr_hash_make(hpc->pool); assert(hpc->table != NULL);

//log_printf(15, "create_hportal_context: hpc=%p hpc->table=%p\n", hpc, hpc->table);

    apr_thread_mutex_create(&(hpc->lock), APR_THREAD_MUTEX_DEFAULT, hpc->pool);

    hpc->fn = imp;
    hpc->next_check = time(NULL);
    hpc->count = 0;
    tbx_ns_timeout_set(&(hpc->dt), 1, 0);

    return(hpc);
}
Ejemplo n.º 14
0
/*
 * Class:     sun_awt_windows_ThemeReader
 * Method:    closeTheme
 * Signature: (J)V
 */
JNIEXPORT void JNICALL Java_sun_awt_windows_ThemeReader_closeTheme
(JNIEnv *env, jclass klass, jlong theme) {

    HRESULT hres = CloseThemeData((HTHEME)theme);
    assert_result(hres, env);
}
Ejemplo n.º 15
0
host_portal_t *create_hportal(portal_context_t *hpc, void *connect_context, char *hostport, int min_conn, int max_conn, apr_time_t dt_connect)
{
    host_portal_t *hp;

    log_printf(15, "create_hportal: hpc=%p\n", hpc);
    tbx_type_malloc_clear(hp, host_portal_t, 1);
    assert_result(apr_pool_create(&(hp->mpool), NULL), APR_SUCCESS);

    char host[sizeof(hp->host)];
    int port;
    char *hp2 = strdup(hostport);
    char *bstate;
    int fin;

    host[0] = '\0';

    strncpy(host, tbx_stk_string_token(hp2, HP_HOSTPORT_SEPARATOR, &bstate, &fin), sizeof(host)-1);
    host[sizeof(host)-1] = '\0';
    port = atoi(bstate);
    free(hp2);
    log_printf(15, "create_hportal: hostport: %s host=%s port=%d min=%d max=%d dt=" TT "\n", hostport, host, port, min_conn, max_conn, dt_connect);

    strncpy(hp->host, host, sizeof(hp->host)-1);
    hp->host[sizeof(hp->host)-1] = '\0';

    //** Check if we can resolve the host's IP address
    char in_addr[6];
    if (tbx_dnsc_lookup(host, in_addr, NULL) != 0) {
        log_printf(1, "create_hportal: Can\'t resolve host address: %s:%d\n", host, port);
        hp->invalid_host = 0;
//     hp->invalid_host = 1;
    } else {
        hp->invalid_host = 0;
    }

    hp->port = port;
    snprintf(hp->skey, sizeof(hp->skey), "%s", hostport);
    hp->connect_context = hpc->fn->dup_connect_context(connect_context);

    hp->context = hpc;
    hp->min_conn = min_conn;
    hp->max_conn = max_conn;
    hp->dt_connect = dt_connect;
    hp->sleeping_conn = 0;
    hp->workload = 0;
    hp->executing_workload = 0;
    hp->cmds_processed = 0;
    hp->n_conn = 0;
    hp->conn_list = tbx_stack_new();
    hp->closed_que = tbx_stack_new();
    hp->que = tbx_stack_new();
    hp->direct_list = tbx_stack_new();
    hp->pause_until = 0;
    hp->stable_conn = max_conn;
    hp->closing_conn = 0;
    hp->failed_conn_attempts = 0;
    hp->successful_conn_attempts = 0;
    hp->abort_conn_attempts = hpc->abort_conn_attempts;

    apr_thread_mutex_create(&(hp->lock), APR_THREAD_MUTEX_DEFAULT, hp->mpool);
    apr_thread_cond_create(&(hp->cond), hp->mpool);

    return(hp);
}
Ejemplo n.º 16
0
resource_service_fn_t *rs_remote_server_create(void *arg, tbx_inip_file_t *fd, char *section)
{
    service_manager_t *ess = (service_manager_t *)arg;
    resource_service_fn_t *rs;
    rs_remote_server_priv_t *rsrs;
    rs_create_t *rs_create;
    mq_command_table_t *ctable;
    char *stype, *ctype;

    if (section == NULL) section = "rs_remote_server";

    tbx_type_malloc_clear(rs, resource_service_fn_t, 1);
    tbx_type_malloc_clear(rsrs, rs_remote_server_priv_t, 1);
    rs->priv = (void *)rsrs;

    //** Make the locks and cond variables
    assert_result(apr_pool_create(&(rsrs->mpool), NULL), APR_SUCCESS);
    apr_thread_mutex_create(&(rsrs->lock), APR_THREAD_MUTEX_DEFAULT, rsrs->mpool);
    apr_thread_cond_create(&(rsrs->cond), rsrs->mpool);

    rsrs->pending = tbx_stack_new();
    memset(&(rsrs->my_map_version), 0, sizeof(rsrs->my_map_version));
    memset(&(rsrs->notify_map_version), 0, sizeof(rsrs->notify_map_version));
    rsrs->notify_map_version.lock = rsrs->lock;
    rsrs->notify_map_version.cond = rsrs->cond;

    //** Get the host name we bind to
    rsrs->hostname= tbx_inip_get_string(fd, section, "address", NULL);

    //** Start the child RS.   The update above should have dumped a RID config for it to load
    stype = tbx_inip_get_string(fd, section, "rs_local", NULL);
    if (stype == NULL) {  //** Oops missing child RS
        log_printf(0, "ERROR: Mising child RS  section=%s key=rs_local!\n", section);
        tbx_log_flush();
        free(stype);
        abort();
    }

    //** and load it
    ctype = tbx_inip_get_string(fd, stype, "type", RS_TYPE_SIMPLE);
    rs_create = lookup_service(ess, RS_SM_AVAILABLE, ctype);
    rsrs->rs_child = (*rs_create)(ess, fd, stype);
    if (rsrs->rs_child == NULL) {
        log_printf(1, "ERROR loading child RS!  type=%s section=%s\n", ctype, stype);
        tbx_log_flush();
        abort();
    }
    free(ctype);
    free(stype);

    //** Get the MQC
    rsrs->mqc = lookup_service(ess, ESS_RUNNING, ESS_MQ); assert(rsrs->mqc != NULL);

    //** Make the server portal
    rsrs->server_portal = mq_portal_create(rsrs->mqc, rsrs->hostname, MQ_CMODE_SERVER);
    ctable = mq_portal_command_table(rsrs->server_portal);
    mq_command_set(ctable, RSR_GET_RID_CONFIG_KEY, RSR_GET_RID_CONFIG_SIZE, rs, rsrs_rid_config_cb);
    mq_command_set(ctable, RSR_GET_UPDATE_CONFIG_KEY, RSR_GET_UPDATE_CONFIG_SIZE, rs, rsrs_rid_config_cb);
    mq_command_set(ctable, RSR_ABORT_KEY, RSR_ABORT_SIZE, rs, rsrs_abort_cb);
    mq_portal_install(rsrs->mqc, rsrs->server_portal);

    //** Launch the config changes thread
    tbx_thread_create_assert(&(rsrs->monitor_thread), NULL, rsrs_monitor_thread, (void *)rs, rsrs->mpool);

    //** Set up the fn ptrs.  This is just for syncing the rid configuration and state
    //** so very little is implemented
    rs->destroy_service = rs_remote_server_destroy;

    rs->type = RS_TYPE_REMOTE_SERVER;

    return(rs);
}
Ejemplo n.º 17
0
int main(int argc, char **argv)
{
    int64_t block_size, buf_size, state_offset;
    int64_t fsize1, fsize2, max_size, cpos, len, bad_bytes, bad_groups;
    int start_option, i, state;
    char *fname1, *fname2;
    char *buf1, *buf2;
    FILE *fd1, *fd2;

    block_size = 64 *1024;
    buf_size = 20 *1024*1024;

    if (argc < 3) {
        printf("\n");
        printf("ldiff [-b block_size] [-s buffer_size] file1 file2\n");
        printf("     -b block_size   Block size for matching to cache page boundaries.  Defaults to " I64T ".  Can use units.\n", block_size);
        printf("     -s buffer_size  Buffer size used in the comparison. This is divided in 1/2 for each buffer. Defaults to " I64T ". Cant use units.\n", buf_size);
        printf("\n");
        return(1);
    }

    //*** Parse the args
    i=1;
    if (argc > 1) {
        do {
            start_option = i;
            if (strcmp(argv[i], "-b") == 0) { //** Block size
                i++;
                block_size = string_get_integer(argv[i]);
                i++;
            } else if (strcmp(argv[i], "-s") == 0) { //** Buffer size
                i++;
                buf_size = string_get_integer(argv[i]);
                i++;
            }
        } while ((start_option < i) && (i<argc));
    }


    if ((argc-i) < 2) {
        printf("Missing filenames!\n");
        return(1);
    }

    //** Open the files and get their sizes
    fname1 = argv[i];
    fname2 = argv[i+1];
    fd1 = fopen(fname1, "r"); assert(fd1 != NULL);
    fd2 = fopen(fname2, "r"); assert(fd2 != NULL);

    fseek(fd1, 0, SEEK_END);
    fseek(fd2, 0, SEEK_END);
    fsize1 = ftell(fd1);
    fsize2 = ftell(fd2);
    fseek(fd1, 0, SEEK_SET);
    fseek(fd2, 0, SEEK_SET);

    //** Print a summary of options
    printf("File 1: %s  (" I64T " bytes)\n", fname1, fsize1);
    printf("File 2: %s  (" I64T " bytes)\n", fname2, fsize2);
    if (fsize1 != fsize2) printf("WARNING:  File sizes differ!!!!!\n");
    printf("Block size: " I64T "\n", block_size);
    printf("Buffer size: " I64T "\n", buf_size);

    buf_size /= 2;  //** It's split between the 2 buffers

    type_malloc(buf1, char, buf_size);
    type_malloc(buf2, char, buf_size);

    max_size = (fsize1 > fsize2) ? fsize2 : fsize1;

    printf("\n");
    printf("Printing comparision breakdown -- Single byte matches are suppressed (max_size=" I64T ")\n", max_size);

    state = 0;
    state_offset = 0;
    bad_bytes = bad_groups = 0;
    for (cpos=0; cpos < max_size; cpos += buf_size) {
        len = ((cpos+buf_size) < max_size) ? buf_size : max_size - cpos;
        assert_result(fread(buf1, 1, len, fd1), len);
        assert_result(fread(buf2, 1, len, fd2), len);

        compare_buffers(buf1, buf2, len, cpos, &bad_bytes, &bad_groups, block_size, &state, &state_offset, max_size);
    }

    printf("\n");
    printf("Bad bytes: " I64T " Bad groups: " I64T "\n", bad_bytes, bad_groups);

    free(buf1);
    free(buf2);

    fclose(fd1);
    fclose(fd2);

    i = ((bad_bytes > 0) || (fsize1 != fsize2)) ? 1 : 0;
    return(i);
}
Ejemplo n.º 18
0
int main(int argc, char **argv)
{
    int start_option, i, watch, summary, base;
    rs_mapping_notify_t notify, me;
    apr_time_t dt;
    char *config;

//printf("argc=%d\n", argc);

    if (argc < 2) {
        printf("\n");
        printf("lio_rs LIO_COMMON_OPTIONS [-w] [-b2 | -b10] [-s | -f]\n");
        lio_print_options(stdout);
        printf("    -w                 - Watch for RID configuration changes. Press ^C to exit\n");
        printf("    -b2                - Use powers of 2 for units(default)\n");
        printf("    -b10               - Use powers of 10 for units\n");
        printf("    -s                 - Print a RID space usage summary\n");
        printf("    -f                 - Print the full RID configuration\n");
        return(1);
    }

    lio_init(&argc, &argv);

    watch = 0;
    summary = 0;
    base = 1024;

    i=1;
    do {
        start_option = i;

        if (strcmp(argv[i], "-w") == 0) { //** Watch for any RID changes
            i++;
            watch = 1;
        } else if (strcmp(argv[i], "-s") == 0) {  //** Print space summary instead of full conifg
            i++;
            summary = 1;
        } else if (strcmp(argv[i], "-b2") == 0) {  //** base-2 units
            i++;
            base = 1024;
        } else if (strcmp(argv[i], "-b10") == 0) {  //** base-10 units
            i++;
            base = 1000;
        }
    } while ((start_option < i) && (i<argc));

    //** Make the APR stuff
    assert_result(apr_pool_create(&mpool, NULL), APR_SUCCESS);
    apr_thread_mutex_create(&lock, APR_THREAD_MUTEX_DEFAULT, mpool);
    apr_thread_cond_create(&cond, mpool);

//if (watch == 1) {
//  printf("Sleeping for 60s\n"); fflush(stdout);
//  sleep(60);
//  printf("Woken up\n"); fflush(stdout);
//}

    memset(&notify, 0, sizeof(notify));
    notify.lock = lock;
    notify.cond = cond;
    me = notify;
    me.map_version = 1; //** This triggers the initial load
    rs_register_mapping_updates(lio_gc->rs, &notify);
    dt = apr_time_from_sec(1);
    do {
        //** Check for an update
        apr_thread_mutex_lock(lock);
        if (watch == 1) apr_thread_cond_timedwait(notify.cond, notify.lock, dt);
        i = ((me.map_version != notify.map_version) || (me.status_version != notify.status_version)) ? 1 : 0;
        me = notify;
        apr_thread_mutex_unlock(lock);

        if (i != 0) {
            config = rs_get_rid_config(lio_gc->rs);

            printf("Map Version: %d  Status Version: %d\n", me.map_version, me.status_version);
            printf("--------------------------------------------------------------------------------------------------\n");

            if (config == NULL) {
                printf("ERROR NULL config!\n");
            } else if (summary == 1) {
                print_rid_summary(config, base);
            } else {
                printf("%s", config);
            }

            printf("--------------------------------------------------------------------------------------------------\n");

            if (config != NULL) free(config);
        }
    } while (watch == 1);

    info_printf(lio_ifd, 5, "BEFORE unregister\n");
    tbx_info_flush(lio_ifd);
    rs_unregister_mapping_updates(lio_gc->rs, &notify);
    info_printf(lio_ifd, 5, "AFTER unregister\n");
    tbx_info_flush(lio_ifd);

    //** Cleanup
    apr_pool_destroy(mpool);

//  info_printf(lio_ifd, 5, "AFTER shutdown\n"); tbx_info_flush(lio_ifd);
    lio_shutdown();

    return(0);
}