forked from cory/tildefriends
clang-format the source. Not exactly how I want it, but automated is better than perfect.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4845 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -23,8 +23,7 @@ static void _tf_ssb_import_add_app(tf_ssb_t* ssb, const char* user, const char*
|
||||
sqlite3* db = tf_ssb_acquire_db_writer(ssb);
|
||||
if (sqlite3_prepare(db, "SELECT value FROM properties WHERE id = ?1 AND key = 'apps'", -1, &statement, NULL) == SQLITE_OK)
|
||||
{
|
||||
if (sqlite3_bind_text(statement, 1, user, -1, NULL) == SQLITE_OK &&
|
||||
sqlite3_step(statement) == SQLITE_ROW)
|
||||
if (sqlite3_bind_text(statement, 1, user, -1, NULL) == SQLITE_OK && sqlite3_step(statement) == SQLITE_ROW)
|
||||
{
|
||||
const char* json = (const char*)sqlite3_column_text(statement, 0);
|
||||
apps = JS_ParseJSON(context, json, strlen(json), NULL);
|
||||
@ -71,9 +70,8 @@ static void _tf_ssb_import_add_app(tf_ssb_t* ssb, const char* user, const char*
|
||||
const char* text = JS_ToCString(context, json);
|
||||
if (sqlite3_prepare(db, "INSERT OR REPLACE INTO properties (id, key, value) VALUES (?1, 'apps', ?2)", -1, &statement, NULL) == SQLITE_OK)
|
||||
{
|
||||
if (sqlite3_bind_text(statement, 1, user, -1, NULL) == SQLITE_OK &&
|
||||
sqlite3_bind_text(statement, 2, text, -1, NULL) == SQLITE_OK &&
|
||||
sqlite3_step(statement) == SQLITE_OK)
|
||||
if (sqlite3_bind_text(statement, 1, user, -1, NULL) == SQLITE_OK && sqlite3_bind_text(statement, 2, text, -1, NULL) == SQLITE_OK &&
|
||||
sqlite3_step(statement) == SQLITE_OK)
|
||||
{
|
||||
}
|
||||
sqlite3_finalize(statement);
|
||||
@ -166,12 +164,10 @@ static bool _tf_ssb_register_app(tf_ssb_t* ssb, const char* user, const char* ap
|
||||
sqlite3* db = tf_ssb_acquire_db_writer(ssb);
|
||||
if (sqlite3_prepare(db, "INSERT OR REPLACE INTO properties (id, key, value) VALUES (?1, 'path:' || ?2, ?3)", -1, &statement, NULL) == SQLITE_OK)
|
||||
{
|
||||
if (sqlite3_bind_text(statement, 1, user, -1, NULL) == SQLITE_OK &&
|
||||
sqlite3_bind_text(statement, 2, app, -1, NULL) == SQLITE_OK &&
|
||||
sqlite3_bind_text(statement, 3, id, -1, NULL) == SQLITE_OK &&
|
||||
sqlite3_step(statement) == SQLITE_DONE)
|
||||
if (sqlite3_bind_text(statement, 1, user, -1, NULL) == SQLITE_OK && sqlite3_bind_text(statement, 2, app, -1, NULL) == SQLITE_OK &&
|
||||
sqlite3_bind_text(statement, 3, id, -1, NULL) == SQLITE_OK && sqlite3_step(statement) == SQLITE_DONE)
|
||||
{
|
||||
result = sqlite3_changes(db) != 0;
|
||||
result = sqlite3_changes(db) != 0;
|
||||
}
|
||||
sqlite3_finalize(statement);
|
||||
}
|
||||
@ -242,8 +238,7 @@ void tf_ssb_import(tf_ssb_t* ssb, const char* user, const char* path)
|
||||
size_t len = strlen(path) + strlen(ent.name) + 2;
|
||||
char* full_path = tf_malloc(len);
|
||||
snprintf(full_path, len, "%s/%s", path, ent.name);
|
||||
if (strlen(ent.name) > strlen(".json") &&
|
||||
strcasecmp(ent.name + strlen(ent.name) - strlen(".json"), ".json") == 0)
|
||||
if (strlen(ent.name) > strlen(".json") && strcasecmp(ent.name + strlen(ent.name) - strlen(".json"), ".json") == 0)
|
||||
{
|
||||
_tf_ssb_import_app_json(ssb, tf_ssb_get_loop(ssb), tf_ssb_get_context(ssb), user, full_path);
|
||||
}
|
||||
@ -290,8 +285,7 @@ static void _tf_ssb_import_recursive_add_files_from_zip(tf_ssb_t* ssb, unzFile z
|
||||
unz_file_info64 info = { 0 };
|
||||
if (unzGetCurrentFileInfo64(zip, &info, file_path, sizeof(file_path), NULL, 0, NULL, 0) == UNZ_OK)
|
||||
{
|
||||
if (strncmp(file_path, root, strlen(root)) == 0 &&
|
||||
file_path[strlen(root)] == '/')
|
||||
if (strncmp(file_path, root, strlen(root)) == 0 && file_path[strlen(root)] == '/')
|
||||
{
|
||||
size_t size = 0;
|
||||
char* blob = _tf_ssb_import_read_current_file_from_zip(zip, &size);
|
||||
@ -306,8 +300,7 @@ static void _tf_ssb_import_recursive_add_files_from_zip(tf_ssb_t* ssb, unzFile z
|
||||
tf_free(blob);
|
||||
}
|
||||
}
|
||||
}
|
||||
while (unzGoToNextFile(zip) == UNZ_OK);
|
||||
} while (unzGoToNextFile(zip) == UNZ_OK);
|
||||
}
|
||||
}
|
||||
|
||||
@ -366,10 +359,8 @@ void tf_ssb_import_from_zip(tf_ssb_t* ssb, const char* zip_path, const char* use
|
||||
unz_file_info64 info = { 0 };
|
||||
if (unzGetCurrentFileInfo64(zip, &info, file_path, sizeof(file_path), NULL, 0, NULL, 0) == UNZ_OK)
|
||||
{
|
||||
if (strncmp(file_path, path, strlen(path)) == 0 &&
|
||||
!strchr(file_path + strlen(path) + 1, '/') &&
|
||||
strlen(file_path) > strlen(".json") &&
|
||||
strcasecmp(file_path + strlen(file_path) - strlen(".json"), ".json") == 0)
|
||||
if (strncmp(file_path, path, strlen(path)) == 0 && !strchr(file_path + strlen(path) + 1, '/') && strlen(file_path) > strlen(".json") &&
|
||||
strcasecmp(file_path + strlen(file_path) - strlen(".json"), ".json") == 0)
|
||||
{
|
||||
unz_file_pos pos = { 0 };
|
||||
unzGetFilePos(zip, &pos);
|
||||
@ -377,8 +368,7 @@ void tf_ssb_import_from_zip(tf_ssb_t* ssb, const char* zip_path, const char* use
|
||||
unzGoToFilePos(zip, &pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
while (unzGoToNextFile(zip) == UNZ_OK);
|
||||
} while (unzGoToNextFile(zip) == UNZ_OK);
|
||||
}
|
||||
unzClose(zip);
|
||||
}
|
||||
|
Reference in New Issue
Block a user