| 54 |
|
|
| 55 |
|
#define MIN_CONN_FREQ 300 |
| 56 |
|
|
| 57 |
+ |
dlink_list flatten_links; |
| 58 |
|
static dlink_list cap_list = { NULL, NULL, 0 }; |
| 59 |
|
static void server_burst(struct Client *); |
| 60 |
|
static void burst_all(struct Client *); |
| 73 |
|
* but in no particular order. |
| 74 |
|
*/ |
| 75 |
|
void |
| 76 |
< |
write_links_file(void* notused) |
| 76 |
> |
write_links_file(void *notused) |
| 77 |
|
{ |
| 78 |
< |
MessageFileLine *next_mptr = NULL; |
| 79 |
< |
MessageFileLine *mptr = NULL; |
| 80 |
< |
MessageFileLine *currentMessageLine = NULL; |
| 80 |
< |
MessageFileLine *newMessageLine = NULL; |
| 81 |
< |
MessageFile *MessageFileptr = &ConfigFileEntry.linksfile; |
| 82 |
< |
FILE *file; |
| 83 |
< |
char buff[512]; |
| 84 |
< |
dlink_node *ptr; |
| 78 |
> |
FILE *file = NULL; |
| 79 |
> |
dlink_node *ptr = NULL, *ptr_next = NULL;; |
| 80 |
> |
char buff[IRCD_BUFSIZE] = { '\0' }; |
| 81 |
|
|
| 82 |
< |
if ((file = fopen(MessageFileptr->fileName, "w")) == NULL) |
| 82 |
> |
if ((file = fopen(LIPATH, "w")) == NULL) |
| 83 |
|
return; |
| 84 |
|
|
| 85 |
< |
for (mptr = MessageFileptr->contentsOfFile; mptr; mptr = next_mptr) |
| 85 |
> |
DLINK_FOREACH_SAFE(ptr, ptr_next, flatten_links.head) |
| 86 |
|
{ |
| 87 |
< |
next_mptr = mptr->next; |
| 88 |
< |
MyFree(mptr); |
| 87 |
> |
dlinkDelete(ptr, &flatten_links); |
| 88 |
> |
MyFree(ptr->data); |
| 89 |
> |
free_dlink_node(ptr); |
| 90 |
|
} |
| 91 |
|
|
| 95 |
– |
MessageFileptr->contentsOfFile = NULL; |
| 96 |
– |
|
| 92 |
|
DLINK_FOREACH(ptr, global_serv_list.head) |
| 93 |
|
{ |
| 94 |
|
const struct Client *target_p = ptr->data; |
| 95 |
|
|
| 96 |
< |
/* skip ourselves, we send ourselves in /links */ |
| 97 |
< |
if (IsMe(target_p)) |
| 98 |
< |
continue; |
| 99 |
< |
|
| 100 |
< |
/* skip hidden servers */ |
| 106 |
< |
if (IsHidden(target_p)) |
| 96 |
> |
/* |
| 97 |
> |
* Skip hidden servers, aswell as ourselves, since we already send |
| 98 |
> |
* ourselves in /links |
| 99 |
> |
*/ |
| 100 |
> |
if (IsHidden(target_p) || IsMe(target_p)) |
| 101 |
|
continue; |
| 102 |
|
|
| 103 |
|
if (HasFlag(target_p, FLAGS_SERVICE) && ConfigServerHide.hide_services) |
| 104 |
|
continue; |
| 105 |
|
|
| 112 |
– |
newMessageLine = MyMalloc(sizeof(MessageFileLine)); |
| 113 |
– |
|
| 106 |
|
/* |
| 107 |
|
* Attempt to format the file in such a way it follows the usual links output |
| 108 |
|
* ie "servername uplink :hops info" |
| 109 |
|
* Mostly for aesthetic reasons - makes it look pretty in mIRC ;) |
| 110 |
|
* - madmax |
| 111 |
|
*/ |
| 112 |
< |
snprintf(newMessageLine->line, sizeof(newMessageLine->line), "%s %s :1 %s", |
| 113 |
< |
target_p->name, me.name, target_p->info); |
| 114 |
< |
|
| 115 |
< |
if (MessageFileptr->contentsOfFile) |
| 116 |
< |
{ |
| 125 |
< |
if (currentMessageLine) |
| 126 |
< |
currentMessageLine->next = newMessageLine; |
| 127 |
< |
currentMessageLine = newMessageLine; |
| 128 |
< |
} |
| 129 |
< |
else |
| 130 |
< |
{ |
| 131 |
< |
MessageFileptr->contentsOfFile = newMessageLine; |
| 132 |
< |
currentMessageLine = newMessageLine; |
| 133 |
< |
} |
| 112 |
> |
snprintf(buff, sizeof(buff), "%s %s :1 %s", target_p->name, |
| 113 |
> |
me.name, target_p->info); |
| 114 |
> |
dlinkAdd(xstrdup(buff), make_dlink_node(), &flatten_links); |
| 115 |
> |
snprintf(buff, sizeof(buff), "%s %s :1 %s\n", target_p->name, |
| 116 |
> |
me.name, target_p->info); |
| 117 |
|
|
| 135 |
– |
snprintf(buff, sizeof(buff), "%s %s :1 %s\n", |
| 136 |
– |
target_p->name, me.name, target_p->info); |
| 118 |
|
fputs(buff, file); |
| 119 |
|
} |
| 120 |
|
|