Go to the source code of this file.
Functions | |
void | try_next_nick () |
void | try_random_nick () |
void | nick_list_on_connect () |
const char * | nick_get_next () |
int | nick_add (const char *) |
int | nick_del (int) |
int | nick_clear () |
int | nick_find (const char *) |
Variables | |
char ** | nick_list |
int | nick_list_len |
int nick_add | ( | const char * | ) |
Definition at line 71 of file nicklist.c.
References nick_list, and nick_list_len.
00072 { 00073 nick_list = realloc(nick_list, sizeof(char *) * (nick_list_len+1)); 00074 nick_list[nick_list_len] = strdup(nick); 00075 nick_list_len++; 00076 return(0); 00077 }
int nick_clear | ( | ) |
Definition at line 93 of file nicklist.c.
References nick_list, nick_list_len, and NULL.
00094 { 00095 int i; 00096 00097 for (i = 0; i < nick_list_len; i++) free(nick_list[i]); 00098 if (nick_list) free(nick_list); 00099 nick_list = NULL; 00100 nick_list_len = 0; 00101 00102 return(0); 00103 }
int nick_del | ( | int | ) |
Definition at line 80 of file nicklist.c.
References nick_list, nick_list_index, and nick_list_len.
00081 { 00082 if (num < 0 || num >= nick_list_len) return(-1); /* Invalid nick index. */ 00083 00084 free(nick_list[num]); 00085 memmove(nick_list + num, nick_list + num + 1, sizeof(*nick_list) * (nick_list_len - num - 1)); 00086 nick_list_len--; 00087 if (num < nick_list_index) nick_list_index--; 00088 00089 return(0); 00090 }
int nick_find | ( | const char * | ) |
Definition at line 106 of file nicklist.c.
References nick_list, and nick_list_len.
00107 { 00108 int i; 00109 00110 for (i = 0; i < nick_list_len; i++) { 00111 if (!nick || !strcasecmp(nick_list[i], nick)) return(i); 00112 } 00113 return(-1); 00114 }
const char* nick_get_next | ( | ) |
Definition at line 57 of file nicklist.c.
References nick_list, nick_list_cycled, nick_list_index, nick_list_len, and NULL.
00058 { 00059 if (nick_list_len <= 0) return(NULL); 00060 nick_list_index++; 00061 if (nick_list_index >= nick_list_len) { 00062 if (nick_list_cycled) return(NULL); 00063 nick_list_cycled = 1; 00064 nick_list_index = 0; 00065 } 00066 00067 return(nick_list[nick_list_index]); 00068 }
void nick_list_on_connect | ( | ) |
Definition at line 50 of file nicklist.c.
References nick_list_cycled, and nick_list_index.
00051 { 00052 nick_list_index = -1; 00053 nick_list_cycled = 0; 00054 }
void try_next_nick | ( | ) |
Definition at line 31 of file nicklist.c.
References _, LOG_MISC, nick_get_next, nick_list_len, printserv, putlog(), SERVER_QUICK, and try_random_nick.
00032 { 00033 const char *nick; 00034 00035 nick = nick_get_next(); 00036 if (!nick) { 00037 putlog(LOG_MISC, "*", _("Using random nick because %s."), 00038 nick_list_len ? _("none of the defined nicks are valid") : _("there are no nicks defined")); 00039 try_random_nick(); 00040 return; 00041 } 00042 printserv(SERVER_QUICK, "NICK %s\r\n", nick); 00043 }
void try_random_nick | ( | ) |
Definition at line 45 of file nicklist.c.
References printserv, and SERVER_QUICK.
00046 { 00047 printserv(SERVER_QUICK, "NICK egg%d\r\n", random()); 00048 }
char** nick_list |
Definition at line 26 of file nicklist.c.
int nick_list_len |
Definition at line 28 of file nicklist.c.