]>
jfr.im git - irc/quakenet/newserv.git/blob - spawnuser/spawnuser.c
5 #include "../channel/channel.h"
6 #include "../control/control.h"
7 #include "../core/config.h"
8 #include "../localuser/localuser.h"
9 #include "../localuser/localuserchannel.h"
10 #include "../nick/nick.h"
11 #include "../irc/irc.h"
13 typedef struct spawnuser_user
16 struct spawnuser_user
*next
;
19 spawnuser_user
*spawnuser_users
;
21 void spawnuser_handlemessages(nick
*target
, int messagetype
, void **args
)
23 spawnuser_user
*spawnuser
;
25 switch ( messagetype
)
28 for ( spawnuser
= spawnuser_users
; spawnuser
; spawnuser
= spawnuser
->next
)
30 if ( target
== spawnuser
->user
)
32 Error("spawnuser", ERR_WARNING
, "A SpawnUser got killed");
33 spawnuser
->user
= NULL
;
44 char nickbuf
[NICKLEN
+ 1], hostbuf
[HOSTLEN
+ 1];
46 spawnuser_user
*spawnuser
;
47 channel
*spawnchannel
;
49 spawnuser_users
= NULL
;
51 for ( i
= 0; i
< 3000; i
++ )
53 snprintf(nickbuf
, NICKLEN
, "SU-%s-%d", mynick
->nick
, i
);
54 nickbuf
[NICKLEN
] = '\0';
55 snprintf(hostbuf
, HOSTLEN
, "SpawnUser-%s.netsplit.net", mynick
->nick
);
56 hostbuf
[HOSTLEN
] = '\0';
57 spawnuser
= malloc(sizeof(spawnuser_user
));
58 spawnuser
->user
= registerlocaluser(nickbuf
, "SpawnUser", hostbuf
, "SpawnUser", NULL
, UMODE_INV
, &spawnuser_handlemessages
);
60 spawnchannel
= findchannel("#twilightzone");
63 localcreatechannel(spawnuser
->user
, "#twilightzone");
65 localjoinchannel(spawnuser
->user
, spawnchannel
);
67 spawnuser
->next
= spawnuser_users
;
68 spawnuser_users
= spawnuser
;
74 spawnuser_user
*temp_spawnuser
;
76 while ( spawnuser_users
)
78 temp_spawnuser
= spawnuser_users
;
79 spawnuser_users
= temp_spawnuser
->next
;
81 if ( temp_spawnuser
->user
)
82 deregisterlocaluser(temp_spawnuser
->user
, "SpawnUser Unloaded");