int input() { char ch; start_check(); uart0GetChar(&ch); finish_check(); return (unsigned int)ch; }
int get() // usage: int i = get(int *ip) >>> i = *ip; { int ii, *ip; start_check(); eval_exp(&ii); finish_check(); ip = (int *)ii; return *ip; }
void delay() { int del; start_check(); eval_exp(&del); if ((del < 0) || (del > 1000000)) sntx_err(PARAM_ERR); delayMS(del ); finish_check(); }
void set() // usage: set(int *ip, int i) >>> *ip = i; { int ii, i, *ip; start_check(); eval_exp(&ii); get_token(); // look for comma separator if(*token != ',') sntx_err(SYNTAX); // syntax error eval_exp(&i); ip = (int *)ii; *ip = i; finish_check(); }
/* Reload thread */ int reload_check_thread(thread_t * thread) { /* set the reloading flag */ SET_RELOAD; log_message(LOG_INFO, "Got SIGHUP, reloading checker configuration"); /* Signals handling */ signal_handler_reset(); /* Destroy master thread */ #ifdef _WITH_VRRP_ kernel_netlink_close(); #endif thread_destroy_master(master); master = thread_make_master(); free_global_data(global_data); free_checkers_queue(); #ifdef _WITH_VRRP_ free_interface_queue(); #endif free_ssl(); ipvs_stop(); /* Save previous conf data */ old_check_data = check_data; check_data = NULL; /* Reload the conf */ #ifdef _DEBUG_ mem_allocated = 0; #endif check_signal_init(); signal_set(SIGCHLD, thread_child_handler, master); start_check(); /* free backup data */ free_check_data(old_check_data); UNSET_RELOAD; return 0; }
void motors() { int lspeed, rspeed; start_check(); eval_exp(&lspeed); if ((lspeed < -100) || (lspeed > 100)) sntx_err(PARAM_ERR); get_token(); // look for comma separator if(*token != ',') sntx_err(SYNTAX); // syntax error eval_exp(&rspeed); if ((rspeed < -100) || (rspeed > 100)) sntx_err(PARAM_ERR); setPWM(lspeed, rspeed); finish_check(); }
void print() { int i; start_check(); get_token(); while(*token !=')') { if(token_type==STRING) { uart0SendString(token); } else { putback(); eval_exp(&i); printNumber(10, 10, FALSE, ' ', i); } get_token(); } uart0SendChar('\n'); get_token(); if(*token!=';') sntx_err(SEMI_EXPECTED); putback(); }
/* Reload thread */ static int reload_check_thread(thread_t * thread) { /* set the reloading flag */ SET_RELOAD; log_message(LOG_INFO, "Got SIGHUP, reloading checker configuration"); /* Destroy master thread */ #ifdef _WITH_VRRP_ kernel_netlink_close(); #endif thread_cleanup_master(master); free_global_data(global_data); free_checkers_queue(); #ifdef _WITH_VRRP_ free_interface_queue(); #endif free_ssl(); ipvs_stop(); /* Save previous conf data */ old_check_data = check_data; check_data = NULL; /* Reload the conf */ #ifdef _MEM_CHECK_ mem_allocated = 0; #endif start_check(); /* free backup data */ free_check_data(old_check_data); UNSET_RELOAD; return 0; }
/* Reload thread */ int reload_check_thread(thread_t * thread) { /* set the reloading flag */ SET_RELOAD; /* Signals handling */ signal_reset(); signal_handler_destroy(); /* Destroy master thread */ thread_destroy_master(master); master = thread_make_master(); free_global_data(data); free_checkers_queue(); #ifdef _WITH_VRRP_ free_interface_queue(); #endif free_ssl(); ipvs_stop(); /* Save previous conf data */ old_check_data = check_data; check_data = NULL; /* Reload the conf */ mem_allocated = 0; check_signal_init(); signal_set(SIGCHLD, thread_child_handler, master); start_check(); /* free backup data */ free_check_data(old_check_data); UNSET_RELOAD; return 0; }
/* Register CHECK thread */ int start_check_child(void) { #ifndef _DEBUG_ pid_t pid; int ret; char *syslog_ident; /* Initialize child process */ pid = fork(); if (pid < 0) { log_message(LOG_INFO, "Healthcheck child process: fork error(%s)" , strerror(errno)); return -1; } else if (pid) { checkers_child = pid; log_message(LOG_INFO, "Starting Healthcheck child process, pid=%d" , pid); /* Start respawning thread */ thread_add_child(master, check_respawn_thread, NULL, pid, RESPAWN_TIMER); return 0; } if ((instance_name #if HAVE_DECL_CLONE_NEWNET || network_namespace #endif ) && (check_syslog_ident = make_syslog_ident(PROG_CHECK))) syslog_ident = check_syslog_ident; else syslog_ident = PROG_CHECK; /* Opening local CHECK syslog channel */ openlog(syslog_ident, LOG_PID | ((__test_bit(LOG_CONSOLE_BIT, &debug)) ? LOG_CONS : 0) , (log_facility==LOG_DAEMON) ? LOG_LOCAL2 : log_facility); #ifdef _MEM_CHECK_ mem_log_init(PROG_CHECK, "Healthcheck child process"); #endif free_parent_mallocs_startup(true); /* Child process part, write pidfile */ if (!pidfile_write(checkers_pidfile, getpid())) { log_message(LOG_INFO, "Healthcheck child process: cannot write pidfile"); exit(KEEPALIVED_EXIT_FATAL); } /* Create the new master thread */ signal_handler_destroy(); thread_destroy_master(master); /* This destroys any residual settings from the parent */ master = thread_make_master(); /* change to / dir */ ret = chdir("/"); if (ret < 0) { log_message(LOG_INFO, "Healthcheck child process: error chdir"); } /* Set mask */ umask(0); #endif /* If last process died during a reload, we can get there and we * don't want to loop again, because we're not reloading anymore. */ UNSET_RELOAD; /* Signal handling initialization */ check_signal_init(); /* Start Healthcheck daemon */ start_check(); /* Launch the scheduling I/O multiplexer */ launch_scheduler(); /* Finish healthchecker daemon process */ stop_check(EXIT_SUCCESS); /* unreachable */ exit(EXIT_SUCCESS); }
/* Register CHECK thread */ int start_check_child(void) { #ifndef _DEBUG_ pid_t pid; int ret; /* Initialize child process */ pid = fork(); if (pid < 0) { log_message(LOG_INFO, "Healthcheck child process: fork error(%s)" , strerror(errno)); return -1; } else if (pid) { checkers_child = pid; log_message(LOG_INFO, "Starting Healthcheck child process, pid=%d" , pid); /* Start respawning thread */ thread_add_child(master, check_respawn_thread, NULL, pid, RESPAWN_TIMER); return 0; } /* Opening local CHECK syslog channel */ openlog(PROG_CHECK, LOG_PID | ((__test_bit(LOG_CONSOLE_BIT, &debug)) ? LOG_CONS : 0) , (log_facility==LOG_DAEMON) ? LOG_LOCAL2 : log_facility); /* Child process part, write pidfile */ if (!pidfile_write(checkers_pidfile, getpid())) { log_message(LOG_INFO, "Healthcheck child process: cannot write pidfile"); exit(0); } /* Create the new master thread */ signal_handler_destroy(); thread_destroy_master(master); master = thread_make_master(); /* change to / dir */ ret = chdir("/"); if (ret < 0) { log_message(LOG_INFO, "Healthcheck child process: error chdir"); } /* Set mask */ umask(0); #endif /* If last process died during a reload, we can get there and we * don't want to loop again, because we're not reloading anymore. */ UNSET_RELOAD; /* Signal handling initialization */ check_signal_init(); /* Start Healthcheck daemon */ start_check(); /* Launch the scheduling I/O multiplexer */ launch_scheduler(); /* Finish healthchecker daemon process */ stop_check(); exit(0); }
int time() { start_check(); finish_check(); return readRTC(); }