fix: allow program to compile
This commit is contained in:
		
							parent
							
								
									0103b0b2ff
								
							
						
					
					
						commit
						6a2b94ef1c
					
				
					 1 changed files with 4 additions and 70 deletions
				
			
		| 
						 | 
				
			
			@ -26,14 +26,11 @@ db_update_insert(macro_t *macro, sqlite3_stmt *stmt)
 | 
			
		|||
 | 
			
		||||
    sqlite3_finalize(stmt);
 | 
			
		||||
 | 
			
		||||
    free(periods_blob);
 | 
			
		||||
 | 
			
		||||
    return rc != SQLITE_DONE;
 | 
			
		||||
}
 | 
			
		||||
static macro_t*
 | 
			
		||||
macro_db_select_mapper(sqlite3_stmt *stmt)
 | 
			
		||||
{
 | 
			
		||||
    const uint16_t *periods_blob;
 | 
			
		||||
    macro_t *new_macro = malloc(sizeof(macro_t));
 | 
			
		||||
    for(int i = 0; i < sqlite3_column_count(stmt); i++)
 | 
			
		||||
    {
 | 
			
		||||
| 
						 | 
				
			
			@ -190,7 +187,6 @@ macro_is_protected(macro_t *macro)
 | 
			
		|||
void
 | 
			
		||||
macro_free(macro_t *macro)
 | 
			
		||||
{
 | 
			
		||||
    free(macro->periods);
 | 
			
		||||
    free(macro);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -204,21 +200,6 @@ macro_free_list(macro_t **macros)
 | 
			
		|||
    free(macros);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint16_t*
 | 
			
		||||
macro_periods_to_blob(macro_t *macro)
 | 
			
		||||
{
 | 
			
		||||
    uint16_t *blob = malloc(sizeof(uint16_t) * ((macro->periods_count * 2) + 1));
 | 
			
		||||
 | 
			
		||||
    blob[0] = macro->periods_count;
 | 
			
		||||
 | 
			
		||||
    for(int i = 0; i < macro->periods_count; i++)
 | 
			
		||||
    {
 | 
			
		||||
        blob[(i * 2) + 1] = macro->periods[i].start;
 | 
			
		||||
        blob[(i * 2) + 2] = macro->periods[i].end;
 | 
			
		||||
    }
 | 
			
		||||
    return blob;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
cJSON*
 | 
			
		||||
macro_to_json(macro_t *macro)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -233,7 +214,7 @@ macro_to_json(macro_t *macro)
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    char uuid_str[UUID_STR_LEN];
 | 
			
		||||
    macro_uid_unparse(macro->uid, uuid_str);
 | 
			
		||||
    uuid_unparse(macro->uid, uuid_str);
 | 
			
		||||
 | 
			
		||||
    LOGGER_DEBUG("JSONifying macro %s\n", uuid_str);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -256,7 +237,7 @@ macro_to_json(macro_t *macro)
 | 
			
		|||
    cJSON_AddItemToObject(json, "id", json_id);
 | 
			
		||||
 | 
			
		||||
    cJSON *json_tags = cJSON_CreateArray();
 | 
			
		||||
    int *tags_ids = junction_tag_get_tags_for_macro_id(macro->id);
 | 
			
		||||
    int *tags_ids = NULL; //junction_tag_get_tags_for_macro_id(macro->id);
 | 
			
		||||
    if(tags_ids != NULL)
 | 
			
		||||
    {
 | 
			
		||||
        for(int i = 0; tags_ids[i] != 0; ++i)
 | 
			
		||||
| 
						 | 
				
			
			@ -336,7 +317,7 @@ macro_t*
 | 
			
		|||
macro_get_by_uid_or_off(uuid_t uid)
 | 
			
		||||
{
 | 
			
		||||
    char uuid_str[UUID_STR_LEN];
 | 
			
		||||
    macro_uid_unparse(uid, uuid_str);
 | 
			
		||||
    uuid_unparse(uid, uuid_str);
 | 
			
		||||
    LOGGER_DEBUG("getting macro [uid=%s] or off from database\n", uuid_str);
 | 
			
		||||
    sqlite3_stmt *stmt;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -364,7 +345,7 @@ macro_t*
 | 
			
		|||
macro_get_by_uid(uuid_t uid)
 | 
			
		||||
{
 | 
			
		||||
    char uuid_str[UUID_STR_LEN];
 | 
			
		||||
    macro_uid_unparse(uid, uuid_str);
 | 
			
		||||
    uuid_unparse(uid, uuid_str);
 | 
			
		||||
    LOGGER_DEBUG("getting macro [uid=%s] from database\n", uuid_str);
 | 
			
		||||
    sqlite3_stmt *stmt;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -402,50 +383,3 @@ macro_get_all()
 | 
			
		|||
    return macro_db_select(stmt);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
macro_uid_parse(const char *uid_str, uuid_t result)
 | 
			
		||||
{
 | 
			
		||||
    if(strcmp("off", uid_str) == 0)
 | 
			
		||||
    {
 | 
			
		||||
        memset(result, 0, sizeof(uuid_t));
 | 
			
		||||
        memcpy(result, "off", 3);
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
    if(strcmp("on", uid_str) == 0)
 | 
			
		||||
    {
 | 
			
		||||
        memset(result, 0, sizeof(uuid_t));
 | 
			
		||||
        memcpy(result, "on", 2);
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if(uuid_parse(uid_str, result))
 | 
			
		||||
    {
 | 
			
		||||
        return 1;
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
macro_uid_unparse(const uuid_t uid, char *result)
 | 
			
		||||
{
 | 
			
		||||
    uuid_t tmp_uuid;
 | 
			
		||||
 | 
			
		||||
    memset(tmp_uuid, 0, sizeof(uuid_t));
 | 
			
		||||
    memcpy(tmp_uuid, "off", 3);
 | 
			
		||||
    if(uuid_compare(uid, tmp_uuid) == 0)
 | 
			
		||||
    {
 | 
			
		||||
        strcpy(result, "off");
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    memset(tmp_uuid, 0, sizeof(uuid_t));
 | 
			
		||||
    memcpy(tmp_uuid, "on", 2);
 | 
			
		||||
    if(uuid_compare(uid, tmp_uuid) == 0)
 | 
			
		||||
    {
 | 
			
		||||
        strcpy(result, "on");
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    uuid_unparse(uid, result);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue