@@ -54,6 +54,12 @@ typedef struct {
5454 size_t blen ; // blen if code is SQLITE_OK, rc in case of error
5555} NETWORK_RESULT ;
5656
57+ typedef struct {
58+ const char * data ;
59+ size_t size ;
60+ size_t read_pos ;
61+ } network_read_data ;
62+
5763// MARK: -
5864
5965static bool network_buffer_check (network_buffer * data , size_t needed ) {
@@ -155,12 +161,6 @@ static NETWORK_RESULT network_receive_buffer (network_data *data, const char *en
155161 return result ;
156162}
157163
158- typedef struct {
159- const char * data ;
160- size_t size ;
161- size_t read_pos ;
162- } network_read_data ;
163-
164164static size_t network_read_callback (char * buffer , size_t size , size_t nitems , void * userdata ) {
165165 network_read_data * rd = (network_read_data * )userdata ;
166166 size_t max_read = size * nitems ;
@@ -292,7 +292,7 @@ char *network_authentication_token(const char *key, const char *value) {
292292 return buffer ;
293293}
294294
295- int extract_query_param (const char * query , const char * key , char * output , size_t output_size ) {
295+ int network_extract_query_param (const char * query , const char * key , char * output , size_t output_size ) {
296296 if (!query || !key || !output || output_size == 0 ) {
297297 return -1 ; // Invalid input
298298 }
@@ -380,10 +380,10 @@ bool network_compute_endpoints (sqlite3_context *context, network_data *data, co
380380 if (rc != CURLE_OK && rc != CURLUE_NO_QUERY ) goto finalize ;
381381 if (query != NULL ) {
382382 char value [MAX_QUERY_VALUE_LEN ];
383- if (!authentication && extract_query_param (query , "apikey" , value , sizeof (value )) == 0 ) {
383+ if (!authentication && network_extract_query_param (query , "apikey" , value , sizeof (value )) == 0 ) {
384384 authentication = network_authentication_token ("apikey" , value );
385385 }
386- if (!authentication && extract_query_param (query , "token" , value , sizeof (value )) == 0 ) {
386+ if (!authentication && network_extract_query_param (query , "token" , value , sizeof (value )) == 0 ) {
387387 authentication = network_authentication_token ("token" , value );
388388 }
389389 }
@@ -428,6 +428,12 @@ bool network_compute_endpoints (sqlite3_context *context, network_data *data, co
428428 return result ;
429429}
430430
431+ void network_result_to_sqlite_error (sqlite3_context * context , NETWORK_RESULT res , const char * default_error_message ) {
432+ sqlite3_result_error (context , ((res .code == CLOUDSYNC_NETWORK_ERROR ) && (res .buffer )) ? res .buffer : default_error_message , -1 );
433+ sqlite3_result_error_code (context , ((res .code == CLOUDSYNC_NETWORK_ERROR ) && (res .blen )) ? (int )res .blen : SQLITE_ERROR );
434+ if (res .buffer ) cloudsync_memory_free (res .buffer );
435+ }
436+
431437// MARK: -
432438
433439void cloudsync_network_init (sqlite3_context * context , int argc , sqlite3_value * * argv ) {
@@ -532,12 +538,6 @@ void cloudsync_network_set_apikey (sqlite3_context *context, int argc, sqlite3_v
532538
533539// MARK: -
534540
535- void network_result_to_sqlite_error (sqlite3_context * context , NETWORK_RESULT res , const char * default_error_message ) {
536- sqlite3_result_error (context , ((res .code == CLOUDSYNC_NETWORK_ERROR ) && (res .buffer )) ? res .buffer : default_error_message , -1 );
537- sqlite3_result_error_code (context , ((res .code == CLOUDSYNC_NETWORK_ERROR ) && (res .blen )) ? (int )res .blen : SQLITE_ERROR );
538- if (res .buffer ) cloudsync_memory_free (res .buffer );
539- }
540-
541541void cloudsync_network_send_changes (sqlite3_context * context , int argc , sqlite3_value * * argv ) {
542542 DEBUG_FUNCTION ("cloudsync_network_send_changes" );
543543
0 commit comments