Changeset 82d3c1f in code
- Timestamp:
- Mar 7, 2014, 5:37:37 PM (11 years ago)
- Branches:
- master
- Children:
- 709589d
- Parents:
- 9c04f2a
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
icb.c
r9c04f2a r82d3c1f 551 551 extern int modtabcnt; 552 552 553 icbd_modupdate(); 553 554 if ((enforce ? 0 : modtabcnt == 0) || 554 555 bsearch(is->nick, modtab, modtabcnt, ICB_MAXNICKLEN, -
icb.h
r9c04f2a r82d3c1f 129 129 130 130 /* icb.c */ 131 struct icb_group *icb_addgroup(struct icb_session *, char *, char *); 132 void icb_cmdout(struct icb_session *, int, char *); 133 void icb_delgroup(struct icb_group *); 134 void icb_error(struct icb_session *, const char *, ...); 135 void icb_init(struct icbd_callbacks *); 136 void icb_input(struct icb_session *); 137 inline int icb_ismod(struct icb_group *, struct icb_session *); 138 int icb_modpermit(struct icb_session *, int); 139 int icb_pass(struct icb_group *, struct icb_session *, 140 struct icb_session *); 141 void icb_privmsg(struct icb_session *, char *, char *); 142 void icb_remove(struct icb_session *, char *); 143 void icb_sendfmt(struct icb_session *, const char *, ...); 144 void icb_start(struct icb_session *); 145 void icb_status(struct icb_session *, int, const char *, ...); 146 void icb_status_group(struct icb_group *, struct icb_session *, 131 struct icb_group * 132 icb_addgroup(struct icb_session *, char *, char *); 133 void icb_cmdout(struct icb_session *, int, char *); 134 void icb_delgroup(struct icb_group *); 135 void icb_error(struct icb_session *, const char *, ...); 136 void icb_init(struct icbd_callbacks *); 137 void icb_input(struct icb_session *); 138 inline int icb_ismod(struct icb_group *, struct icb_session *); 139 int icb_modpermit(struct icb_session *, int); 140 int icb_pass(struct icb_group *, struct icb_session *, 141 struct icb_session *); 142 void icb_privmsg(struct icb_session *, char *, char *); 143 void icb_remove(struct icb_session *, char *); 144 void icb_sendfmt(struct icb_session *, const char *, ...); 145 void icb_start(struct icb_session *); 146 void icb_status(struct icb_session *, int, const char *, ...); 147 void icb_status_group(struct icb_group *, struct icb_session *, 147 148 int, const char *, ...); 148 void 149 int 149 void icb_who(struct icb_session *, struct icb_group *); 150 int icb_vis(char *, const char *, size_t, int); 150 151 151 152 /* callbacks from icbd.c */ -
icbd.c
r9c04f2a r82d3c1f 44 44 45 45 uint64_t sessionid; 46 struct stat modtabst; 46 47 char modtabpath[MAXPATHLEN]; 47 48 char modtab[ICB_MTABLEN][ICB_MAXNICKLEN]; … … 64 65 void icbd_log(struct icb_session *, int, const char *, ...); 65 66 void icbd_grplist(char *); 66 void icbd_modtab(char *);67 67 void icbd_restrict(void); 68 68 void icbd_write(struct icb_session *, char *, ssize_t); 69 void icbd_signal(int);70 69 71 70 static inline int icbd_session_cmp(struct icb_session *, struct icb_session *); … … 82 81 main(int argc, char *argv[]) 83 82 { 84 struct event ev_sig;85 83 struct icbd_callbacks ic = { icbd_drop, icbd_log, icbd_write }; 86 84 const char *cause = NULL; … … 239 237 icbd_restrict(); 240 238 239 icbd_modupdate(); 240 241 241 (void)signal(SIGPIPE, SIG_IGN); 242 if (strlen(modtabpath) > 0) {243 icbd_modtab(modtabpath);244 signal_set(&ev_sig, SIGHUP,245 (void (*)(int, short, void *))icbd_signal, NULL);246 signal_add(&ev_sig, NULL);247 }248 242 249 243 (void)event_dispatch(); … … 549 543 550 544 void 551 icbd_modtab(char *mtab) 552 { 545 icbd_modupdate(void) 546 { 547 struct stat st; 553 548 FILE *fp; 554 549 char *buf, *lbuf; 555 550 size_t len; 556 551 557 if ((fp = fopen(mtab, "r")) == NULL) 558 err(EX_NOINPUT, "%s", mtab); 552 if (strlen(modtabpath) == 0) 553 return; 554 if (stat(modtabpath, &st)) { 555 syslog(LOG_ERR, "stat %s", modtabpath); 556 return; 557 } 558 /* see if there are any changes */ 559 if (timespeccmp(&st.st_mtim, &modtabst.st_mtim, ==) || 560 st.st_size == 0) 561 return; 562 563 if ((fp = fopen(modtabpath, "r")) == NULL) 564 err(EX_NOINPUT, "open %s", modtabpath); 559 565 560 566 modtabcnt = 0; … … 577 583 continue; 578 584 strlcpy(modtab[modtabcnt++], buf, ICB_MAXNICKLEN); 585 fprintf(stderr, "%s\n", buf); 579 586 } 580 587 free(lbuf); … … 584 591 585 592 fclose(fp); 586 }587 588 void589 icbd_signal(int sig)590 {591 switch (sig) {592 case SIGHUP:593 if (strlen(modtabpath) > 0)594 icbd_modtab(modtabpath);595 break;596 default:597 syslog(LOG_WARNING, "unexpected signal %d", sig);598 break;599 }600 593 } 601 594 -
icbd.h
r9c04f2a r82d3c1f 24 24 25 25 /* icbd.c */ 26 inline struct icb_session *icbd_session_lookup(uint64_t); 27 time_t getmonotime(void); 26 inline struct icb_session * 27 icbd_session_lookup(uint64_t); 28 void icbd_modupdate(void); 29 time_t getmonotime(void); 28 30 29 31 /* dns.c */ 30 32 struct sockaddr_storage; 31 int dns_init(void);32 void dns_rresolv(struct icb_session *, struct sockaddr_storage *);33 int dns_init(void); 34 void dns_rresolv(struct icb_session *, struct sockaddr_storage *); 33 35 34 36 /* logger.c */ 35 int logger_init(void);36 void logger(char *, char *, char *);37 int logger_init(void); 38 void logger(char *, char *, char *);
Note:
See TracChangeset
for help on using the changeset viewer.