int main(int argc, char *argv[]) { int ret; enum _alpm_errno_t err; setlocale(LC_ALL, ""); strings_init(); if (argc == 1) { cwr_fprintf(stderr, LOG_ERROR, "not enough arguments\n"); exit(EXIT_FAILURE); } const command_t *cmd = find(argv[1]); if (!cmd) { cwr_fprintf(stderr, LOG_ERROR, "command %s not understood\n", argv[1]); exit(EXIT_FAILURE); } /* if ((ret = parse_options(argc, argv)) != 0) */ /* return ret; */ cwr_fprintf(stderr, LOG_DEBUG, "initializing alpm\n"); pmhandle = alpm_initialize(PACMAN_ROOT, PACMAN_DBPATH, &err); if (!pmhandle) { cwr_fprintf(stderr, LOG_ERROR, "failed to initialize alpm library\n"); goto finish; } ret = run(cmd, --argc, ++argv); finish: alpm_release(pmhandle); return ret; }
int main(int argc, char **argv) { int i; context_t ctx; char *entry_hook_line = "{exec {print-str ' entry:'} [var 0 0]" "\n {while <is-le [var 0] 10>" "\n {exec" "\n {print-char 32}" "\n {print-hex0 [reg [var 0]]}" "\n {if <is-null [reg [var 0]]>" "\n (break)" "\n }" "\n [var 0 (add [var 0] 1)]" "\n }" "\n }" "\n (print-char 10)" "\n}"; char *exit_hook_line = "{exec {print-str ' exit:'} [var 0 0]" "\n {while <is-le [var 0] 10>" "\n {exec {print-str ' '} (print-hex0 [reg [var 0]]) [var 0 (add [var 0] 1)]}" "\n }" "\n (print-char 10)" "\n}"; hook_p h; if (strings_init(STRING_BUFF) || atoms_init(MAX_ATOMS) || symbols_init(MAX_SYMBOLS) || ringbuf_init(4096) || hooks_init(4, NULL, NULL)) return -1; if (argc > 1) entry_hook_line = argv[1]; if (argc > 2) exit_hook_line = argv[2]; h = hook_install((uint_t)funnn, entry_hook_line, exit_hook_line, NULL, ringbuf_dump, splinter_test_mode); if (!h) { fprintf(stderr, "%s", splinter_error_get()); return -1; } h->enabled = 1; memset(&ctx, 0, sizeof(ctx)); for(i = 0; i < 1; i++) { context_call(&h->entry_chain, h, &ctx); context_call(&h->exit_chain, h, &ctx); context_close(h, &ctx); } dump_ringbuffer(); return 0; }
/* * blissc_init * * Initializes the driver, setting up the context block. * This should be first routine called by a driver program. */ blissc_driverctx_t blissc_init (jmp_buf retenv) { blissc_driverctx_t ctx; ctx = malloc(sizeof(struct blissc_driverctx_s)); if (ctx == 0) return 0; memset(ctx, 0, sizeof(struct blissc_driverctx_s)); ctx->strctx = strings_init(); ctx->logctx = logging_init(retenv); ctx->fioctx = fileio_init(ctx->logctx); ctx->outtype = BLISS_K_OUTPUT_OBJECT; ctx->optlevel = -1; // unset return ctx; } /* blissc_init */