Loading src/client/Parse.c +2 −4 Original line number Original line Diff line number Diff line Loading @@ -8,14 +8,12 @@ #include "user.h" #include "user.h" #include "talker_privs.h" #include "talker_privs.h" #include "userio.h" #include "userio.h" #include "alias.h" extern unsigned long rights; extern unsigned long rights; extern CommandList chattable[]; extern CommandList chattable[]; extern struct user * const user; extern struct user * const user; #include "alias.h" extern Alias alias_list; static void shuffle_up(char *bp) static void shuffle_up(char *bp) { { /* The strlen is right its the length of bp, which is the length /* The strlen is right its the length of bp, which is the length Loading Loading @@ -108,7 +106,7 @@ int DoCommand(char *input, CommandList *cm) CommandList *found=NULL, *exact=NULL, *backup; CommandList *found=NULL, *exact=NULL, *backup; int count=0, ecount=0; int count=0, ecount=0; int c; int c; Alias al; alias *al; const char *dowhat; const char *dowhat; char *text; char *text; char *args = NULL, *ptr, *p2, *tmp; char *args = NULL, *ptr, *p2, *tmp; Loading src/client/alias.c +53 −81 Original line number Original line Diff line number Diff line Loading @@ -11,77 +11,52 @@ #include "userio.h" #include "userio.h" #include "alias.h" #include "alias.h" Alias alias_list=NULL; alias *alias_list = NULL; Alias bind_list=NULL; alias *bind_list = NULL; Alias rpc_list=NULL; alias *rpc_list = NULL; Alias event_list=NULL; alias *event_list = NULL; Alias onoff_list=NULL; alias *onoff_list = NULL; Alias ipc_list=NULL; alias *ipc_list = NULL; Alias force_list=NULL; alias *force_list = NULL; Alias shutdown_list=NULL; alias *shutdown_list = NULL; Alias eventin_list=NULL; alias *eventin_list = NULL; /* completely destroys the given list */ /* completely destroys the given list */ void DestroyAllLinks(Alias *list) void DestroyAllLinks(alias **list) { { Alias free_me; for (alias *node = *list; node != NULL; node = *list) { *list = node->next; while (*list!=NULL) free(node); { free((*list)->from); free((*list)->to); free_me = *list; *list = (*list)->next; free(free_me); } } } } /* removes the link given by 'name' in the list */ /* removes the link given by 'name' in the list */ int DestroyLink(Alias *list, const char *name) int DestroyLink(alias **list, const char *name) { { Alias prev, aptr; alias **prevnext = list; int found = 0; alias *entry = *list; aptr = *list; while (entry != NULL) { prev=NULL; if (!strcasecmp(entry->from, name)) while (aptr!=NULL) { if (!strcasecmp(aptr->from, name)) { found = 1; free(aptr->from); free(aptr->to); if (prev == NULL) { /* first */ *list = aptr->next; } else if (aptr->next == NULL) { /* last */ prev->next = NULL; } else { /* middle */ prev->next = aptr->next; } free(aptr); break; break; prevnext = &entry->next; entry = entry->next; } } prev = aptr; if (entry == NULL) aptr = aptr->next; return 0; /* Not found or empty */ } return(found); *prevnext = entry->next; free(entry); return 1; } } /* adds the 'from/to' node to the given list, or redefines if in existance */ /* adds the 'from/to' node to the given list, or redefines if in existance */ int AddLink(Alias *list, const char *from, const char *to) int AddLink(alias **list, const char *from, const char *to) { { Alias new; alias *new = *list; int redefine = 0; int redefine = 0; size_t size, fromsize; new=*list; while (new!=NULL && strcasecmp(new->from, from)) while (new!=NULL && strcasecmp(new->from, from)) new=new->next; new=new->next; Loading @@ -91,22 +66,24 @@ int AddLink(Alias *list, const char *from, const char *to) redefine = 1; redefine = 1; } } new=(Alias)malloc(sizeof(struct alias_record)); fromsize = strlen(from) + 1; new->from=malloc(sizeof(char) * (strlen(from) + 1)); size = sizeof(*new) + (strlen(to) + 1) + fromsize; new->to=malloc(sizeof(char) * (strlen(to) + 1)); new = calloc(1, size); new->from = (char *)(new + 1); new->to = new->from + fromsize; strcpy(new->from,from); strcpy(new->from,from); strcpy(new->to,to); strcpy(new->to,to); new->next = *list; new->next = *list; *list = new; *list = new; return (redefine); return redefine; } } /* displays the list */ /* displays the list */ void ShowLinks(Alias list, const char *prompt, const char *link, int count) void ShowLinks(alias *list, const char *prompt, const char *link, int count) { { char buff[10]; char buff[10]; Alias al; alias *al; int max; int max; int screen_height = screen_h(); int screen_height = screen_h(); Loading Loading @@ -159,25 +136,23 @@ void ShowLinks(Alias list, const char *prompt, const char *link, int count) } } } } char *FindLinks(Alias list, const char *from) char *FindLinks(alias *list, const char *from) { { Alias al; alias *al = list; al = list; while (al != NULL && strcasecmp(from, al->from)) while (al != NULL && strcasecmp(from, al->from)) { al = al->next; al = al->next; } if (al == NULL) if (al == NULL) return(NULL); return NULL; else return(strdup(al->to)); return strdup(al->to); } } /* bind listing autocompletion for scripts and tab-completion */ /* bind listing autocompletion for scripts and tab-completion */ char *list_bind(const char *text, int state) char *list_bind(const char *text, int state) { { static Alias bind; static alias *bind; static int len; static int len; char *name; char *name; Loading @@ -201,7 +176,7 @@ char *list_bind(const char *text, int state) /* bind listing autocompletion for readline */ /* bind listing autocompletion for readline */ char *list_bind_rl(const char *text, int state) char *list_bind_rl(const char *text, int state) { { static Alias bind; static alias *bind; static int len; static int len; char *name; char *name; Loading @@ -224,11 +199,8 @@ char *list_bind_rl(const char *text, int state) return NULL; return NULL; } } char *NextLink(Alias list, char *prev) char *NextLink(alias *al, char *prev) { { Alias al; al = list; if (prev) if (prev) { { while(al && strcasecmp(al->from, prev)) al = al->next; while(al && strcasecmp(al->from, prev)) al = al->next; Loading src/client/alias.h +19 −10 Original line number Original line Diff line number Diff line #ifndef ALIAS_H #ifndef ALIAS_H #define ALIAS_H #define ALIAS_H typedef struct alias_record typedef struct alias { { char *from; char *from; char *to; char *to; struct alias_record *next; struct alias *next; } *Alias; } alias; void DestroyAllLinks(Alias *list); void DestroyAllLinks(alias **list); int DestroyLink(Alias *list, const char *name); int DestroyLink(alias **list, const char *name); int AddLink(Alias *list, const char *from, const char *to); int AddLink(alias **list, const char *from, const char *to); void ShowLinks(Alias list, const char *prompt, const char *link, int count); void ShowLinks(alias *list, const char *prompt, const char *link, int count); char *FindLinks(Alias list, const char *from); char *FindLinks(alias *list, const char *from); char *list_bind(const char *text, int state); char *list_bind(const char *text, int state); char *list_bind_rl(const char *text, int state); char *list_bind_rl(const char *text, int state); char *NextLink(Alias list, char *prev); char *NextLink(alias *list, char *prev); extern alias *alias_list; extern alias *bind_list; extern alias *rpc_list; extern alias *event_list; extern alias *onoff_list; extern alias *ipc_list; extern alias *force_list; extern alias *shutdown_list; extern alias *eventin_list; #endif /* ALIAS_H */ #endif /* ALIAS_H */ src/client/incoming.c +0 −4 Original line number Original line Diff line number Diff line Loading @@ -31,10 +31,6 @@ #include <jansson.h> #include <jansson.h> #include <str_util.h> #include <str_util.h> extern Alias rpc_list; extern Alias event_list; extern Alias onoff_list; extern Alias ipc_list; extern struct user * const user; extern struct user * const user; extern int quietmode; extern int quietmode; extern ipc_connection_t *ipcsock; extern ipc_connection_t *ipcsock; Loading src/client/init.c +0 −10 Original line number Original line Diff line number Diff line Loading @@ -19,16 +19,6 @@ #include "js.h" #include "js.h" #include "init.h" #include "init.h" #include "user.h" #include "user.h" extern Alias alias_list; extern Alias bind_list; extern Alias rpc_list; extern Alias event_list; extern Alias onoff_list; extern Alias ipc_list; extern Alias force_list; extern Alias shutdown_list; #include "script.h" #include "script.h" #include "frl.h" #include "frl.h" Loading Loading
src/client/Parse.c +2 −4 Original line number Original line Diff line number Diff line Loading @@ -8,14 +8,12 @@ #include "user.h" #include "user.h" #include "talker_privs.h" #include "talker_privs.h" #include "userio.h" #include "userio.h" #include "alias.h" extern unsigned long rights; extern unsigned long rights; extern CommandList chattable[]; extern CommandList chattable[]; extern struct user * const user; extern struct user * const user; #include "alias.h" extern Alias alias_list; static void shuffle_up(char *bp) static void shuffle_up(char *bp) { { /* The strlen is right its the length of bp, which is the length /* The strlen is right its the length of bp, which is the length Loading Loading @@ -108,7 +106,7 @@ int DoCommand(char *input, CommandList *cm) CommandList *found=NULL, *exact=NULL, *backup; CommandList *found=NULL, *exact=NULL, *backup; int count=0, ecount=0; int count=0, ecount=0; int c; int c; Alias al; alias *al; const char *dowhat; const char *dowhat; char *text; char *text; char *args = NULL, *ptr, *p2, *tmp; char *args = NULL, *ptr, *p2, *tmp; Loading
src/client/alias.c +53 −81 Original line number Original line Diff line number Diff line Loading @@ -11,77 +11,52 @@ #include "userio.h" #include "userio.h" #include "alias.h" #include "alias.h" Alias alias_list=NULL; alias *alias_list = NULL; Alias bind_list=NULL; alias *bind_list = NULL; Alias rpc_list=NULL; alias *rpc_list = NULL; Alias event_list=NULL; alias *event_list = NULL; Alias onoff_list=NULL; alias *onoff_list = NULL; Alias ipc_list=NULL; alias *ipc_list = NULL; Alias force_list=NULL; alias *force_list = NULL; Alias shutdown_list=NULL; alias *shutdown_list = NULL; Alias eventin_list=NULL; alias *eventin_list = NULL; /* completely destroys the given list */ /* completely destroys the given list */ void DestroyAllLinks(Alias *list) void DestroyAllLinks(alias **list) { { Alias free_me; for (alias *node = *list; node != NULL; node = *list) { *list = node->next; while (*list!=NULL) free(node); { free((*list)->from); free((*list)->to); free_me = *list; *list = (*list)->next; free(free_me); } } } } /* removes the link given by 'name' in the list */ /* removes the link given by 'name' in the list */ int DestroyLink(Alias *list, const char *name) int DestroyLink(alias **list, const char *name) { { Alias prev, aptr; alias **prevnext = list; int found = 0; alias *entry = *list; aptr = *list; while (entry != NULL) { prev=NULL; if (!strcasecmp(entry->from, name)) while (aptr!=NULL) { if (!strcasecmp(aptr->from, name)) { found = 1; free(aptr->from); free(aptr->to); if (prev == NULL) { /* first */ *list = aptr->next; } else if (aptr->next == NULL) { /* last */ prev->next = NULL; } else { /* middle */ prev->next = aptr->next; } free(aptr); break; break; prevnext = &entry->next; entry = entry->next; } } prev = aptr; if (entry == NULL) aptr = aptr->next; return 0; /* Not found or empty */ } return(found); *prevnext = entry->next; free(entry); return 1; } } /* adds the 'from/to' node to the given list, or redefines if in existance */ /* adds the 'from/to' node to the given list, or redefines if in existance */ int AddLink(Alias *list, const char *from, const char *to) int AddLink(alias **list, const char *from, const char *to) { { Alias new; alias *new = *list; int redefine = 0; int redefine = 0; size_t size, fromsize; new=*list; while (new!=NULL && strcasecmp(new->from, from)) while (new!=NULL && strcasecmp(new->from, from)) new=new->next; new=new->next; Loading @@ -91,22 +66,24 @@ int AddLink(Alias *list, const char *from, const char *to) redefine = 1; redefine = 1; } } new=(Alias)malloc(sizeof(struct alias_record)); fromsize = strlen(from) + 1; new->from=malloc(sizeof(char) * (strlen(from) + 1)); size = sizeof(*new) + (strlen(to) + 1) + fromsize; new->to=malloc(sizeof(char) * (strlen(to) + 1)); new = calloc(1, size); new->from = (char *)(new + 1); new->to = new->from + fromsize; strcpy(new->from,from); strcpy(new->from,from); strcpy(new->to,to); strcpy(new->to,to); new->next = *list; new->next = *list; *list = new; *list = new; return (redefine); return redefine; } } /* displays the list */ /* displays the list */ void ShowLinks(Alias list, const char *prompt, const char *link, int count) void ShowLinks(alias *list, const char *prompt, const char *link, int count) { { char buff[10]; char buff[10]; Alias al; alias *al; int max; int max; int screen_height = screen_h(); int screen_height = screen_h(); Loading Loading @@ -159,25 +136,23 @@ void ShowLinks(Alias list, const char *prompt, const char *link, int count) } } } } char *FindLinks(Alias list, const char *from) char *FindLinks(alias *list, const char *from) { { Alias al; alias *al = list; al = list; while (al != NULL && strcasecmp(from, al->from)) while (al != NULL && strcasecmp(from, al->from)) { al = al->next; al = al->next; } if (al == NULL) if (al == NULL) return(NULL); return NULL; else return(strdup(al->to)); return strdup(al->to); } } /* bind listing autocompletion for scripts and tab-completion */ /* bind listing autocompletion for scripts and tab-completion */ char *list_bind(const char *text, int state) char *list_bind(const char *text, int state) { { static Alias bind; static alias *bind; static int len; static int len; char *name; char *name; Loading @@ -201,7 +176,7 @@ char *list_bind(const char *text, int state) /* bind listing autocompletion for readline */ /* bind listing autocompletion for readline */ char *list_bind_rl(const char *text, int state) char *list_bind_rl(const char *text, int state) { { static Alias bind; static alias *bind; static int len; static int len; char *name; char *name; Loading @@ -224,11 +199,8 @@ char *list_bind_rl(const char *text, int state) return NULL; return NULL; } } char *NextLink(Alias list, char *prev) char *NextLink(alias *al, char *prev) { { Alias al; al = list; if (prev) if (prev) { { while(al && strcasecmp(al->from, prev)) al = al->next; while(al && strcasecmp(al->from, prev)) al = al->next; Loading
src/client/alias.h +19 −10 Original line number Original line Diff line number Diff line #ifndef ALIAS_H #ifndef ALIAS_H #define ALIAS_H #define ALIAS_H typedef struct alias_record typedef struct alias { { char *from; char *from; char *to; char *to; struct alias_record *next; struct alias *next; } *Alias; } alias; void DestroyAllLinks(Alias *list); void DestroyAllLinks(alias **list); int DestroyLink(Alias *list, const char *name); int DestroyLink(alias **list, const char *name); int AddLink(Alias *list, const char *from, const char *to); int AddLink(alias **list, const char *from, const char *to); void ShowLinks(Alias list, const char *prompt, const char *link, int count); void ShowLinks(alias *list, const char *prompt, const char *link, int count); char *FindLinks(Alias list, const char *from); char *FindLinks(alias *list, const char *from); char *list_bind(const char *text, int state); char *list_bind(const char *text, int state); char *list_bind_rl(const char *text, int state); char *list_bind_rl(const char *text, int state); char *NextLink(Alias list, char *prev); char *NextLink(alias *list, char *prev); extern alias *alias_list; extern alias *bind_list; extern alias *rpc_list; extern alias *event_list; extern alias *onoff_list; extern alias *ipc_list; extern alias *force_list; extern alias *shutdown_list; extern alias *eventin_list; #endif /* ALIAS_H */ #endif /* ALIAS_H */
src/client/incoming.c +0 −4 Original line number Original line Diff line number Diff line Loading @@ -31,10 +31,6 @@ #include <jansson.h> #include <jansson.h> #include <str_util.h> #include <str_util.h> extern Alias rpc_list; extern Alias event_list; extern Alias onoff_list; extern Alias ipc_list; extern struct user * const user; extern struct user * const user; extern int quietmode; extern int quietmode; extern ipc_connection_t *ipcsock; extern ipc_connection_t *ipcsock; Loading
src/client/init.c +0 −10 Original line number Original line Diff line number Diff line Loading @@ -19,16 +19,6 @@ #include "js.h" #include "js.h" #include "init.h" #include "init.h" #include "user.h" #include "user.h" extern Alias alias_list; extern Alias bind_list; extern Alias rpc_list; extern Alias event_list; extern Alias onoff_list; extern Alias ipc_list; extern Alias force_list; extern Alias shutdown_list; #include "script.h" #include "script.h" #include "frl.h" #include "frl.h" Loading