utils: Refactor check_id out of protocol for global access
This commit is contained in:
parent
826ad11e41
commit
511b51ffe6
6 changed files with 13 additions and 24 deletions
|
@ -24,6 +24,7 @@
|
|||
#include "subnet.h"
|
||||
#include "tincctl.h"
|
||||
#include "info.h"
|
||||
#include "utils.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
void logger(int level, int priority, const char *format, ...) {
|
||||
|
|
|
@ -55,17 +55,6 @@ static char (*request_name[]) = {
|
|||
|
||||
static splay_tree_t *past_request_tree;
|
||||
|
||||
bool check_id(const char *id) {
|
||||
if(!id || !*id)
|
||||
return false;
|
||||
|
||||
for(; *id; id++)
|
||||
if(!isalnum(*id) && *id != '_')
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Generic request routines - takes care of logging and error
|
||||
detection as well */
|
||||
|
||||
|
|
|
@ -81,7 +81,6 @@ extern ecdsa_t *invitation_key;
|
|||
extern bool send_request(struct connection_t *, const char *, ...) __attribute__ ((__format__(printf, 2, 3)));
|
||||
extern void forward_request(struct connection_t *, const char *);
|
||||
extern bool receive_request(struct connection_t *, const char *);
|
||||
extern bool check_id(const char *);
|
||||
|
||||
extern void init_requests(void);
|
||||
extern void exit_requests(void);
|
||||
|
|
|
@ -1675,18 +1675,6 @@ static int cmd_config(int argc, char *argv[]) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool check_id(const char *name) {
|
||||
if(!name || !*name)
|
||||
return false;
|
||||
|
||||
for(int i = 0; i < strlen(name); i++) {
|
||||
if(!isalnum(name[i]) && name[i] != '_')
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool try_bind(int port) {
|
||||
struct addrinfo *ai = NULL;
|
||||
struct addrinfo hint = {
|
||||
|
|
11
src/utils.c
11
src/utils.c
|
@ -181,6 +181,17 @@ unsigned int bitfield_to_int(const void *bitfield, size_t size) {
|
|||
return value;
|
||||
}
|
||||
|
||||
bool check_id(const char *id) {
|
||||
if(!id || !*id)
|
||||
return false;
|
||||
|
||||
for(; *id; id++)
|
||||
if(!isalnum(*id) && *id != '_')
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
char *replace_name(const char *name) {
|
||||
char *ret_name;
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ extern const char *winerror(int);
|
|||
|
||||
extern unsigned int bitfield_to_int(const void *bitfield, size_t size);
|
||||
|
||||
extern bool check_id(const char *);
|
||||
char *replace_name(const char *name);
|
||||
|
||||
#endif /* __TINC_UTILS_H__ */
|
||||
|
|
Loading…
Reference in a new issue