src/helper: wrap and clean headers.
Remove all useless 'extern' keywords from function prototypes. Wraps long lines for readability.__archive__
parent
4882647f3e
commit
1712d7835e
|
@ -30,7 +30,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* inlining this will help show what fn that is taking time during profiling. */
|
/* inlining this will help show what fn that is taking time during profiling. */
|
||||||
static inline void buf_set_u32(uint8_t* buffer, unsigned int first, unsigned int num, uint32_t value)
|
static inline void buf_set_u32(uint8_t* buffer,
|
||||||
|
unsigned int first, unsigned int num, uint32_t value)
|
||||||
{
|
{
|
||||||
if ((num == 32) && (first == 0))
|
if ((num == 32) && (first == 0))
|
||||||
{
|
{
|
||||||
|
@ -51,13 +52,16 @@ static inline void buf_set_u32(uint8_t* buffer, unsigned int first, unsigned int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static inline uint32_t buf_get_u32(const uint8_t* buffer, unsigned int first, unsigned int num)
|
static inline uint32_t buf_get_u32(const uint8_t* buffer,
|
||||||
|
unsigned int first, unsigned int num)
|
||||||
{
|
{
|
||||||
if ((num == 32) && (first == 0))
|
if ((num == 32) && (first == 0))
|
||||||
{
|
{
|
||||||
return (((uint32_t)buffer[3]) << 24) | (((uint32_t)buffer[2]) << 16) | (((uint32_t)buffer[1]) << 8) | (((uint32_t)buffer[0]) << 0);
|
return (((uint32_t)buffer[3]) << 24) |
|
||||||
} else
|
(((uint32_t)buffer[2]) << 16) |
|
||||||
{
|
(((uint32_t)buffer[1]) << 8) |
|
||||||
|
(((uint32_t)buffer[0]) << 0);
|
||||||
|
} else {
|
||||||
uint32_t result = 0;
|
uint32_t result = 0;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
@ -71,30 +75,30 @@ static inline uint32_t buf_get_u32(const uint8_t* buffer, unsigned int first, un
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern uint32_t flip_u32(uint32_t value, unsigned int num);
|
uint32_t flip_u32(uint32_t value, unsigned int num);
|
||||||
|
|
||||||
extern int buf_cmp(const uint8_t *buf1, const uint8_t *buf2, int size);
|
int buf_cmp(const uint8_t *buf1, const uint8_t *buf2, int size);
|
||||||
extern int buf_cmp_mask(const uint8_t *buf1, const uint8_t *buf2, const uint8_t *mask, int size);
|
int buf_cmp_mask(const uint8_t *buf1, const uint8_t *buf2,
|
||||||
extern uint8_t* buf_cpy(const uint8_t *from, uint8_t *to, int size);
|
const uint8_t *mask, int size);
|
||||||
|
uint8_t* buf_cpy(const uint8_t *from, uint8_t *to, int size);
|
||||||
|
|
||||||
extern uint8_t* buf_set_ones(uint8_t *buf, int count);
|
uint8_t* buf_set_ones(uint8_t *buf, int count);
|
||||||
extern uint8_t* buf_set_buf(const uint8_t *src, int src_start, uint8_t *dst, int dst_start, int len);
|
uint8_t* buf_set_buf(const uint8_t *src, int src_start,
|
||||||
|
uint8_t *dst, int dst_start, int len);
|
||||||
|
|
||||||
extern int str_to_buf(const char *str, int len, uint8_t *bin_buf, int buf_size, int radix);
|
int str_to_buf(const char *str, int len,
|
||||||
extern char* buf_to_str(const uint8_t *buf, int size, int radix);
|
uint8_t *bin_buf, int buf_size, int radix);
|
||||||
|
char* buf_to_str(const uint8_t *buf, int size, int radix);
|
||||||
|
|
||||||
struct scan_field_s;
|
struct scan_field_s;
|
||||||
extern int buf_to_u32_handler(uint8_t *in_buf, void *priv, struct scan_field_s *field);
|
int buf_to_u32_handler(uint8_t *in_buf, void *priv, struct scan_field_s *field);
|
||||||
|
|
||||||
#define CEIL(m, n) (((m) + (n) - 1) / (n))
|
#define CEIL(m, n) (((m) + (n) - 1) / (n))
|
||||||
|
|
||||||
/* read a uint32_t from a buffer in target memory endianness */
|
/* read a uint32_t from a buffer in target memory endianness */
|
||||||
static inline uint32_t fast_target_buffer_get_u32(const uint8_t *buffer, int little)
|
static inline uint32_t fast_target_buffer_get_u32(const uint8_t *p, int le)
|
||||||
{
|
{
|
||||||
if (little)
|
return le ? le_to_h_u32(p) : be_to_h_u32(p);
|
||||||
return le_to_h_u32(buffer);
|
|
||||||
else
|
|
||||||
return be_to_h_u32(buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* BINARYBUFFER_H */
|
#endif /* BINARYBUFFER_H */
|
||||||
|
|
|
@ -84,25 +84,36 @@ typedef struct command_s
|
||||||
struct command_s *next;
|
struct command_s *next;
|
||||||
} command_t;
|
} command_t;
|
||||||
|
|
||||||
extern command_t* register_command(command_context_t *context, command_t *parent, char *name, int (*handler)(struct command_context_s *context, char* name, char** args, int argc), enum command_mode mode, char *help);
|
command_t* register_command(command_context_t *context,
|
||||||
extern int unregister_command(command_context_t *context, char *name);
|
command_t *parent, char *name,
|
||||||
extern int unregister_all_commands(command_context_t *context);
|
int (*handler)(struct command_context_s *context,
|
||||||
extern void command_set_output_handler(command_context_t* context, int (*output_handler)(struct command_context_s *context, const char* line), void *priv);
|
char* name, char** args, int argc),
|
||||||
extern command_context_t* copy_command_context(command_context_t* context);
|
enum command_mode mode, char *help);
|
||||||
extern int command_context_mode(command_context_t *context, enum command_mode mode);
|
|
||||||
extern command_context_t* command_init(void);
|
|
||||||
extern int command_done(command_context_t *context);
|
|
||||||
|
|
||||||
extern void command_print(command_context_t *context, const char *format, ...)
|
int unregister_command(command_context_t *context, char *name);
|
||||||
__attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 2, 3)));
|
int unregister_all_commands(command_context_t *context);
|
||||||
extern void command_print_sameline(command_context_t *context, const char *format, ...)
|
|
||||||
__attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 2, 3)));
|
|
||||||
extern int command_run_line(command_context_t *context, char *line);
|
|
||||||
extern int command_run_linef(command_context_t *context, const char *format, ...)
|
|
||||||
__attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 2, 3)));
|
|
||||||
extern void command_output_text(command_context_t *context, const char *data);
|
|
||||||
|
|
||||||
extern void process_jim_events(void);
|
void command_set_output_handler(command_context_t* context,
|
||||||
|
int (*output_handler)(struct command_context_s *context,
|
||||||
|
const char* line), void *priv);
|
||||||
|
|
||||||
|
command_context_t* copy_command_context(command_context_t* context);
|
||||||
|
|
||||||
|
int command_context_mode(command_context_t *context, enum command_mode mode);
|
||||||
|
|
||||||
|
command_context_t* command_init(void);
|
||||||
|
int command_done(command_context_t *context);
|
||||||
|
|
||||||
|
void command_print(command_context_t *context, const char *format, ...)
|
||||||
|
__attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 2, 3)));
|
||||||
|
void command_print_sameline(command_context_t *context, const char *format, ...)
|
||||||
|
__attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 2, 3)));
|
||||||
|
int command_run_line(command_context_t *context, char *line);
|
||||||
|
int command_run_linef(command_context_t *context, const char *format, ...)
|
||||||
|
__attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 2, 3)));
|
||||||
|
void command_output_text(command_context_t *context, const char *data);
|
||||||
|
|
||||||
|
void process_jim_events(void);
|
||||||
|
|
||||||
#define ERROR_COMMAND_CLOSE_CONNECTION (-600)
|
#define ERROR_COMMAND_CLOSE_CONNECTION (-600)
|
||||||
#define ERROR_COMMAND_SYNTAX_ERROR (-601)
|
#define ERROR_COMMAND_SYNTAX_ERROR (-601)
|
||||||
|
|
|
@ -25,12 +25,19 @@
|
||||||
|
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
|
|
||||||
extern int parse_cmdline_args(struct command_context_s *cmd_ctx, int argc, char *argv[]);
|
int parse_cmdline_args(struct command_context_s *cmd_ctx,
|
||||||
extern int parse_config_file(struct command_context_s *cmd_ctx);
|
int argc, char *argv[]);
|
||||||
extern void add_config_command (const char *cfg);
|
|
||||||
extern void add_script_search_dir (const char *dir);
|
int parse_config_file(struct command_context_s *cmd_ctx);
|
||||||
extern int configuration_output_handler(struct command_context_s *context, const char* line);
|
void add_config_command(const char *cfg);
|
||||||
extern FILE *open_file_from_path (char *file, char *mode);
|
|
||||||
extern char *find_file(const char *name);
|
void add_script_search_dir(const char *dir);
|
||||||
|
|
||||||
|
int configuration_output_handler(struct command_context_s *cmd_ctx,
|
||||||
|
const char *line);
|
||||||
|
|
||||||
|
FILE *open_file_from_path(char *file, char *mode);
|
||||||
|
|
||||||
|
char *find_file(const char *name);
|
||||||
|
|
||||||
#endif /* CONFIGURATION_H */
|
#endif /* CONFIGURATION_H */
|
||||||
|
|
|
@ -54,14 +54,20 @@ typedef struct fileio_s
|
||||||
FILE *file;
|
FILE *file;
|
||||||
} fileio_t;
|
} fileio_t;
|
||||||
|
|
||||||
extern int fileio_write(fileio_t *fileio, uint32_t size, const uint8_t *buffer, uint32_t *size_written);
|
int fileio_open(fileio_t *fileio,
|
||||||
extern int fileio_read(fileio_t *fileio, uint32_t size, uint8_t *buffer, uint32_t *size_read);
|
const char *url, enum fileio_access access, enum fileio_type type);
|
||||||
extern int fileio_fgets(fileio_t *fileio, uint32_t size, char *buffer);
|
int fileio_close(fileio_t *fileio);
|
||||||
extern int fileio_seek(fileio_t *fileio, uint32_t position);
|
|
||||||
extern int fileio_close(fileio_t *fileio);
|
int fileio_seek(fileio_t *fileio, uint32_t position);
|
||||||
extern int fileio_open(fileio_t *fileio, const char *url, enum fileio_access access, enum fileio_type type);
|
int fileio_fgets(fileio_t *fileio, uint32_t size, char *buffer);
|
||||||
extern int fileio_read_u32(fileio_t *fileio, uint32_t *data);
|
|
||||||
extern int fileio_write_u32(fileio_t *fileio, uint32_t data);
|
int fileio_read(fileio_t *fileio,
|
||||||
|
uint32_t size, uint8_t *buffer, uint32_t *size_read);
|
||||||
|
int fileio_write(fileio_t *fileio,
|
||||||
|
uint32_t size, const uint8_t *buffer, uint32_t *size_written);
|
||||||
|
|
||||||
|
int fileio_read_u32(fileio_t *fileio, uint32_t *data);
|
||||||
|
int fileio_write_u32(fileio_t *fileio, uint32_t data);
|
||||||
|
|
||||||
#define ERROR_FILEIO_LOCATION_UNKNOWN (-1200)
|
#define ERROR_FILEIO_LOCATION_UNKNOWN (-1200)
|
||||||
#define ERROR_FILEIO_NOT_FOUND (-1201)
|
#define ERROR_FILEIO_NOT_FOUND (-1201)
|
||||||
|
|
|
@ -59,20 +59,23 @@ enum log_levels
|
||||||
LOG_LVL_DEBUG = 3
|
LOG_LVL_DEBUG = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void log_printf(enum log_levels level, const char *file, int line,
|
void log_printf(enum log_levels level, const char *file, int line,
|
||||||
const char *function, const char *format, ...)
|
const char *function, const char *format, ...)
|
||||||
__attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 5, 6)));
|
__attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 5, 6)));
|
||||||
extern void log_printf_lf(enum log_levels level, const char *file, int line,
|
void log_printf_lf(enum log_levels level, const char *file, int line,
|
||||||
const char *function, const char *format, ...)
|
const char *function, const char *format, ...)
|
||||||
__attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 5, 6)));
|
__attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 5, 6)));
|
||||||
extern int log_register_commands(struct command_context_s *cmd_ctx);
|
|
||||||
extern int log_init(struct command_context_s *cmd_ctx);
|
|
||||||
extern int set_log_output(struct command_context_s *cmd_ctx, FILE *output);
|
|
||||||
extern void keep_alive(void);
|
|
||||||
extern void kept_alive(void);
|
|
||||||
extern void alive_sleep(int ms);
|
|
||||||
extern void busy_sleep(int ms);
|
|
||||||
|
|
||||||
|
int log_init(struct command_context_s *cmd_ctx);
|
||||||
|
int set_log_output(struct command_context_s *cmd_ctx, FILE *output);
|
||||||
|
|
||||||
|
int log_register_commands(struct command_context_s *cmd_ctx);
|
||||||
|
|
||||||
|
void keep_alive(void);
|
||||||
|
void kept_alive(void);
|
||||||
|
|
||||||
|
void alive_sleep(int ms);
|
||||||
|
void busy_sleep(int ms);
|
||||||
|
|
||||||
/* log entries can be paused and replayed roughly according to the try/catch/rethrow
|
/* log entries can be paused and replayed roughly according to the try/catch/rethrow
|
||||||
* concepts in C++
|
* concepts in C++
|
||||||
|
@ -92,8 +95,8 @@ typedef struct log_callback_s
|
||||||
struct log_callback_s *next;
|
struct log_callback_s *next;
|
||||||
} log_callback_t;
|
} log_callback_t;
|
||||||
|
|
||||||
extern int log_add_callback(log_callback_fn fn, void *priv);
|
int log_add_callback(log_callback_fn fn, void *priv);
|
||||||
extern int log_remove_callback(log_callback_fn fn, void *priv);
|
int log_remove_callback(log_callback_fn fn, void *priv);
|
||||||
|
|
||||||
char *alloc_vprintf(const char *fmt, va_list ap);
|
char *alloc_vprintf(const char *fmt, va_list ap);
|
||||||
char *alloc_printf(const char *fmt, ...);
|
char *alloc_printf(const char *fmt, ...);
|
||||||
|
|
|
@ -65,7 +65,8 @@ struct timezone {
|
||||||
#endif
|
#endif
|
||||||
struct timezone;
|
struct timezone;
|
||||||
|
|
||||||
extern int gettimeofday(struct timeval *tv, struct timezone *tz);
|
int gettimeofday(struct timeval *tv, struct timezone *tz);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef IN_REPLACEMENTS_C
|
#ifndef IN_REPLACEMENTS_C
|
||||||
|
@ -105,11 +106,11 @@ void *fill_malloc(size_t size);
|
||||||
|
|
||||||
/* GNU extensions to the C library that may be missing on some systems */
|
/* GNU extensions to the C library that may be missing on some systems */
|
||||||
#ifndef HAVE_STRNDUP
|
#ifndef HAVE_STRNDUP
|
||||||
extern char* strndup(const char *s, size_t n);
|
char* strndup(const char *s, size_t n);
|
||||||
#endif /* HAVE_STRNDUP */
|
#endif /* HAVE_STRNDUP */
|
||||||
|
|
||||||
#ifndef HAVE_STRNLEN
|
#ifndef HAVE_STRNLEN
|
||||||
extern size_t strnlen(const char *s, size_t maxlen);
|
size_t strnlen(const char *s, size_t maxlen);
|
||||||
#endif /* HAVE_STRNLEN */
|
#endif /* HAVE_STRNLEN */
|
||||||
|
|
||||||
#ifndef HAVE_USLEEP
|
#ifndef HAVE_USLEEP
|
||||||
|
|
Loading…
Reference in New Issue