Ejemplo n.º 1
0
int cmd_modify_count(int mode, ibp_connect_context_t *cc, char **argv, int argc)
{
    ibp_cap_t *cap;
    ibp_op_t op;
    int captype;
    int err, timeout;

    if (argc < 3) {
        printf("cmd_modify_count: Not enough parameters.  Received %d need 3\n", argc);
        return(0);
    }


    cap = argv[0];
    captype = scan_map(argv[1], _ibp_captype_map, table_len(_ibp_captype_map));
    timeout = atoi(argv[2]);

    if (captype < 0) {
        printf("cmd_modify_count: Bad captype: %s\n", argv[1]);
        exit(1);
    }

    set_ibp_modify_count_op(&op, cap, mode, captype, timeout, NULL, cc);
    err = ibp_sync_command(&op);
    if (err != IBP_OK) {
        printf("cmd_modify_count: Error %s(%d)\n", _ibp_error_map[-err], err);
        return(0);
    }

    return(0);
}
Ejemplo n.º 2
0
void store_attr(ibp_attributes_t *attr, char **argv)
{
    int type, rel, duration;

    rel = scan_map(argv[0], _ibp_rel_map, table_len(_ibp_rel_map));
    type = scan_map(argv[1], _ibp_type_map, table_len(_ibp_type_map));
    duration = atoi(argv[2]);
    if (rel < 0) {
        printf("store_attr: Bad rel type: %s\n", argv[0]);
        exit(1);
    }
    if (type < 0) {
        printf("store_attr: Bad type type: %s\n", argv[1]);
        exit(1);
    }

    set_ibp_attributes(attr, time(NULL) + duration, rel, type);
}
Ejemplo n.º 3
0
void print_ibp_tables()
{
    printf("sizeof(map)=" ST " sizeof(char *)=" ST " table_len=" ST "\n", sizeof(_ibp_command_map), sizeof(char *), table_len(_ibp_command_map));
    printf("\n");
    printf("IBP Commands\n");
    printf("------------------------------------------\n");
    print_table(_ibp_command_map, 1, table_len(_ibp_command_map));
    printf("\n");

    printf("Options for IBP_MANAGE\n");
    printf("------------------------------------------\n");
    print_table(_ibp_subcmd_map, 1, table_len(_ibp_subcmd_map));
    printf("\n");

    printf("Options for IBP_STATUS\n");
    printf("------------------------------------------\n");
    print_table(_ibp_st_map, 1, table_len(_ibp_st_map));
    printf("\n");

    printf("Capability types\n");
    printf("------------------------------------------\n");
    print_table(_ibp_captype_map, 1, table_len(_ibp_captype_map));
    printf("\n");

    printf("Allocation reliability\n");
    printf("------------------------------------------\n");
    print_table(_ibp_rel_map, 1, table_len(_ibp_rel_map));
    printf("\n");

    printf("Allocation types\n");
    printf("------------------------------------------\n");
    print_table(_ibp_type_map, 1, table_len(_ibp_type_map));
    printf("\n");

    printf("Connection types\n");
    printf("------------------------------------------\n");
    print_table(_ibp_ctype_map, 1, table_len(_ibp_ctype_map));
    printf("\n");

    printf("Error messages\n");
    printf("------------------------------------------\n");
    print_table(_ibp_error_map, -1, table_len(_ibp_error_map));
    printf("\n");
}
Ejemplo n.º 4
0
static qbase_table *
table_create(qbase_sta *sta)	{
	int tblen = 0, i = 1;
	const char *keystr = NULL;
	qbase_table *t = NULL;
	if(!lua_istable(sta->L, -1))
		return NULL;
	tblen = table_len(sta);
	t = (qbase_table*)malloc(sizeof(qbase_table));
	t->fieldnames = (char**)malloc(sizeof(char*)*(tblen+1));
	t->field_count = tblen;
	// TODO: set table name in fieldnames[0]
	lua_pushnil(sta->L);
	while(0 != lua_next(sta->L, -2))	{
		keystr = lua_tostring(sta->L, -2);
		t->fieldnames[i] = (char*)malloc(strlen(keystr)+1);
		strcpy(t->fieldnames[i], keystr);
		lua_pop(sta->L, 1);
		i++;
	}
	return t;
}
Ejemplo n.º 5
0
int cmd_modify_alloc(ibp_connect_context_t *cc, char **argv, int argc)
{
    ibp_cap_t *cap;
    ibp_op_t op;
    int rel;
    size_t size;
    time_t duration;
    int err, timeout;

    if (argc < 5) {
        printf("cmd_modify_alloc: Not enough parameters.  Received %d need 5\n", argc);
        return(0);
    }

    cap = argv[0];
    size = atol(argv[1]);
    duration = atol(argv[2]);
    rel = scan_map(argv[3], _ibp_rel_map, table_len(_ibp_rel_map));
    timeout = atoi(argv[4]);

    if (rel < 0) {
        printf("cmd_modify_alloc: Bad reliability: %s\n", argv[3]);
        exit(1);
    }

    timeout = atoi(argv[4]);

    set_ibp_modify_alloc_op(&op, cap, size, duration, rel, timeout, NULL, cc);
    err = ibp_sync_command(&op);
    if (err != IBP_OK) {
        printf("cmd_modify_alloc: Error %s(%d)\n", _ibp_error_map[-err], err);
        return(0);
    }

    return(0);
}