Skip to content

Commit

Permalink
address remaining todos
Browse files Browse the repository at this point in the history
  • Loading branch information
goatshriek committed Dec 3, 2023
1 parent 3ed2a7a commit 82a229e
Showing 23 changed files with 114 additions and 19 deletions.
4 changes: 4 additions & 0 deletions include/private/config/locale/bg-bg.h
Original file line number Diff line number Diff line change
@@ -229,6 +229,10 @@ ARG_NAME " беше NULL"
# define L10N_SOURCE_REGISTRATION_TRANSACTION_DESCRIPTION_W \
L"Stumpless registration of Windows Event Log Source"

// todo translate
# define L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( PARAM ) \
"could not bind " PARAM " to the statement"

// todo translate
# define L10N_SQLITE3_BUSY_ERROR_MESSAGE \
"the database was busy and could not complete the transaction"
4 changes: 4 additions & 0 deletions include/private/config/locale/bn-in.h
Original file line number Diff line number Diff line change
@@ -215,6 +215,10 @@ ARG_NAME " NULL ছিল"
# define L10N_SOURCE_REGISTRATION_TRANSACTION_DESCRIPTION_W \
L"উইন্ডোজ ইভেন্ট লগ সোর্সের স্টাম্পলেস রেজিস্ট্রেশন"

// todo translate
# define L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( PARAM ) \
"could not bind " PARAM " to the statement"

// todo translate
# define L10N_SQLITE3_BUSY_ERROR_MESSAGE \
"the database was busy and could not complete the transaction"
4 changes: 4 additions & 0 deletions include/private/config/locale/cz-cz.h
Original file line number Diff line number Diff line change
@@ -221,6 +221,10 @@ ARG_NAME " měl hodnotu NULL"
# define L10N_SOURCE_REGISTRATION_TRANSACTION_DESCRIPTION_W \
L"Stumpless registration of Windows Event Log Source"

// todo translate
# define L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( PARAM ) \
"could not bind " PARAM " to the statement"

// todo translate
# define L10N_SQLITE3_BUSY_ERROR_MESSAGE \
"the database was busy and could not complete the transaction"
4 changes: 4 additions & 0 deletions include/private/config/locale/da-dk.h
Original file line number Diff line number Diff line change
@@ -206,6 +206,10 @@ ARG_NAME " var NULL"
# define L10N_SOURCE_REGISTRATION_TRANSACTION_DESCRIPTION_W \
"Stumpless registration af Windows Event Log kilde"

// todo translate
# define L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( PARAM ) \
"could not bind " PARAM " to the statement"

// todo translate
# define L10N_SQLITE3_BUSY_ERROR_MESSAGE \
"the database was busy and could not complete the transaction"
4 changes: 4 additions & 0 deletions include/private/config/locale/de-de.h
Original file line number Diff line number Diff line change
@@ -237,6 +237,10 @@ ARG_NAME " war NULL"
# define L10N_SOURCE_REGISTRATION_TRANSACTION_DESCRIPTION_W \
L"Stumpless registration of Windows Event Log Source"

// todo translate
# define L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( PARAM ) \
"could not bind " PARAM " to the statement"

// todo translate
# define L10N_SQLITE3_BUSY_ERROR_MESSAGE \
"the database was busy and could not complete the transaction"
4 changes: 4 additions & 0 deletions include/private/config/locale/el-gr.h
Original file line number Diff line number Diff line change
@@ -224,6 +224,10 @@ ARG_NAME " κατέχει την τιμή NULL"
# define L10N_SOURCE_REGISTRATION_TRANSACTION_DESCRIPTION_W \
L"Stumpless registration of Windows Event Log Source"

// todo translate
# define L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( PARAM ) \
"could not bind " PARAM " to the statement"

// todo translate
# define L10N_SQLITE3_BUSY_ERROR_MESSAGE \
"the database was busy and could not complete the transaction"
3 changes: 3 additions & 0 deletions include/private/config/locale/en-us.h
Original file line number Diff line number Diff line change
@@ -209,6 +209,9 @@ ARG_NAME " was NULL"
# define L10N_SOURCE_REGISTRATION_TRANSACTION_DESCRIPTION_W \
L"Stumpless registration of Windows Event Log Source"

# define L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( PARAM ) \
"could not bind " PARAM " to the statement"

# define L10N_SQLITE3_BUSY_ERROR_MESSAGE \
"the database was busy and could not complete the transaction"

4 changes: 4 additions & 0 deletions include/private/config/locale/es-es.h
Original file line number Diff line number Diff line change
@@ -208,6 +208,10 @@ ARG_NAME " fue NULL"
# define L10N_SOURCE_REGISTRATION_TRANSACTION_DESCRIPTION_W \
L"registro de Stumpless del Registro de Eventos de Windows"

// todo translate
# define L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( PARAM ) \
"could not bind " PARAM " to the statement"

// todo translate
# define L10N_SQLITE3_BUSY_ERROR_MESSAGE \
"the database was busy and could not complete the transaction"
4 changes: 4 additions & 0 deletions include/private/config/locale/fr-fr.h
Original file line number Diff line number Diff line change
@@ -206,6 +206,10 @@ ARG_NAME " a été NULL"
# define L10N_SOURCE_REGISTRATION_TRANSACTION_DESCRIPTION_W \
L"enregistrement Stumpless de Windows Event Log Source"

// todo translate
# define L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( PARAM ) \
"could not bind " PARAM " to the statement"

// todo translate
# define L10N_SQLITE3_BUSY_ERROR_MESSAGE \
"the database was busy and could not complete the transaction"
4 changes: 4 additions & 0 deletions include/private/config/locale/he-il.h
Original file line number Diff line number Diff line change
@@ -207,6 +207,10 @@
# define L10N_SOURCE_REGISTRATION_TRANSACTION_DESCRIPTION_W \
L"Windows Event Log Source של Stumpless רישום"

// todo translate
# define L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( PARAM ) \
"could not bind " PARAM " to the statement"

// todo translate
# define L10N_SQLITE3_BUSY_ERROR_MESSAGE \
"the database was busy and could not complete the transaction"
4 changes: 4 additions & 0 deletions include/private/config/locale/hi-in.h
Original file line number Diff line number Diff line change
@@ -210,6 +210,10 @@ ARG_NAME " NULL था"
# define L10N_SOURCE_REGISTRATION_TRANSACTION_DESCRIPTION_W \
L"विंडोज इवेंट लॉग सोर्स का स्टंपलेस पंजीकरण"

// todo translate
# define L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( PARAM ) \
"could not bind " PARAM " to the statement"

// todo translate
# define L10N_SQLITE3_BUSY_ERROR_MESSAGE \
"the database was busy and could not complete the transaction"
4 changes: 4 additions & 0 deletions include/private/config/locale/it-it.h
Original file line number Diff line number Diff line change
@@ -208,6 +208,10 @@ ARG_NAME " era NULL"
# define L10N_SOURCE_REGISTRATION_TRANSACTION_DESCRIPTION_W \
L"la registrazione per Stumpless di Windows Event Log Source"

// todo translate
# define L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( PARAM ) \
"could not bind " PARAM " to the statement"

// todo translate
# define L10N_SQLITE3_BUSY_ERROR_MESSAGE \
"the database was busy and could not complete the transaction"
4 changes: 4 additions & 0 deletions include/private/config/locale/pl-pl.h
Original file line number Diff line number Diff line change
@@ -224,6 +224,10 @@ ARG_NAME " miał wartość NULL"
# define L10N_SOURCE_REGISTRATION_TRANSACTION_DESCRIPTION_W \
L"Stumpless registration of Windows Event Log Source"

// todo translate
# define L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( PARAM ) \
"could not bind " PARAM " to the statement"

// todo translate
# define L10N_SQLITE3_BUSY_ERROR_MESSAGE \
"the database was busy and could not complete the transaction"
4 changes: 4 additions & 0 deletions include/private/config/locale/pt-br.h
Original file line number Diff line number Diff line change
@@ -209,6 +209,10 @@ ARG_NAME " era NULL"
# define L10N_SOURCE_REGISTRATION_TRANSACTION_DESCRIPTION_W \
L"Registro do Stumpless no Windows Event Log Source"

// todo translate
# define L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( PARAM ) \
"could not bind " PARAM " to the statement"

// todo translate
# define L10N_SQLITE3_BUSY_ERROR_MESSAGE \
"the database was busy and could not complete the transaction"
4 changes: 4 additions & 0 deletions include/private/config/locale/sk-sk.h
Original file line number Diff line number Diff line change
@@ -233,6 +233,10 @@ ARG_NAME " mal hodnotu NULL"
# define L10N_SOURCE_REGISTRATION_TRANSACTION_DESCRIPTION_W \
L"Stumpless registration of Windows Event Log Source"

// todo translate
# define L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( PARAM ) \
"could not bind " PARAM " to the statement"

// todo translate
# define L10N_SQLITE3_BUSY_ERROR_MESSAGE \
"the database was busy and could not complete the transaction"
4 changes: 4 additions & 0 deletions include/private/config/locale/sv-se.h
Original file line number Diff line number Diff line change
@@ -236,6 +236,10 @@ ARG_NAME " var NULL"
# define L10N_SOURCE_REGISTRATION_TRANSACTION_DESCRIPTION_W \
L"Stumpless registration of Windows Event Log Source"

// todo translate
# define L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( PARAM ) \
"could not bind " PARAM " to the statement"

// todo translate
# define L10N_SQLITE3_BUSY_ERROR_MESSAGE \
"the database was busy and could not complete the transaction"
4 changes: 4 additions & 0 deletions include/private/config/locale/sw-ke.h
Original file line number Diff line number Diff line change
@@ -212,6 +212,10 @@ ARG_NAME " ilikuwa NULL"
# define L10N_SOURCE_REGISTRATION_TRANSACTION_DESCRIPTION_W \
"usajili wa Stumpless wa chanzo cha Windows Event Log"

// todo translate
# define L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( PARAM ) \
"could not bind " PARAM " to the statement"

// todo translate
# define L10N_SQLITE3_BUSY_ERROR_MESSAGE \
"the database was busy and could not complete the transaction"
4 changes: 4 additions & 0 deletions include/private/config/locale/tr-tr.h
Original file line number Diff line number Diff line change
@@ -210,6 +210,10 @@ ARG_NAME " NULL idi"
# define L10N_SOURCE_REGISTRATION_TRANSACTION_DESCRIPTION_W \
L"Windows Olay Günlüğü kaynağının Stumpless Kaydı"

// todo translate
# define L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( PARAM ) \
"could not bind " PARAM " to the statement"

// todo translate
# define L10N_SQLITE3_BUSY_ERROR_MESSAGE \
"the database was busy and could not complete the transaction"
4 changes: 4 additions & 0 deletions include/private/config/locale/zh-cn.h
Original file line number Diff line number Diff line change
@@ -211,6 +211,10 @@ ARG_NAME "是空的"
# define L10N_SOURCE_REGISTRATION_TRANSACTION_DESCRIPTION_W \
L"Windows事件日志源的无障碍注册"

// todo translate
# define L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( PARAM ) \
"could not bind " PARAM " to the statement"

// todo translate
# define L10N_SQLITE3_BUSY_ERROR_MESSAGE \
"the database was busy and could not complete the transaction"
12 changes: 9 additions & 3 deletions include/stumpless/error.h
Original file line number Diff line number Diff line change
@@ -134,17 +134,23 @@ extern "C" {
*/\
ERROR( STUMPLESS_INVALID_PARAM_STRING, 29 ) \
/**
* Sqlite3 was busy and could not complete the request.
* SQLite3 was busy and could not complete the request.
*
* @since release v2.2.0
*/\
ERROR( STUMPLESS_SQLITE3_BUSY, 30 ) \
/**
* Sqlite3 encountered a failure.
* A custom callback to a SQLite3 target failed.
*
* @since release v2.2.0
*/\
ERROR( STUMPLESS_SQLITE3_FAILURE, 31 )
ERROR( STUMPLESS_SQLITE3_CALLBACK_FAILURE, 31 ) \
/**
* SQLite3 encountered a failure.
*
* @since release v2.2.0
*/\
ERROR( STUMPLESS_SQLITE3_FAILURE, 32 )

/**
* An (enum) identifier of the types of errors that might be encountered.
10 changes: 8 additions & 2 deletions src/error.c
Original file line number Diff line number Diff line change
@@ -328,12 +328,18 @@ raise_socket_send_failure( const char *message,

void
raise_sqlite3_busy( void ) {
raise_error( STUMPLESS_SQLITE3_BUSY, "", STUMPLESS_SQLITE3_RETRY_MAX, "" ); // TODO fill in l10n strings
raise_error( STUMPLESS_SQLITE3_BUSY,
L10N_SQLITE3_BUSY_ERROR_MESSAGE,
STUMPLESS_SQLITE3_RETRY_MAX,
L10N_SQLITE3_RETRY_COUNT_CODE_TYPE );
}

void
raise_sqlite3_failure( const char *message, int code ) {
raise_error( STUMPLESS_SQLITE3_FAILURE, message, code, "the sqlite3 result code" ); // TODO l10n
raise_error( STUMPLESS_SQLITE3_FAILURE,
message,
code,
L10N_SQLITE3_RESULT_CODE_TYPE );
}

void
35 changes: 21 additions & 14 deletions src/target/sqlite3.c
Original file line number Diff line number Diff line change
@@ -317,6 +317,7 @@ stumpless_sqlite3_prepare( const struct stumpless_entry *entry,
const struct strbuilder *strbuilder_result;
const char *buffer;
size_t buffer_size;
const char *msg;

buffer_size = config_get_now( timestamp );

@@ -361,7 +362,7 @@ stumpless_sqlite3_prepare( const struct stumpless_entry *entry,
if( prival_index != 0 ) {
sql_result = sqlite3_bind_int( insert_stmt, prival_index, entry->prival );
if( sql_result != SQLITE_OK ) {
raise_sqlite3_failure( "could not bind the prival to the statement", sql_result ); // TODO l10n
msg = L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( "$prival" );
goto fail_bind;
}
}
@@ -371,7 +372,7 @@ stumpless_sqlite3_prepare( const struct stumpless_entry *entry,
facility_index,
get_facility( entry->prival ) );
if( sql_result != SQLITE_OK ) {
raise_sqlite3_failure( "could not bind the facility to the statement", sql_result ); // TODO l10n
msg = L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( "$facility" );
goto fail_bind;
}
}
@@ -381,7 +382,7 @@ stumpless_sqlite3_prepare( const struct stumpless_entry *entry,
severity_index,
get_severity( entry->prival ) );
if( sql_result != SQLITE_OK ) {
raise_sqlite3_failure( "could not bind the severity to the statement", sql_result ); // TODO l10n
msg = L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( "$severity" );
goto fail_bind;
}
}
@@ -399,7 +400,7 @@ stumpless_sqlite3_prepare( const struct stumpless_entry *entry,
SQLITE_TRANSIENT );
}
if( sql_result != SQLITE_OK ) {
raise_sqlite3_failure( "could not bind the timestamp to the statement", sql_result ); // TODO l10n
msg = L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( "$timestamp" );
goto fail_bind;
}
}
@@ -422,7 +423,7 @@ stumpless_sqlite3_prepare( const struct stumpless_entry *entry,
SQLITE_TRANSIENT );
}
if( sql_result != SQLITE_OK ) {
raise_sqlite3_failure( "could not bind the hostname to the statement", sql_result ); // TODO l10n
msg = L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( "$hostname" );
goto fail_bind;
}
}
@@ -438,7 +439,7 @@ stumpless_sqlite3_prepare( const struct stumpless_entry *entry,
SQLITE_STATIC );
}
if( sql_result != SQLITE_OK ) {
raise_sqlite3_failure( "could not bind the app_name to the statement", sql_result ); // TODO l10n
msg = L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( "$app_name" );
goto fail_bind;
}
}
@@ -462,7 +463,7 @@ stumpless_sqlite3_prepare( const struct stumpless_entry *entry,
SQLITE_TRANSIENT );
}
if( sql_result != SQLITE_OK ) {
raise_sqlite3_failure( "could not bind the procid to the statement", sql_result ); // TODO l10n
msg = L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( "$procid" );
goto fail_bind;
}
}
@@ -478,7 +479,7 @@ stumpless_sqlite3_prepare( const struct stumpless_entry *entry,
SQLITE_STATIC );
}
if( sql_result != SQLITE_OK ) {
raise_sqlite3_failure( "could not bind the msgid to the statement", sql_result ); // TODO l10n
msg = L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( "$msgid" );
goto fail_bind;
}
}
@@ -502,7 +503,7 @@ stumpless_sqlite3_prepare( const struct stumpless_entry *entry,
SQLITE_TRANSIENT );
}
if( sql_result != SQLITE_OK ) {
raise_sqlite3_failure( "could not bind the structured data to the statement", sql_result ); // TODO l10n
msg = L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( "$structured_data" );
goto fail_bind;
}
}
@@ -518,7 +519,7 @@ stumpless_sqlite3_prepare( const struct stumpless_entry *entry,
sql_result = sqlite3_bind_null( insert_stmt, message_index );
}
if( sql_result != SQLITE_OK ) {
raise_sqlite3_failure( "could not bind the message to the statement", sql_result ); // TODO l10n
msg = L10N_SQLITE3_BIND_FAILED_ERROR_MESSAGE( "$message" );
goto fail_bind;
}
}
@@ -532,6 +533,7 @@ stumpless_sqlite3_prepare( const struct stumpless_entry *entry,
fail_bind:
unlock_entry( entry );
strbuilder_destroy( builder );
raise_sqlite3_failure( msg, sql_result );
return NULL;
}

@@ -579,12 +581,16 @@ send_entry_to_sqlite3_target( const struct stumpless_target *target,

config_lock_mutex( &db_target->db_mutex );

statements = db_target->prepare_func( entry, db_target->prepare_data, &stmt_count );
statements = db_target->prepare_func( entry,
db_target->prepare_data,
&stmt_count );
if( !statements ) {
result = -1;
if( db_target->prepare_func != &stumpless_sqlite3_prepare ) {
// TODO create an error for sqlite3 callback failure
raise_sqlite3_failure ( "the prepare statements callback failed", 0 ); // TODO make more specific
raise_error( STUMPLESS_SQLITE3_CALLBACK_FAILURE,
L10N_SQLITE3_CUSTOM_PREPARE_FAILED_ERROR_MESSAGE,
0,
NULL );
}
goto cleanup_and_finish;
}
@@ -603,7 +609,8 @@ send_entry_to_sqlite3_target( const struct stumpless_target *target,

if( sql_result != SQLITE_DONE ) {
result = -1;
raise_sqlite3_failure( "sqlite3_step failed", sql_result ); // TODO l10n
raise_sqlite3_failure( L10N_SQLITE3_STEP_FAILED_ERROR_MESSAGE,
sql_result );
goto cleanup_and_finish;
}
}
1 change: 1 addition & 0 deletions tools/check_headers/stumpless.yml
Original file line number Diff line number Diff line change
@@ -388,6 +388,7 @@
"STUMPLESS_SOCKET_TARGETS_SUPPORTED": "stumpless/config.h"
"STUMPLESS_SOCKET_TARGET": "stumpless/target.h"
"STUMPLESS_SQLITE3_BUSY": "stumpless/error.h"
"STUMPLESS_SQLITE3_CALLBACK_FAILURE": "stumpless/error.h"
"STUMPLESS_SQLITE3_FAILURE": "stumpless/error.h"
"stumpless_sqlite3_prepare": "stumpless/target/sqlite3.h"
"stumpless_sqlite3_prepare_func_t": "stumpless/target/sqlite3.h"

0 comments on commit 82a229e

Please sign in to comment.