From: Pablo Neira Ayuso pablo@gnumonks.org
Summary of changes:
s/bcd2char/osmo_bcd2char/g s/char2bcd/osmo_char2bcd/g s/hexparse/osmo_hexparse/g s/hexdump/osmo_hexdump/g s/hexdump_nospc/osmo_hexdump_nospc/g s/ubit_dump/osmo_ubit_dump/g s/static_assert/osmo_static_assert/g --- include/osmocom/core/msgb.h | 2 +- include/osmocom/core/utils.h | 14 +++++++------- src/gsm/gsm48.c | 12 ++++++------ src/utils.c | 18 +++++++++--------- 4 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h index 57b5d7f..8665c2b 100644 --- a/include/osmocom/core/msgb.h +++ b/include/osmocom/core/msgb.h @@ -181,7 +181,7 @@ static inline void msgb_reserve(struct msgb *msg, int len) static inline struct msgb *msgb_alloc_headroom(int size, int headroom, const char *name) { - static_assert(size > headroom, headroom_bigger); + osmo_static_assert(size > headroom, headroom_bigger);
struct msgb *msg = msgb_alloc(size, name); if (msg) diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h index 252228d..0f1ea3b 100644 --- a/include/osmocom/core/utils.h +++ b/include/osmocom/core/utils.h @@ -13,16 +13,16 @@ struct value_string { const char *get_value_string(const struct value_string *vs, uint32_t val); int get_string_value(const struct value_string *vs, const char *str);
-char bcd2char(uint8_t bcd); +char osmo_bcd2char(uint8_t bcd); /* only works for numbers in ascci */ -uint8_t char2bcd(char c); +uint8_t osmo_char2bcd(char c);
-int hexparse(const char *str, uint8_t *b, int max_len); -char *hexdump(const unsigned char *buf, int len); -char *hexdump_nospc(const unsigned char *buf, int len); -char *ubit_dump(const uint8_t *bits, unsigned int len); +int osmo_hexparse(const char *str, uint8_t *b, int max_len); +char *osmo_hexdump(const unsigned char *buf, int len); +char *osmo_osmo_hexdump_nospc(const unsigned char *buf, int len); +char *osmo_ubit_dump(const uint8_t *bits, unsigned int len);
-#define static_assert(exp, name) typedef int dummy##name [(exp) ? 1 : -1]; +#define osmo_static_assert(exp, name) typedef int dummy##name [(exp) ? 1 : -1];
void osmo_str2lower(char *out, const char *in); void osmo_str2upper(char *out, const char *in); diff --git a/src/gsm/gsm48.c b/src/gsm/gsm48.c index 436bf14..d034589 100644 --- a/src/gsm/gsm48.c +++ b/src/gsm/gsm48.c @@ -301,7 +301,7 @@ int gsm48_generate_mid_from_imsi(uint8_t *buf, const char *imsi) uint8_t odd = (length & 0x1) == 1;
buf[0] = GSM48_IE_MOBILE_ID; - buf[2] = char2bcd(imsi[0]) << 4 | GSM_MI_TYPE_IMSI | (odd << 3); + buf[2] = osmo_char2bcd(imsi[0]) << 4 | GSM_MI_TYPE_IMSI | (odd << 3);
/* if the length is even we will fill half of the last octet */ if (odd) @@ -312,11 +312,11 @@ int gsm48_generate_mid_from_imsi(uint8_t *buf, const char *imsi) for (i = 1; i < buf[1]; ++i) { uint8_t lower, upper;
- lower = char2bcd(imsi[++off]); + lower = osmo_char2bcd(imsi[++off]); if (!odd && off + 1 == length) upper = 0x0f; else - upper = char2bcd(imsi[++off]) & 0x0f; + upper = osmo_char2bcd(imsi[++off]) & 0x0f;
buf[2 + i] = (upper << 4) | lower; } @@ -349,15 +349,15 @@ int gsm48_mi_to_string(char *string, const int str_len, const uint8_t *mi, case GSM_MI_TYPE_IMSI: case GSM_MI_TYPE_IMEI: case GSM_MI_TYPE_IMEISV: - *str_cur++ = bcd2char(mi[0] >> 4); + *str_cur++ = osmo_bcd2char(mi[0] >> 4);
for (i = 1; i < mi_len; i++) { if (str_cur + 2 >= string + str_len) return str_cur - string; - *str_cur++ = bcd2char(mi[i] & 0xf); + *str_cur++ = osmo_bcd2char(mi[i] & 0xf); /* skip last nibble in last input byte when GSM_EVEN */ if( (i != mi_len-1) || (mi[0] & GSM_MI_ODD)) - *str_cur++ = bcd2char(mi[i] >> 4); + *str_cur++ = osmo_bcd2char(mi[i] >> 4); } break; default: diff --git a/src/utils.c b/src/utils.c index af1829c..3ee14ab 100644 --- a/src/utils.c +++ b/src/utils.c @@ -35,7 +35,7 @@ int get_string_value(const struct value_string *vs, const char *str) return -EINVAL; }
-char bcd2char(uint8_t bcd) +char osmo_bcd2char(uint8_t bcd) { if (bcd < 0xa) return '0' + bcd; @@ -44,12 +44,12 @@ char bcd2char(uint8_t bcd) }
/* only works for numbers in ascii */ -uint8_t char2bcd(char c) +uint8_t osmo_char2bcd(char c) { return c - 0x30; }
-int hexparse(const char *str, uint8_t *b, int max_len) +int osmo_hexparse(const char *str, uint8_t *b, int max_len)
{ int i, l, v; @@ -78,7 +78,7 @@ int hexparse(const char *str, uint8_t *b, int max_len)
static char hexd_buff[4096];
-static char *_hexdump(const unsigned char *buf, int len, char *delim) +static char *_osmo_hexdump(const unsigned char *buf, int len, char *delim) { int i; char *cur = hexd_buff; @@ -95,7 +95,7 @@ static char *_hexdump(const unsigned char *buf, int len, char *delim) return hexd_buff; }
-char *ubit_dump(const uint8_t *bits, unsigned int len) +char *osmo_ubit_dump(const uint8_t *bits, unsigned int len) { int i;
@@ -125,14 +125,14 @@ char *ubit_dump(const uint8_t *bits, unsigned int len) return hexd_buff; }
-char *hexdump(const unsigned char *buf, int len) +char *osmo_hexdump(const unsigned char *buf, int len) { - return _hexdump(buf, len, " "); + return _osmo_hexdump(buf, len, " "); }
-char *hexdump_nospc(const unsigned char *buf, int len) +char *osmo_osmo_hexdump_nospc(const unsigned char *buf, int len) { - return _hexdump(buf, len, ""); + return _osmo_hexdump(buf, len, ""); }
#include "../config.h"
From: Pablo Neira Ayuso pablo@gnumonks.org
Summary of changes:
s/crc16_table/osmo_crc16_table/g s/crc16/osmo_crc16/g s/crc16_byte/osmo_crc16_byte/g --- include/osmocom/core/crc16.h | 8 ++++---- src/crc16.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/include/osmocom/core/crc16.h b/include/osmocom/core/crc16.h index 7a51249..0e52417 100644 --- a/include/osmocom/core/crc16.h +++ b/include/osmocom/core/crc16.h @@ -22,13 +22,13 @@
#include <sys/types.h>
-extern uint16_t const crc16_table[256]; +extern uint16_t const osmo_crc16_table[256];
-extern uint16_t crc16(uint16_t crc, const uint8_t *buffer, size_t len); +extern uint16_t osmo_crc16(uint16_t crc, const uint8_t *buffer, size_t len);
-static inline uint16_t crc16_byte(uint16_t crc, const uint8_t data) +static inline uint16_t osmo_crc16_byte(uint16_t crc, const uint8_t data) { - return (crc >> 8) ^ crc16_table[(crc ^ data) & 0xff]; + return (crc >> 8) ^ osmo_crc16_table[(crc ^ data) & 0xff]; }
#endif /* __CRC16_H */ diff --git a/src/crc16.c b/src/crc16.c index 3a0d0dd..2741cf5 100644 --- a/src/crc16.c +++ b/src/crc16.c @@ -11,7 +11,7 @@ #include <osmocom/core/crc16.h>
/** CRC table for the CRC-16. The poly is 0x8005 (x^16 + x^15 + x^2 + 1) */ -uint16_t const crc16_table[256] = { +uint16_t const osmo_crc16_table[256] = { 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440, 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40, @@ -54,9 +54,9 @@ uint16_t const crc16_table[256] = { * * Returns the updated CRC value. */ -uint16_t crc16(uint16_t crc, uint8_t const *buffer, size_t len) +uint16_t osmo_crc16(uint16_t crc, uint8_t const *buffer, size_t len) { while (len--) - crc = crc16_byte(crc, *buffer++); + crc = osmo_crc16_byte(crc, *buffer++); return crc; }
From: Pablo Neira Ayuso pablo@gnumonks.org
Summary of changes:
s/backtrace/osmo_backtrace/g --- include/osmocom/core/backtrace.h | 2 +- src/backtrace.c | 2 +- src/panic.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/osmocom/core/backtrace.h b/include/osmocom/core/backtrace.h index bbbb2c2..5a8a816 100644 --- a/include/osmocom/core/backtrace.h +++ b/include/osmocom/core/backtrace.h @@ -1,6 +1,6 @@ #ifndef _OSMO_BACKTRACE_H_ #define _OSMO_BACKTRACE_H_
-void generate_backtrace(); +void osmo_generate_backtrace();
#endif diff --git a/src/backtrace.c b/src/backtrace.c index ecd6b9c..8281fad 100644 --- a/src/backtrace.c +++ b/src/backtrace.c @@ -29,7 +29,7 @@
#ifdef HAVE_EXECINFO_H #include <execinfo.h> -void generate_backtrace() +void osmo_generate_backtrace() { int i, nptrs; void *buffer[100]; diff --git a/src/panic.c b/src/panic.c index 588a5fe..d445226 100644 --- a/src/panic.c +++ b/src/panic.c @@ -38,7 +38,7 @@ static osmo_panic_handler_t osmo_panic_handler = (void*)0; static void osmo_panic_default(const char *fmt, va_list args) { vfprintf(stderr, fmt, args); - generate_backtrace(); + osmo_generate_backtrace(); abort(); }
From: Pablo Neira Ayuso pablo@gnumonks.org
Summary of changes:
s/plugin_load_all/osmo_plugin_load_all/g --- include/osmocom/core/plugin.h | 2 +- src/gsm/gprs_cipher_core.c | 2 +- src/plugin.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/osmocom/core/plugin.h b/include/osmocom/core/plugin.h index 98f9b56..6c0eccc 100644 --- a/include/osmocom/core/plugin.h +++ b/include/osmocom/core/plugin.h @@ -1,6 +1,6 @@ #ifndef _OSMO_PLUGIN_H #define _OSMO_PLUGIN_H
-int plugin_load_all(const char *directory); +int osmo_plugin_load_all(const char *directory);
#endif diff --git a/src/gsm/gprs_cipher_core.c b/src/gsm/gprs_cipher_core.c index 0ff85e2..7884be0 100644 --- a/src/gsm/gprs_cipher_core.c +++ b/src/gsm/gprs_cipher_core.c @@ -53,7 +53,7 @@ int gprs_cipher_register(struct gprs_cipher_impl *ciph) int gprs_cipher_load(const char *path) { /* load all plugins available from path */ - return plugin_load_all(path); + return osmo_plugin_load_all(path); }
/* function to be called by core code */ diff --git a/src/plugin.c b/src/plugin.c index 4d9fd31..998bca3 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -32,7 +32,7 @@
#include <osmocom/core/plugin.h>
-int plugin_load_all(const char *directory) +int osmo_plugin_load_all(const char *directory) { unsigned int num = 0; char fname[PATH_MAX]; @@ -55,7 +55,7 @@ int plugin_load_all(const char *directory) return num; } #else -int plugin_load_all(const char *directory) +int osmo_plugin_load_all(const char *directory) { return 0; }
From: Pablo Neira Ayuso pablo@gnumonks.org
Summary of changes:
s/msg_entry/osmo_config_entry/g s/msg_entries/osmo_config_list/g s/msg_entry_parse/osmo_config_list_parse/g
minor glitch included in this patch while I was at it:
-#include "linuxlist.h" +#include <osmocom/core/linuxlist.h> --- include/osmocom/core/msgfile.h | 8 ++++---- src/msgfile.c | 22 ++++++++++++---------- tests/msgfile/msgfile_test.c | 8 ++++---- 3 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/include/osmocom/core/msgfile.h b/include/osmocom/core/msgfile.h index 92caa9f..c5e67a4 100644 --- a/include/osmocom/core/msgfile.h +++ b/include/osmocom/core/msgfile.h @@ -22,12 +22,12 @@ #ifndef MSG_FILE_H #define MSG_FILE_H
-#include "linuxlist.h" +#include <osmocom/core/linuxlist.h>
/** * One message in the list. */ -struct msg_entry { +struct osmo_config_entry { struct llist_head list;
/* number for everyone to use */ @@ -40,10 +40,10 @@ struct msg_entry { char *text; };
-struct msg_entries { +struct osmo_config_list { struct llist_head entry; };
-struct msg_entries *msg_entry_parse(void *ctx, const char *filename); +struct osmo_config_list* osmo_config_list_parse(void *ctx, const char *filename);
#endif diff --git a/src/msgfile.c b/src/msgfile.c index c13df51..d2b180d 100644 --- a/src/msgfile.c +++ b/src/msgfile.c @@ -29,11 +29,13 @@ #include <unistd.h> #include <string.h>
-static struct msg_entry *alloc_entry(struct msg_entries *entries, - const char *mcc, const char *mnc, - const char *option, const char *text) +static struct osmo_config_entry * +alloc_entry(struct osmo_config_list *entries, + const char *mcc, const char *mnc, + const char *option, const char *text) { - struct msg_entry *entry = talloc_zero(entries, struct msg_entry); + struct osmo_config_entry *entry = + talloc_zero(entries, struct osmo_config_entry); if (!entry) return NULL;
@@ -46,11 +48,11 @@ static struct msg_entry *alloc_entry(struct msg_entries *entries, return entry; }
-static struct msg_entries *alloc_entries(void *ctx) +static struct osmo_config_list *alloc_entries(void *ctx) { - struct msg_entries *entries; + struct osmo_config_list *entries;
- entries = talloc_zero(ctx, struct msg_entries); + entries = talloc_zero(ctx, struct osmo_config_list); if (!entries) return NULL;
@@ -61,7 +63,7 @@ static struct msg_entries *alloc_entries(void *ctx) /* * split a line like 'foo:Text'. */ -static void handle_line(struct msg_entries *entries, char *line) +static void handle_line(struct osmo_config_list *entries, char *line) { int i; const int len = strlen(line); @@ -91,9 +93,9 @@ static void handle_line(struct msg_entries *entries, char *line) /* nothing found */ }
-struct msg_entries *msg_entry_parse(void *ctx, const char *filename) +struct osmo_config_list *osmo_config_list_parse(void *ctx, const char *filename) { - struct msg_entries *entries; + struct osmo_config_list *entries; size_t n; char *line; FILE *file; diff --git a/tests/msgfile/msgfile_test.c b/tests/msgfile/msgfile_test.c index 4637cea..ed7aa97 100644 --- a/tests/msgfile/msgfile_test.c +++ b/tests/msgfile/msgfile_test.c @@ -23,9 +23,9 @@
#include <stdio.h>
-static void dump_entries(struct msg_entries *entries) +static void dump_entries(struct osmo_config_list *entries) { - struct msg_entry *entry; + struct osmo_config_entry *entry;
if (!entries) { fprintf(stderr, "Failed to parse the file\n"); @@ -40,10 +40,10 @@ static void dump_entries(struct msg_entries *entries)
int main(int argc, char **argv) { - struct msg_entries *entries; + struct osmo_config_list *entries;
/* todo use msgfile_test.c.in and replace the path */ - entries = msg_entry_parse(NULL, "msgconfig.cfg"); + entries = osmo_config_list_parse(NULL, "msgconfig.cfg"); dump_entries(entries);
return 0;