update redis one-key concept

Change-Id: Ifc164f5737decefef2463af57d75f717b97e169b
pull/316/head
Richard Fuchs 8 years ago
parent 9d8861afb3
commit f77726caa8

@ -176,7 +176,7 @@ option and which are reproduced below:
-k, --subscribe-keyspace Subscription keyspace list
--redis-num-threads=INT Number of Redis restore threads
--redis-expires=INT Expire time in seconds for redis keys
--redis-multikey=INT Use multiple redis keys for storing the call (old behaviour) DEPRECATED
--redis-multikey Use multiple redis keys for storing the call (old behaviour) DEPRECATED
-q, --no-redis-required Start even if can't connect to redis databases
-b, --b2b-url=STRING XMLRPC URL of B2B UA
-L, --log-level=INT Mask log priorities above this level

@ -299,7 +299,7 @@ static void options(int *argc, char ***argv) {
{ "redis-write",'w', 0, G_OPTION_ARG_STRING, &redisps_write, "Connect to Redis write database", "[PW@]IP:PORT/INT" },
{ "redis-num-threads", 0, 0, G_OPTION_ARG_INT, &redis_num_threads, "Number of Redis restore threads", "INT" },
{ "redis-expires", 0, 0, G_OPTION_ARG_INT, &redis_expires, "Expire time in seconds for redis keys", "INT" },
{ "redis-multikey", 0, 0, G_OPTION_ARG_NONE, &redis_multikey, "Use multiple redis keys for storing the call (old behaviour) DEPRECATED", "INT" },
{ "redis-multikey", 0, 0, G_OPTION_ARG_NONE, &redis_multikey, "Use multiple redis keys for storing the call (old behaviour) DEPRECATED", NULL },
{ "no-redis-required", 'q', 0, G_OPTION_ARG_NONE, &no_redis_required, "Start no matter of redis connection state", NULL },
{ "b2b-url", 'b', 0, G_OPTION_ARG_STRING, &b2b_url, "XMLRPC URL of B2B UA" , "STRING" },
{ "log-facility",0, 0, G_OPTION_ARG_STRING, &log_facility_s, "Syslog facility to use for logging", "daemon|local0|...|local7"},

File diff suppressed because it is too large Load Diff

@ -93,8 +93,6 @@ INLINE gboolean g_hash_table_insert_check(GHashTable *h, gpointer k, gpointer v)
#define rlog(l, x...) ilog(l | LOG_FLAG_RESTORE, x)
#define REDIS_FMT(x) (x)->len, (x)->str
void redis_notify_loop(void *d);

@ -48,3 +48,51 @@ char *rand_hex_str(char *rand_str, int num_bytes) {
}
return rand_str;
}
static const char *hex_chars = "0123456789abcdef";
int str_uri_encode_len(char *out, const char *in, int len) {
const char *end = in + len;
char *ori_out = out;
while (in < end) {
if (*in < ' ' || *in > '~' || *in == '%' || *in == '\\' || *in == '\'' || *in == '"') {
*(out++) = '%';
*(out++) = hex_chars[(*((unsigned char *) in)) >> 4];
*(out++) = hex_chars[(*((unsigned char *) in)) & 0xf];
in++;
continue;
}
*(out++) = *(in++);
}
*out = 0;
return out - ori_out;
}
int str_uri_decode_len(char **out, const char *in, int in_len) {
const char *end = in + in_len;
*out = malloc(in_len + 1);
char *outp = *out;
while (in < end) {
if (*in != '%') {
*(outp++) = (*in++);
continue;
}
if (end - in < 3 || !g_ascii_isxdigit(in[1]) || !g_ascii_isxdigit(in[2])) {
free(*out);
*out = NULL;
return -1;
}
unsigned char c = g_ascii_xdigit_value(in[1]) << 4 | g_ascii_xdigit_value(in[2]);
*(outp++) = c;
in += 3;
}
*outp = 0;
return outp - *out;
}

@ -56,6 +56,8 @@ INLINE str *str_dup(const str *s);
INLINE str *str_chunk_insert(GStringChunk *c, const str *s);
/* shifts pointer by len chars and decrements len. returns -1 if buffer too short, 0 otherwise */
INLINE int str_shift(str *s, int len);
/* eats the supplied string from the beginning of s. returns -1 if string head doesn't match */
INLINE int str_shift_cmp(str *s, const char *);
/* binary compares str object with memory chunk of equal size */
INLINE int str_memcmp(const str *s, void *m);
/* locate a substring within a string, returns character index or -1 */
@ -85,6 +87,12 @@ gboolean str_equal(gconstpointer a, gconstpointer b);
/* destroy function, frees a slice-alloc'd str */
void str_slice_free(void *);
/* saves "in" into "out" pseudo-URI encoded. "out" point to a buffer with sufficient length. returns length */
int str_uri_encode_len(char *out, const char *in, int in_len);
INLINE int str_uri_encode(char *out, const str *in);
/* reverse of the above. stores newly allocated buffer in *out. returns length */
int str_uri_decode_len(char **out, const char *in, int in_len);
@ -105,6 +113,16 @@ INLINE int str_shift(str *s, int len) {
s->len -= len;
return 0;
}
INLINE int str_shift_cmp(str *s, const char *t) {
int len = strlen(t);
if (s->len < len)
return -1;
if (memcmp(s->s, t, len))
return -1;
s->s += len;
s->len -= len;
return 0;
}
INLINE char *str_chr(const str *s, int c) {
return memchr(s->s, c, s->len);
}
@ -292,6 +310,10 @@ INLINE int str_token(str *new_token, str *ori_and_remainder, int sep) {
return 0;
}
INLINE int str_uri_encode(char *out, const str *in) {
return str_uri_encode_len(out, in->s, in->len);
}
/* Generates a hex string representing n random bytes. len(rand_str) = 2*num_bytes + 1 */
char *rand_hex_str(char *rand_str, int num_bytes);

Loading…
Cancel
Save