error_t fshelp_get_identity (struct port_bucket *bucket, ino_t fileno, mach_port_t *pt) { struct idspec *i; error_t err = 0; error_t check_port (void *arg) { struct idspec *i = arg; if (i->fileno == fileno) { *pt = ports_get_right (i); return 1; } else return 0; } mutex_lock (&idlock); if (!idclass) id_initialize (); *pt = MACH_PORT_NULL; ports_class_iterate (idclass, check_port); if (*pt != MACH_PORT_NULL) { mutex_unlock (&idlock); return 0; } err = ports_create_port (idclass, bucket, sizeof (struct idspec), &i); if (err) { mutex_unlock (&idlock); return err; } i->fileno = fileno; *pt = ports_get_right (i); ports_port_deref (i); mutex_unlock (&idlock); return 0; }
int main(int argc, char **argv) { int retval; /* * Some versions of cron(8) and at(1) set SIGCHLD to SIG_IGN. * This is kinda dumb, because it breaks assumprions made in * libc (like pclose, for instance). It also blows away most * of Cook's process handling. We explicitly set the SIGCHLD * signal handling to SIG_DFL to make sure this signal does what * we expect no matter how we are invoked. */ #ifdef SIGCHLD signal(SIGCHLD, SIG_DFL); #else signal(SIGCLD, SIG_DFL); #endif /* * initialize things * (order is critical here) */ progname_set(argv[0]); str_initialize(); id_initialize(); lex_initialize(); /* * parse the COOK environment variable */ arglex_init_from_env(argv[0], argtab); argparse(OPTION_LEVEL_ENVIRONMENT); /* * parse the command line */ arglex_init(argc, argv, argtab); argparse(OPTION_LEVEL_COMMAND_LINE); option_tidy_up(); log_open(); /* * turn on progress stars if they asked for them */ if (option_test(OPTION_STAR)) star_enable(); /* * If we were asked to update the fingerprints, do it here. * We don't actually ant to read in the cookbook. */ if (option.fingerprint_update) { fp_tweak(); quit(0); } /* * read in the cook book * * If there are #include-cooked directives, * we may need to do it more than once. */ if (!option.o_book) fatal_intl(0, i18n("no book found")); for (;;) { int status; size_t j; builtin_initialize(); /* * instanciate the command line variable assignments */ for (j = 0; j < option.o_vardef.nstrings; ++j) { char *s; char *cp; string_ty *name; string_ty *value; string_list_ty wl; opcode_context_ty *ocp; s = option.o_vardef.string[j]->str_text; cp = strchr(s, '='); assert(cp); if (!cp) continue; name = str_n_from_c(s, cp - s); value = str_from_c(cp + 1); str2wl(&wl, value, (char *)0, 0); str_free(value); ocp = opcode_context_new(0, 0); opcode_context_id_assign(ocp, name, id_variable_new(&wl), 0); opcode_context_delete(ocp); str_free(name); string_list_destructor(&wl); } set_command_line_goals(); parse(option.o_book); status = cook_auto_required(); if (status < 0) quit(1); if (!status) break; id_reset(); cook_reset(); } /* * work out what to cook. * If no targets have been given, use the first explicit recipe. */ set_command_line_goals(); if (!option.o_target.nstrings) cook_find_default(&option.o_target); assert(option.o_target.nstrings); /* * cook the target */ if (option.pairs) retval = cook_pairs(&option.o_target); else if (option.script) retval = cook_script(&option.o_target); else if (option.web) retval = cook_web(&option.o_target); else retval = cook(&option.o_target); #ifdef DEBUG fflush_slowly_report(); #endif quit(retval); /*NOTREACHED*/ return 0; }