AbstractString * LogicalPathname::write_to_string() { Thread * thread = current_thread(); bool escape = thread->symbol_value(S_print_escape) || thread->symbol_value(S_print_readably); String * s = new String(); if (escape) s->append("#P\""); s->append(the_string(_host)); s->append_char(':'); if (_directory != NIL) s->append(directory_namestring()); if (_name != NIL) { if (_name == K_wild) s->append_char('*'); else s->append(::princ_to_string(_name)); } if (_type != NIL) { s->append_char('.'); if (_type == K_wild) s->append_char('*'); else s->append(::princ_to_string(_type)); } if (integerp(_version)) { s->append_char('.'); s->append(::write_to_string(_version)->upcase()); } else if (_version == K_wild) s->append(".*"); else if (_version == K_newest) s->append(".NEWEST"); if (escape) s->append_char('"'); return s; }
static int ftw_callback(const char *c_path, const struct stat *c_sb, int c_type, struct FTW *fb) { int c_result = 1; uw_frame_t cont_guard; uw_push_guard(&cont_guard, 0); uw_simple_catch_begin; sig_check_fast(); { val path = string_utf8(c_path); val type = num(c_type); val sb = stat_to_struct(*c_sb, path); val level = num(fb->level); val base = num(fb->base); val result; args_decl(args, ARGS_MIN); args_add5(args, path, type, sb, level, base); result = generic_funcall(s_callback, args); c_result = if3(integerp(result), c_num(result), 0); } uw_unwind { s_exit_point = uw_curr_exit_point; uw_curr_exit_point = 0; /* stops unwinding */ } uw_catch_end; uw_pop_frame(&cont_guard); return c_result; }
static void event_add (sexpr sx) { struct event *ev; if (consp (sx)) { sexpr a = car (sx); sexpr c = cdr (sx); int repeat = 1; int stat = 0; if (truep (equalp (a, sym_quit))) { cexit (0); } if (truep (equalp (a, sym_repeat))) { a = car (c); c = cdr (c); repeat = -1; stat |= STAT_HAD_REPEAT; if (integerp (a)) { repeat = sx_integer (a); a = car (c); c = cdr (c); } else if (truep (equalp (a, sym_indefinitely))) { repeat = -1; a = car (c); c = cdr (c); } else { stat |= STAT_SKIP_IN_POP; } } if (truep (equalp (a, sym_every))) { a = car (c); c = cdr (c); if (!(stat & STAT_HAD_REPEAT)) { repeat = -1; } stat |= STAT_PROCESS_IN; stat |= STAT_SKIP_IN_POP; } if (truep (equalp (a, sym_in)) || (stat & STAT_PROCESS_IN)) { if (!(stat & STAT_SKIP_IN_POP)) { a = car (c); c = cdr (c); } if (integerp (a)) { ev = get_event (); ev->repeat = repeat; ev->model_data.seconds = sx_integer (a); a = car (c); c = cdr (c); if (truep (equalp (a, sym_seconds)) || truep (equalp (a, sym_second)) || truep (equalp (a, sym_s))) { a = car (c); c = cdr (c); /* nothing to do*/ } if (!nexp (a) && falsep (equalp (a, sym_then))) { ev->output = a; a = car (c); c = cdr (c); } if (truep (equalp (a, sym_then))) { ev->then = c; } } } } }
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)))); } } } } }