75 |
|
void |
76 |
|
write_links_file(void* notused) |
77 |
|
{ |
78 |
< |
MessageFileLine *next_mptr = 0; |
79 |
< |
MessageFileLine *mptr = 0; |
80 |
< |
MessageFileLine *currentMessageLine = 0; |
81 |
< |
MessageFileLine *newMessageLine = 0; |
82 |
< |
MessageFile *MessageFileptr; |
83 |
< |
const char *p; |
78 |
> |
MessageFileLine *next_mptr = NULL; |
79 |
> |
MessageFileLine *mptr = NULL; |
80 |
> |
MessageFileLine *currentMessageLine = NULL; |
81 |
> |
MessageFileLine *newMessageLine = NULL; |
82 |
> |
MessageFile *MessageFileptr = &ConfigFileEntry.linksfile; |
83 |
|
FILE *file; |
84 |
|
char buff[512]; |
85 |
|
dlink_node *ptr; |
86 |
|
|
88 |
– |
MessageFileptr = &ConfigFileEntry.linksfile; |
89 |
– |
|
87 |
|
if ((file = fopen(MessageFileptr->fileName, "w")) == NULL) |
88 |
|
return; |
89 |
|
|
94 |
|
} |
95 |
|
|
96 |
|
MessageFileptr->contentsOfFile = NULL; |
100 |
– |
currentMessageLine = NULL; |
97 |
|
|
98 |
|
DLINK_FOREACH(ptr, global_serv_list.head) |
99 |
|
{ |
107 |
|
if (IsHidden(target_p)) |
108 |
|
continue; |
109 |
|
|
114 |
– |
if (target_p->info[0]) |
115 |
– |
p = target_p->info; |
116 |
– |
else |
117 |
– |
p = "(Unknown Location)"; |
118 |
– |
|
110 |
|
newMessageLine = MyMalloc(sizeof(MessageFileLine)); |
111 |
|
|
112 |
< |
/* Attempt to format the file in such a way it follows the usual links output |
112 |
> |
/* |
113 |
> |
* Attempt to format the file in such a way it follows the usual links output |
114 |
|
* ie "servername uplink :hops info" |
115 |
|
* Mostly for aesthetic reasons - makes it look pretty in mIRC ;) |
116 |
|
* - madmax |
117 |
|
*/ |
126 |
– |
|
127 |
– |
/* |
128 |
– |
* For now, check this ircsprintf wont overflow - it shouldnt on a |
129 |
– |
* default config but it is configurable.. |
130 |
– |
* This should be changed to an snprintf at some point, but I'm wanting to |
131 |
– |
* know if this is a cause of a bug - cryogen |
132 |
– |
*/ |
133 |
– |
assert(strlen(target_p->name) + strlen(me.name) + 6 + strlen(p) <= |
134 |
– |
MESSAGELINELEN); |
118 |
|
snprintf(newMessageLine->line, sizeof(newMessageLine->line), "%s %s :1 %s", |
119 |
< |
target_p->name, me.name, p); |
137 |
< |
newMessageLine->next = NULL; |
119 |
> |
target_p->name, me.name, target_p->info); |
120 |
|
|
121 |
|
if (MessageFileptr->contentsOfFile) |
122 |
|
{ |
130 |
|
currentMessageLine = newMessageLine; |
131 |
|
} |
132 |
|
|
133 |
< |
snprintf(buff, sizeof(buff), "%s %s :1 %s\n", target_p->name, me.name, p); |
133 |
> |
snprintf(buff, sizeof(buff), "%s %s :1 %s\n", |
134 |
> |
target_p->name, me.name, target_p->info); |
135 |
|
fputs(buff, file); |
136 |
|
} |
137 |
|
|