/*---------------------------------------------------------------------------* * re-read the config file on SIGHUP or menu command *---------------------------------------------------------------------------*/ void rereadconfig(int dummy) { extern int entrycount; dolog(LL_DMN, "re-reading configuration file"); close_allactive(); #if I4B_EXTERNAL_MONITOR monitor_clear_rights(); #endif entrycount = -1; nentries = 0; /* read runtime configuration file and configure ourselves */ configure(configfile, 1); if(config_error_flag) { dolog(LL_ERR, "rereadconfig: there were %d error(s) in the configuration file, terminating!", config_error_flag); error_exit(1, "rereadconfig: there were %d error(s) in the configuration file, terminating!", config_error_flag); } if(aliasing) { /* reread alias database */ free_aliases(); init_alias(aliasfile); } }
void calc_color_alias(t_rt *img, t_ray *ray, t_obj *tmp) { t_obj *obj_result; init_alias(img, ray); obj_result = NULL; while (img && ray && tmp && tmp->color) { assign_ray(img, ray, tmp); obj_result = cast_ray(ray, tmp, obj_result); tmp = tmp->next; } if (obj_result != NULL && obj_result->color) { assign_ray(img, ray, obj_result); obj_result->color->color = perlin_color(img, ray, obj_result); lighting(ray, obj_result, img->spot); shadows(img, ray, obj_result); } }
/*---------------------------------------------------------------------------* * program entry *---------------------------------------------------------------------------*/ int main(int argc, char **argv) { int i; msg_vr_req_t mvr; #ifdef I4B_EXTERNAL_MONITOR int sockfd = -1; /* local monitor socket */ #ifndef I4B_NOTCPIP_MONITOR int remotesockfd = -1; /* tcp/ip monitor socket */ #endif #endif setlocale (LC_ALL, ""); while ((i = getopt(argc, argv, "mc:d:fFlL:Pr:s:t:u:")) != -1) { switch (i) { #ifdef I4B_EXTERNAL_MONITOR case 'm': inhibit_monitor = 1; break; #endif case 'c': configfile = optarg; break; #ifdef DEBUG case 'd': if(*optarg == 'n') debug_noscreen = 1; else if((sscanf(optarg, "%i", &debug_flags)) == 1) do_debug = 1; else usage(); break; #endif case 'f': do_fullscreen = 1; do_fork = 0; #ifndef USE_CURSES fprintf(stderr, "Sorry, no fullscreen mode available - daemon compiled without USE_CURSES\n"); exit(1); #endif break; case 'F': do_fork = 0; break; case 'l': uselogfile = 1; break; case 'L': strlcpy(logfile, optarg, sizeof(logfile)); break; case 'P': do_print = 1; break; case 'r': rdev = optarg; do_rdev = 1; break; case 's': if(isdigit(*optarg)) { int facility; logfacility = strtoul(optarg, NULL, 10); facility = logfacility << 3; if((facility < LOG_KERN) || (facility > LOG_FTP && facility < LOG_LOCAL0) || (facility > LOG_LOCAL7)) { fprintf(stderr, "Error, option -s has invalid logging facility %d", logfacility); usage(); } logfacility = facility; } else { fprintf(stderr, "Error: option -s requires a numeric argument!\n"); usage(); } break; case 't': ttype = optarg; do_ttytype = 1; break; case 'u': if(isdigit(*optarg)) { unit_length = strtoul(optarg, NULL, 10); if(unit_length < ULSRC_CMDLMIN) unit_length = ULSRC_CMDLMIN; else if(unit_length > ULSRC_CMDLMAX) unit_length = ULSRC_CMDLMAX; got_unitlen = 1; } else { fprintf(stderr, "Error: option -T requires a numeric argument!\n"); usage(); } break; case '?': default: usage(); break; } } #ifdef DEBUG if(!do_debug) debug_noscreen = 0; #endif if(!do_print) { umask(UMASK); /* set our umask ... */ init_log(); /* initialize the logging subsystem */ } check_pid(); /* check if we are already running */ if(!do_print) { if(do_fork || (do_fullscreen && do_rdev)) /* daemon mode ? */ daemonize(); write_pid(); /* write our pid to file */ /* set signal handler(s) */ signal(SIGCHLD, sigchild_handler); /* process handling */ signal(SIGHUP, rereadconfig); /* reread configuration */ signal(SIGUSR1, reopenfiles); /* reopen acct/log files*/ signal(SIGPIPE, SIG_IGN); /* handled manually */ signal(SIGINT, do_exit); /* clean up on SIGINT */ signal(SIGTERM, do_exit); /* clean up on SIGTERM */ signal(SIGQUIT, do_exit); /* clean up on SIGQUIT */ } /* open isdn device */ if((isdnfd = open(I4BDEVICE, O_RDWR)) < 0) { dolog(LL_ERR, "main: cannot open %s: %s", I4BDEVICE, strerror(errno)); exit(1); } /* check kernel and userland have same version/release numbers */ if((ioctl(isdnfd, I4B_VR_REQ, &mvr)) < 0) { dolog(LL_ERR, "main: ioctl I4B_VR_REQ failed: %s", strerror(errno)); do_exit(1); } if(mvr.version != VERSION) { dolog(LL_ERR, "main: version mismatch, kernel %d, daemon %d", mvr.version, VERSION); do_exit(1); } if(mvr.release != REL) { dolog(LL_ERR, "main: release mismatch, kernel %d, daemon %d", mvr.release, REL); do_exit(1); } if(mvr.step != STEP) { dolog(LL_ERR, "main: step mismatch, kernel %d, daemon %d", mvr.step, STEP); do_exit(1); } /* init controller state array */ init_controller(); /* read runtime configuration file and configure ourselves */ configure(configfile, 0); if(config_error_flag) { dolog(LL_ERR, "there were %d error(s) in the configuration file, terminating!", config_error_flag); exit(1); } /* set controller ISDN protocol */ init_controller_protocol(); /* init active controllers, if any */ signal(SIGCHLD, SIG_IGN); /*XXX*/ init_active_controller(); signal(SIGCHLD, sigchild_handler); /*XXX*/ /* handle the rates stuff */ if((i = readrates(ratesfile)) == ERROR) { if(rate_error != NULL) dolog(LL_ERR, "%s", rate_error); exit(1); } if(i == GOOD) { got_rate = 1; /* flag, ratesfile read and ok */ DBGL(DL_RCCF, (dolog(LL_DBG, "ratesfile %s read successfully", ratesfile))); } else { if(rate_error != NULL) dolog(LL_WRN, "%s", rate_error); } /* if writing accounting info, open file, set unbuffered */ if(useacctfile) { if((acctfp = fopen(acctfile, "a")) == NULL) { dolog(LL_ERR, "ERROR, can't open acctfile %s for writing, terminating!", acctfile); exit(1); } setvbuf(acctfp, NULL, _IONBF, 0); } /* initialize alias processing */ if(aliasing) init_alias(aliasfile); /* init holidays */ init_holidays(holidayfile); /* init remote monitoring */ #ifdef I4B_EXTERNAL_MONITOR if(do_monitor) { monitor_init(); sockfd = monitor_create_local_socket(); #ifndef I4B_NOTCPIP_MONITOR remotesockfd = monitor_create_remote_socket(monitorport); #endif } #endif /* in case fullscreendisplay, initialize */ #ifdef USE_CURSES if(do_fullscreen) { init_screen(); } #endif /* init realtime priority */ #ifdef USE_RTPRIO if(rt_prio != RTPRIO_NOTUSED) { struct rtprio rtp; rtp.type = RTP_PRIO_REALTIME; rtp.prio = rt_prio; if((rtprio(RTP_SET, getpid(), &rtp)) == -1) { dolog(LL_ERR, "rtprio failed: %s", strerror(errno)); do_exit(1); } } #endif starttime = time(NULL); /* get starttime */ srandom(580403); /* init random number gen */ mloop( /* enter loop of no return .. */ #ifdef I4B_EXTERNAL_MONITOR sockfd #ifndef I4B_NOTCPIP_MONITOR , remotesockfd #endif #endif ); do_exit(0); return(0); }
/*---------------------------------------------------------------------------* * program entry *---------------------------------------------------------------------------*/ int main(int argc, char **argv) { int i; int kchar; struct pollfd set[1]; char *ncp; const char *aliasfile = ALIASFILE; int rrtimeout = REREADTIMEOUT; extern char *optarg; setlocale( LC_ALL, ""); while ((i = getopt(argc, argv, "a:d:p:t:")) != -1) { switch (i) { case 'a': aliasfile = optarg; break; case 'd': spooldir = optarg; break; case 'p': playstring = optarg; break; case 't': rrtimeout = strtoul(optarg, &ncp, 10); if (*ncp) usage(); break; case '?': default: usage(); break; } } if (rrtimeout < 10) rrtimeout = 10; if ((chdir(spooldir)) != 0) fatal("cannot change directory to spooldir %s!", spooldir); init_alias(aliasfile); init_screen(); init_files(0); /* go into loop */ set[0].fd = STDIN_FILENO; set[0].events = POLLIN; for (;;) { /* if no char is available within timeout, reread spool */ if ((poll(set, 1, rrtimeout * 1000)) <= 0) { reread(); continue; } kchar = wgetch(main_w); /* get char */ switch (kchar) { case CR: case LF: #ifdef KEY_ENTER case KEY_ENTER: #endif do_menu(); break; case KEY_UP: /* up-move cursor */ if (cur_file && cur_file->prev) { cur_file = cur_file->prev; cur_pos--; } break; case TAB: case KEY_DOWN: /* down-move cursor */ if (cur_file && cur_file->next) { cur_file = cur_file->next; cur_pos++; } break; case KEY_HOME: /* move cursor to first dir */ break; case KEY_LL: /* move cursor to last file */ break; case CNTRL_D: do_quit(0); break; case CNTRL_L: /* refresh */ touchwin(curscr); wrefresh(curscr); break; } makecurrent(cur_pos, cur_file, 0); } do_quit(0); return(0); }