Example #1
0
int DB_find(const char *url)
{
    bstring data = NULL;
    bstring line = bfromcstr(url);
    int res = -1;

    data = DB_load();
    check(data, "Failed to load: %s", DB_FILE);

    if (binstr(data, 0, line) == BSTR_ERR) {
        res = 0;
    } else {
        res = 1;
    }

error: // fallthrough
    if (data) {
        bdestroy(data);
    }
    if (line) {
        bdestroy(line);
    }

    return res;
}
Example #2
0
File: db.c Project: ajdecon/play
int DB_list() {
    bstring data = DB_load();
    check(data, "Failed to load data: %s", DB_FILE);
    printf("%s", bdata(data));
    bdestroy(data);
    return 0;
error:
    return -1;
}
Example #3
0
int DB_list()
{
    bstring data = DB_load();
    assert(data != NULL);
    
    printf("%s", bdata(data));
    bdestroy(data);
    
    return 0;
}
Example #4
0
int DB_list()
{
	bstring data = DB_load();
	check(data, "Failed to read load: %s", DB_FILE);
	printf("devpkg database:\n%s", bdata(data));
	bdestroy(data);
	return 0;
error:
	return -1;
}
Example #5
0
int DB_list()
{
	bstring data = DB_load();
	check(data, "Failed to read load: %s", DB_FILE);
	// bdata(data)即data->data
	printf("%s", bdata(data));
	bdestroy(data);
	return 0;

  error:
	return -1;
}
Example #6
0
int DB_list()
{
	bstring data = DB_load(DB_FILE);
	check(data, "Could not load db %s.", DB_FILE);

	printf("%s", bdata(data));
	bdestroy(data);
	return 0;

error:
	return -1;
}
Example #7
0
int DB_find(char *url)
{
	bstring data = NULL;
	bstring line = bfromcstr(url);
	int res = -1;

	data = DB_load(DB_FILE);
	check(data, "Could not load %s.", DB_FILE);

	if(binstr(data, 0, line) == BSTR_ERR){
		res = 0;
	} else {
		res = 1;
	}

error: // fallthrough
	if(data) bdestroy(data);
	if(line) bdestroy(line);

	return res;
}
Example #8
0
int DB_find(const char *url)
{
	bstring data = NULL;
	bstring line = bfromcstr(url);
	int res = -1;

	data = DB_load(DB_FILE);
	check(data, "Failed to load: %s", DB_FILE);
	// 从0开始,在data中找line
	if(binstr(data, 0, line) == BSTR_ERR)
	{
		res = 0;
	}
	else
	{
		res = 1;
	}

  error:
	if(data) bdestroy(data);
	if(line) bdestroy(line);

	return res;
}
Example #9
0
int DB_find(const char *url, bool *found)
{
    assert(url != NULL);
    assert(found != NULL);
    
    bstring data = NULL;
    bstring line = bfromcstr(url);
    
    int rc = 0;
    
    data = DB_load();
    assert(data != NULL);
    
    if (binstr(data, 0, line) == BSTR_ERR) {
        *found = false;
    } else {
        *found = true;
    }

    bdestroy(data);
    bdestroy(line);    

    return rc;
}