EepromIo_c& EepromIo_c::writeIntern(const uint8_t* apb_data, uint8_t aui8_len) { if ( ! eofp( aui8_len ) ) { write (mui16_wPosition, aui8_len, apb_data); mui16_wPosition += aui8_len; //inkrement position } return *this; }
static void timer_io_read (sexpr sx, struct sexpr_io *io, void *aux) { if (eofp (sx)) { output_remove (io); return; } event_add (sx); event_queue (); }
static void on_script_read (sexpr sx, struct sexpr_io *io, void *p) { if (eofp (sx)) { script_reading_finished (); } else { monitor_script = cons (sx, monitor_script); } }
int cmain () { int i; multiplex_signal(); multiplex_sexpr(); output_add (sx_open_stdio ()); for (i = 1; curie_argv [i] != (char *)0; i++) { int j = 0; struct io *in; struct sexpr_io *io; sexpr sx; while (curie_argv[i][j] != (char)0) j++; j++; in = io_open_buffer (curie_argv[i], j); io = sx_open_i (in); while (!eofp (sx = sx_read (io)) && !nexp (sx)) { timer_io_read (sx, (struct sexpr_io *)0, (void *)0); } } multiplex_add_signal (sig_alrm, timer_signal, (void *)0); multiplex_add_signal (sig_vtalrm, timer_signal, (void *)0); multiplex_add_signal (sig_hup, term_signal, (void *)0); multiplex_add_signal (sig_segv, term_signal, (void *)0); multiplex_add_signal (sig_term, term_signal, (void *)0); while (multiplex() != mx_nothing_to_do); return 0; }
static void include_on_read (sexpr sx, struct sexpr_io *io, void *aux) { struct transdata *td = (struct transdata *)aux; if (eofp (sx)) { td->done = 1; } else if (consp (sx)) { sexpr n = car (sx); if (truep (equalp (sym_object, n))) { (*(td->data)) = cons (lx_eval (sx, (td->environment)), (*(td->data))); } else { (*(td->data)) = cons (sx, (*(td->data))); } } }
static void on_script_file_read (sexpr sx, struct sexpr_io *io, void *p) { if (consp (sx)) { sexpr a = car (sx), mt, b, c; struct kyu_module *mo; char daemon = 0; if (truep (equalp (sym_init_script, a)) || (daemon = truep (equalp (sym_daemon, a)))) { sexpr name = sx_nonexistent, description = sx_nonexistent, provides = sx_end_of_list, requires = sx_end_of_list, before = sx_end_of_list, after = sx_end_of_list, conflicts = sx_end_of_list, schedulerflags = sx_end_of_list, functions = sx_end_of_list, functiondata = sx_end_of_list, binary = sx_end_of_list, pidfile = sx_end_of_list, startcommand = sx_end_of_list, stopcommand = sx_true, parameters = sx_end_of_list, module; if (daemon) { functions = cons (sym_stop, cons (sym_start, functions)); } a = cdr (sx); name = car (a); a = cdr (a); description = car (a); a = cdr (a); while (consp (a)) { sexpr v = car (a); sexpr va = car (v); if (truep (equalp (sym_provides, va))) { provides = sx_set_merge (provides, cdr (v)); } else if (truep (equalp (sym_requires, va))) { requires = sx_set_merge (requires, cdr (v)); } else if (truep (equalp (sym_conflicts_with, va))) { conflicts = sx_set_merge (conflicts, cdr (v)); } else if (truep (equalp (sym_before, va))) { before = sx_set_merge (before, cdr (v)); } else if (truep (equalp (sym_after, va))) { after = sx_set_merge (after, cdr (v)); } else if (truep (equalp (sym_schedule_limitations, va))) { schedulerflags = sx_set_merge (schedulerflags, cdr (v)); } else if (truep (equalp (sym_functions, va))) { functiondata = sx_set_merge (functiondata, cdr (v)); } else if (truep (equalp (sym_pid_file, va))) { pidfile = sx_set_merge (pidfile, cdr (v)); } else if (truep (equalp (sym_binary, va))) { binary = sx_set_merge (binary, cdr (v)); } else if (truep (equalp (sym_parameters, va))) { parameters = sx_set_merge (parameters, cdr (c)); } a = cdr (a); } if (!eolp (binary)) { for (a = binary; consp (a); a = cdr (a)) { b = car (a); if (falsep ((c = which (b)))) { kyu_command (cons (sym_warning, cons (sym_binary_not_found, cons (native_system, cons (name, cons (b, sx_end_of_list)))))); return; } if (daemon) { startcommand = cons (cons (sym_run, cons (c, parameters)), startcommand); if (!eolp(pidfile) && truep(stopcommand)) { stopcommand = sx_list1 (sx_list2(sym_kill_via_pid_file, pidfile)); } } } } if (daemon) { functiondata = cons (cons (sym_start, startcommand), cons (cons (sym_stop, stopcommand), functiondata)); } mt = lx_environment_lookup (my_modules, name); if (!nexp (mt)) { mo = (struct kyu_module *)mt; schedulerflags = sx_set_merge (schedulerflags, mo->schedulerflags); } module = kyu_make_module (name, description, provides, requires, before, after, conflicts, schedulerflags, functions); my_modules = lx_environment_unbind (my_modules, name); my_modules = lx_environment_bind (my_modules, name, module); mod_functions = lx_environment_unbind (mod_functions, name); mod_functions = lx_environment_bind (mod_functions, name, functiondata); mod_metadata = lx_environment_unbind (mod_metadata, name); mod_metadata = lx_environment_bind (mod_metadata, name, cons (binary, pidfile)); kyu_command (cons (sym_update, cons (native_system, cons (module, sx_end_of_list)))); } } else if (eofp (sx)) { open_config_files--; if (open_config_files == 0) { update_status_from_pid_files (); kyu_command (cons (sym_initialised, cons (sym_server_seteh, sx_end_of_list))); } } }
static void update_status_from_pid_files ( void ) { sexpr c, a, n, pl, name, m, flags; struct sexpr_io *io; struct kyu_module *mod; int online; for (c = lx_environment_alist (mod_metadata); consp (c); c = cdr (c)) { a = car (c); name = car (a); a = cdr (a); online = 0; if (consp ((pl = cdr (a)))) { while (!online && (consp (pl))) { a = car (pl); if (truep (filep (a))) { io = sx_open_i (io_open_read (sx_string (a))); while (!eofp ((n = sx_read (io)))) { if (integerp (n)) { online = kyu_test_pid (sx_integer (n)); break; } } sx_close_io (io); } pl = cdr (pl); } if (!nexp (m = lx_environment_lookup (my_modules, name))) { mod = (struct kyu_module *)m; flags = mod->schedulerflags; if (truep (sx_set_memberp (flags, sym_enabled)) != online) { my_modules = lx_environment_unbind (my_modules, name); if (online) { flags = sx_set_add (flags, sym_enabled); } else { flags = sx_set_remove (flags, sym_enabled); } m = kyu_make_module (mod->name, mod->description, mod->provides, mod->requires, mod->before, mod->after, mod->conflicts, flags, mod->functions); my_modules = lx_environment_bind (my_modules, name, m); kyu_command (cons (sym_update, cons (native_system, cons (m, sx_end_of_list)))); } } } } }