Function declarations changed to common Maxscale style.

This commit is contained in:
Johan Wikman
2015-10-21 15:47:04 +03:00
parent 18181e8cb9
commit cb468be04f

View File

@ -258,12 +258,11 @@ typedef struct strpart
/** Static function declarations */ /** Static function declarations */
static bool logfiles_init(logmanager_t* lmgr); static bool logfiles_init(logmanager_t* lmgr);
static bool logfile_init( static bool logfile_init(logfile_t* logfile,
logfile_t* logfile, logfile_id_t logfile_id,
logfile_id_t logfile_id, logmanager_t* logmanager,
logmanager_t* logmanager, bool store_shmem,
bool store_shmem, bool write_syslog);
bool write_syslog);
static void logfile_done(logfile_t* logfile); static void logfile_done(logfile_t* logfile);
static void logfile_free_memory(logfile_t* lf); static void logfile_free_memory(logfile_t* lf);
static void logfile_flush(logfile_t* lf); static void logfile_flush(logfile_t* lf);
@ -272,53 +271,49 @@ static bool logfile_create(logfile_t* lf);
static bool logfile_open_file(filewriter_t* fw, logfile_t* lf); static bool logfile_open_file(filewriter_t* fw, logfile_t* lf);
static char* form_full_file_name(strpart_t* parts, logfile_t* lf, int seqnoidx); static char* form_full_file_name(strpart_t* parts, logfile_t* lf, int seqnoidx);
static bool filewriter_init( static bool filewriter_init(logmanager_t* logmanager,
logmanager_t* logmanager, filewriter_t* fw,
filewriter_t* fw, skygw_message_t* clientmes,
skygw_message_t* clientmes, skygw_message_t* logmes);
skygw_message_t* logmes); static void filewriter_done(filewriter_t* filewriter);
static void filewriter_done(filewriter_t* filewriter); static bool fnames_conf_init(fnames_conf_t* fn, int argc, char* argv[]);
static bool fnames_conf_init(fnames_conf_t* fn, int argc, char* argv[]); static void fnames_conf_done(fnames_conf_t* fn);
static void fnames_conf_done(fnames_conf_t* fn); static void fnames_conf_free_memory(fnames_conf_t* fn);
static void fnames_conf_free_memory(fnames_conf_t* fn); static char* fname_conf_get_prefix(fnames_conf_t* fn, logfile_id_t id);
static char* fname_conf_get_prefix(fnames_conf_t* fn, logfile_id_t id); static char* fname_conf_get_suffix(fnames_conf_t* fn, logfile_id_t id);
static char* fname_conf_get_suffix(fnames_conf_t* fn, logfile_id_t id); static void* thr_filewriter_fun(void* data);
static void* thr_filewriter_fun(void* data);
static logfile_t* logmanager_get_logfile(logmanager_t* lm, logfile_id_t id); static logfile_t* logmanager_get_logfile(logmanager_t* lm, logfile_id_t id);
static bool logmanager_register(bool writep); static bool logmanager_register(bool writep);
static void logmanager_unregister(void); static void logmanager_unregister(void);
static bool logmanager_init_nomutex(int argc, char* argv[]); static bool logmanager_init_nomutex(int argc, char* argv[]);
static void logmanager_done_nomutex(void); static void logmanager_done_nomutex(void);
static int logmanager_write_log( static int logmanager_write_log(logfile_id_t id,
logfile_id_t id, bool flush,
bool flush, bool use_valist,
bool use_valist, bool spread_down,
bool spread_down, bool rotate,
bool rotate, size_t len,
size_t len, const char* str,
const char* str, va_list valist);
va_list valist);
static blockbuf_t* blockbuf_init(logfile_id_t id); static blockbuf_t* blockbuf_init(logfile_id_t id);
static void blockbuf_node_done(void* bb_data); static void blockbuf_node_done(void* bb_data);
static char* blockbuf_get_writepos( static char* blockbuf_get_writepos(blockbuf_t** p_bb,
blockbuf_t** p_bb, logfile_id_t id,
logfile_id_t id, size_t str_len,
size_t str_len, bool flush);
bool flush);
static void blockbuf_register(blockbuf_t* bb); static void blockbuf_register(blockbuf_t* bb);
static void blockbuf_unregister(blockbuf_t* bb); static void blockbuf_unregister(blockbuf_t* bb);
static bool logfile_set_enabled(logfile_id_t id, bool val); static bool logfile_set_enabled(logfile_id_t id, bool val);
static char* add_slash(char* str); static char* add_slash(char* str);
static bool check_file_and_path( static bool check_file_and_path(char* filename,
char* filename, bool* writable,
bool* writable, bool do_log);
bool do_log);
static bool file_is_symlink(char* filename); static bool file_is_symlink(char* filename);
static int skygw_log_disable_raw(logfile_id_t id, bool emergency); /*< no locking */ static int skygw_log_disable_raw(logfile_id_t id, bool emergency); /*< no locking */
static int find_last_seqno(strpart_t* parts, int seqno, int seqnoidx); static int find_last_seqno(strpart_t* parts, int seqno, int seqnoidx);
void flushall_logfiles(bool flush); void flushall_logfiles(bool flush);
@ -374,9 +369,7 @@ const char* get_logpath_default(void)
return "/var/log/maxscale"; return "/var/log/maxscale";
} }
static bool logmanager_init_nomutex( static bool logmanager_init_nomutex(int argc, char* argv[])
int argc,
char* argv[])
{ {
fnames_conf_t* fn; fnames_conf_t* fn;
filewriter_t* fw; filewriter_t* fw;
@ -498,9 +491,7 @@ return_succp:
* @return true if succeed, otherwise false * @return true if succeed, otherwise false
* *
*/ */
bool skygw_logmanager_init( bool skygw_logmanager_init(int argc, char* argv[])
int argc,
char* argv[])
{ {
bool succp = false; bool succp = false;
@ -658,15 +649,14 @@ static logfile_t* logmanager_get_logfile(
* @return 0 if succeed, -1 otherwise * @return 0 if succeed, -1 otherwise
* *
*/ */
static int logmanager_write_log( static int logmanager_write_log(logfile_id_t id,
logfile_id_t id, bool flush,
bool flush, bool use_valist,
bool use_valist, bool spread_down,
bool spread_down, bool rotate,
bool rotate, size_t str_len,
size_t str_len, const char* str,
const char* str, va_list valist)
va_list valist)
{ {
logfile_t* lf; logfile_t* lf;
char* wp; char* wp;
@ -955,8 +945,7 @@ return_err:
* *
* @param bb block buffer * @param bb block buffer
*/ */
static void blockbuf_register( static void blockbuf_register(blockbuf_t* bb)
blockbuf_t* bb)
{ {
CHK_BLOCKBUF(bb); CHK_BLOCKBUF(bb);
ss_dassert(bb->bb_refcount >= 0); ss_dassert(bb->bb_refcount >= 0);
@ -969,8 +958,7 @@ static void blockbuf_register(
* *
* @param bb block buffer * @param bb block buffer
*/ */
static void blockbuf_unregister( static void blockbuf_unregister(blockbuf_t* bb)
blockbuf_t* bb)
{ {
logfile_t* lf; logfile_t* lf;
@ -1008,11 +996,10 @@ static void blockbuf_unregister(
* mutex. * mutex.
* *
*/ */
static char* blockbuf_get_writepos( static char* blockbuf_get_writepos(blockbuf_t** p_bb,
blockbuf_t** p_bb, logfile_id_t id,
logfile_id_t id, size_t str_len,
size_t str_len, bool flush)
bool flush)
{ {
logfile_t* lf; logfile_t* lf;
mlist_t* bb_list; mlist_t* bb_list;
@ -1265,16 +1252,14 @@ static char* blockbuf_get_writepos(
return pos; return pos;
} }
static void blockbuf_node_done( static void blockbuf_node_done(void* bb_data)
void* bb_data)
{ {
blockbuf_t* bb = (blockbuf_t *)bb_data; blockbuf_t* bb = (blockbuf_t *)bb_data;
simple_mutex_done(&bb->bb_mutex); simple_mutex_done(&bb->bb_mutex);
} }
static blockbuf_t* blockbuf_init( static blockbuf_t* blockbuf_init(logfile_id_t id)
logfile_id_t id)
{ {
blockbuf_t* bb; blockbuf_t* bb;
@ -1303,8 +1288,7 @@ static blockbuf_t* blockbuf_init(
} }
int skygw_log_enable( int skygw_log_enable(logfile_id_t id)
logfile_id_t id)
{ {
bool err = 0; bool err = 0;
@ -1329,8 +1313,7 @@ return_err:
return err; return err;
} }
int skygw_log_disable( int skygw_log_disable(logfile_id_t id) /*< no locking */
logfile_id_t id) /*< no locking */
{ {
int rc; int rc;
@ -1562,13 +1545,12 @@ static int log_write(logfile_id_t id,
return rv; return rv;
} }
int skygw_log_write_context_flush( int skygw_log_write_context_flush(logfile_id_t id,
logfile_id_t id, const char* file,
const char* file, int line,
int line, const char* function,
const char* function, const char* str,
const char* str, ...)
...)
{ {
int err = 0; int err = 0;
va_list valist; va_list valist;
@ -1604,13 +1586,12 @@ int skygw_log_write_context_flush(
int skygw_log_write_context( int skygw_log_write_context(logfile_id_t id,
logfile_id_t id, const char* file,
const char* file, int line,
int line, const char* function,
const char* function, const char* str,
const char* str, ...)
...)
{ {
int err = 0; int err = 0;
va_list valist; va_list valist;
@ -1645,8 +1626,7 @@ int skygw_log_write_context(
} }
int skygw_log_flush( int skygw_log_flush(logfile_id_t id)
logfile_id_t id)
{ {
int err = 0; int err = 0;
va_list valist; /**< Dummy, must be present but it is not processed */ va_list valist; /**< Dummy, must be present but it is not processed */
@ -1676,8 +1656,7 @@ return_err:
* Replace current logfile with new file with increased sequence number on * Replace current logfile with new file with increased sequence number on
* its name. * its name.
*/ */
int skygw_log_rotate( int skygw_log_rotate(logfile_id_t id)
logfile_id_t id)
{ {
int err = 0; int err = 0;
logfile_t* lf; logfile_t* lf;
@ -1739,8 +1718,7 @@ return_err:
* @details Link count modify is protected by mutex. * @details Link count modify is protected by mutex.
* *
*/ */
static bool logmanager_register( static bool logmanager_register(bool writep)
bool writep)
{ {
bool succp = true; bool succp = true;
@ -1839,10 +1817,9 @@ static void logmanager_unregister(void)
* @details Note that input parameter lenghts are checked here. * @details Note that input parameter lenghts are checked here.
* *
*/ */
static bool fnames_conf_init( static bool fnames_conf_init(fnames_conf_t* fn,
fnames_conf_t* fn, int argc,
int argc, char* argv[])
char* argv[])
{ {
int opt; int opt;
bool succp = false; bool succp = false;
@ -2013,9 +1990,8 @@ return_conf_init:
} }
static char* fname_conf_get_prefix( static char* fname_conf_get_prefix(fnames_conf_t* fn,
fnames_conf_t* fn, logfile_id_t id)
logfile_id_t id)
{ {
CHK_FNAMES_CONF(fn); CHK_FNAMES_CONF(fn);
ss_dassert(id >= LOGFILE_FIRST && id <= LOGFILE_LAST); ss_dassert(id >= LOGFILE_FIRST && id <= LOGFILE_LAST);
@ -2043,9 +2019,8 @@ static char* fname_conf_get_prefix(
} }
} }
static char* fname_conf_get_suffix( static char* fname_conf_get_suffix(fnames_conf_t* fn,
fnames_conf_t* fn, logfile_id_t id)
logfile_id_t id)
{ {
CHK_FNAMES_CONF(fn); CHK_FNAMES_CONF(fn);
ss_dassert(id >= LOGFILE_FIRST && id <= LOGFILE_LAST); ss_dassert(id >= LOGFILE_FIRST && id <= LOGFILE_LAST);
@ -2157,8 +2132,7 @@ static bool logfiles_init(
return succp; return succp;
} }
static void logfile_flush( static void logfile_flush(logfile_t* lf)
logfile_t* lf)
{ {
CHK_LOGFILE(lf); CHK_LOGFILE(lf);
acquire_lock(&lf->lf_spinlock); acquire_lock(&lf->lf_spinlock);
@ -2173,8 +2147,7 @@ static void logfile_flush(
* *
* @param lf logfile pointer * @param lf logfile pointer
*/ */
static void logfile_rotate( static void logfile_rotate(logfile_t* lf)
logfile_t* lf)
{ {
CHK_LOGFILE(lf); CHK_LOGFILE(lf);
acquire_lock(&lf->lf_spinlock); acquire_lock(&lf->lf_spinlock);
@ -2196,8 +2169,7 @@ static void logfile_rotate(
* using log manager in parallel with multiple processes and by configuring * using log manager in parallel with multiple processes and by configuring
* log manager to use same directories among those processes. * log manager to use same directories among those processes.
*/ */
static bool logfile_create( static bool logfile_create(logfile_t* lf)
logfile_t* lf)
{ {
bool namecreatefail; bool namecreatefail;
bool nameconflicts; bool nameconflicts;
@ -2337,9 +2309,8 @@ return_succp:
* false if failed. * false if failed.
* *
*/ */
static bool logfile_open_file( static bool logfile_open_file(filewriter_t* fw,
filewriter_t* fw, logfile_t* lf)
logfile_t* lf)
{ {
bool succp; bool succp;
char* start_msg_str; char* start_msg_str;
@ -2428,10 +2399,9 @@ return_succp:
* @return Pointer to filename, of NULL if failed. * @return Pointer to filename, of NULL if failed.
* *
*/ */
static char* form_full_file_name( static char* form_full_file_name(strpart_t* parts,
strpart_t* parts, logfile_t* lf,
logfile_t* lf, int seqnoidx)
int seqnoidx)
{ {
int i; int i;
int seqno; int seqno;
@ -2545,8 +2515,7 @@ return_filename:
* @details (write detailed description here) * @details (write detailed description here)
* *
*/ */
static char* add_slash( static char* add_slash(char* str)
char* str)
{ {
char* p = str; char* p = str;
size_t plen = strlen(p); size_t plen = strlen(p);
@ -2581,10 +2550,9 @@ static char* add_slash(
* TODO: recall what was the reason for not succeeding with simply * TODO: recall what was the reason for not succeeding with simply
* calling access, and fstat. vraa 26.11.13 * calling access, and fstat. vraa 26.11.13
*/ */
static bool check_file_and_path( static bool check_file_and_path(char* filename,
char* filename, bool* writable,
bool* writable, bool do_log)
bool do_log)
{ {
bool exists; bool exists;
@ -2655,8 +2623,7 @@ static bool check_file_and_path(
static bool file_is_symlink( static bool file_is_symlink(char* filename)
char* filename)
{ {
int rc; int rc;
bool succp = false; bool succp = false;
@ -2689,12 +2656,11 @@ static bool file_is_symlink(
* *
* @return true if succeed, false otherwise * @return true if succeed, false otherwise
*/ */
static bool logfile_init( static bool logfile_init(logfile_t* logfile,
logfile_t* logfile, logfile_id_t logfile_id,
logfile_id_t logfile_id, logmanager_t* logmanager,
logmanager_t* logmanager, bool store_shmem,
bool store_shmem, bool write_syslog)
bool write_syslog)
{ {
bool succp = false; bool succp = false;
fnames_conf_t* fn = &logmanager->lm_fnames_conf; fnames_conf_t* fn = &logmanager->lm_fnames_conf;
@ -2823,8 +2789,7 @@ return_with_succp:
* flag read/write. Lock would be held during log write operation by clients. * flag read/write. Lock would be held during log write operation by clients.
* *
*/ */
static void logfile_done( static void logfile_done(logfile_t* lf)
logfile_t* lf)
{ {
switch(lf->lf_state) switch(lf->lf_state)
{ {
@ -2870,11 +2835,10 @@ static void logfile_free_memory(
* @return true if succeed, false if failed * @return true if succeed, false if failed
* *
*/ */
static bool filewriter_init( static bool filewriter_init(logmanager_t* logmanager,
logmanager_t* logmanager, filewriter_t* fw,
filewriter_t* fw, skygw_message_t* clientmes,
skygw_message_t* clientmes, skygw_message_t* logmes)
skygw_message_t* logmes)
{ {
bool succp = false; bool succp = false;
logfile_t* lf; logfile_t* lf;
@ -2926,8 +2890,7 @@ return_succp:
return succp; return succp;
} }
static void filewriter_done( static void filewriter_done(filewriter_t* fw)
filewriter_t* fw)
{ {
int i; int i;
logfile_id_t id; logfile_id_t id;
@ -3003,8 +2966,7 @@ static void filewriter_done(
* version is even and read is consistent only if version hasn't changed * version is even and read is consistent only if version hasn't changed
* during the read. * during the read.
*/ */
static void* thr_filewriter_fun( static void* thr_filewriter_fun(void* data)
void* data)
{ {
skygw_thread_t* thr; skygw_thread_t* thr;
filewriter_t* fwr; filewriter_t* fwr;
@ -3237,8 +3199,7 @@ static void* thr_filewriter_fun(
} }
static void fnames_conf_done( static void fnames_conf_done(fnames_conf_t* fn)
fnames_conf_t* fn)
{ {
switch (fn->fn_state) switch (fn->fn_state)
{ {
@ -3255,8 +3216,7 @@ static void fnames_conf_done(
} }
static void fnames_conf_free_memory( static void fnames_conf_free_memory(fnames_conf_t* fn)
fnames_conf_t* fn)
{ {
if (fn->fn_debug_prefix != NULL) free(fn->fn_debug_prefix); if (fn->fn_debug_prefix != NULL) free(fn->fn_debug_prefix);
if (fn->fn_debug_suffix!= NULL) free(fn->fn_debug_suffix); if (fn->fn_debug_suffix!= NULL) free(fn->fn_debug_suffix);
@ -3278,10 +3238,9 @@ static void fnames_conf_free_memory(
* *
* @return the biggest sequence number used * @return the biggest sequence number used
*/ */
static int find_last_seqno( static int find_last_seqno(strpart_t* parts,
strpart_t* parts, int seqno,
int seqno, int seqnoidx)
int seqnoidx)
{ {
strpart_t* p; strpart_t* p;
char* snstr; char* snstr;