// Log an executed command to the CCACHE_LOGFILE location. void cc_log_argv(const char *prefix, char **argv) { if (!init_log()) { return; } log_prefix(true); if (logfile) { fputs(prefix, logfile); print_command(logfile, argv); int rc = fflush(logfile); if (rc) { warn_log_fail(); } } #ifdef HAVE_SYSLOG if (use_syslog) { char *s = format_command(argv); syslog(LOG_DEBUG, "%s", s); free(s); } #endif if (debug_log_buffer) { append_to_debug_log(prefix, strlen(prefix)); char *s = format_command(argv); append_to_debug_log(s, strlen(s)); free(s); } }
/* * Find the EXTERNAL command which matches the given name 'param'. If there is * more than one possibility, make a popup menu of the matching commands and * allow the user to select one. Return the selected command. */ static char *lookup_external(char *param, int only_overriders) { int pass, num_disabled, num_matched, num_choices, cur_choice; size_t length = 0; char *cmdbuf = NULL; char **actions = 0; char **choices = 0; lynx_list_item_type *ptr = 0; for (pass = 0; pass < 2; pass++) { num_disabled = 0; num_matched = 0; num_choices = 0; for (ptr = externals; ptr != 0; ptr = ptr->next) { if (match_item_by_name(ptr, param, only_overriders)) { ++num_matched; CTRACE((tfp, "EXTERNAL: '%s' <==> '%s'\n", ptr->name, param)); if (no_externals && !ptr->always_enabled && !only_overriders) { ++num_disabled; } else { if (pass == 0) { length++; } else if (pass != 0) { cmdbuf = format_command(ptr->command, param); if (length > 1) { actions[num_choices] = cmdbuf; choices[num_choices] = format_command(ptr->menu_name, param); } } num_choices++; } } } if (length > 1) { if (pass == 0) { actions = typecallocn(char *, length + 1); choices = typecallocn(char *, length + 1); if (actions == 0 || choices == 0) outofmem(__FILE__, "lookup_external"); } else { actions[num_choices] = 0; choices[num_choices] = 0; } }
/** * This method will be called by each thread. * It will call itself recursively later on. */ void *do_work(void * thread_num) { int thread = *((int *) thread_num); /* * the index of the current file */ int currentFile; /* * this is supposed to be something like synchronized in java, * prevents the multiple threads from reading/modifying the same * variable at the same time. */ pthread_mutex_lock(&mutex); currentFile = ++last_file; pthread_mutex_unlock(&mutex); /* check if index is out of bounds */ if (currentFile > files_count - 1) { /* if it is, do nothing */ LOG(DEBUG, "THREAD %d: about to finish!", thread); return NULL; } /* * command to call */ char* command = format_command(config.command, currentFile); // char* filename = extract_filename_from_path(input_files[currentFile]); LOG(INFO, "THREAD %d: input_filename='%s'", thread, input_files[currentFile]); // free(filename); LOG(DEBUG, "THREAD %d: command: %s", thread, command); /*********************** * START CONVERSION! * ***********************/ if (!dry_run) { FILE *file; file = popen(command, "r"); /* * wait for the command execution to complete */ pclose(file); } else { LOG(WARN, "THREAD %d: Dry run, skipping the command call!", thread); } free(command); /* * convert the file which is next in line if there is any (recursive call) */ do_work(thread_num); return NULL; }
static ErlDrvSSizeT uart_drv_ctl(ErlDrvData d, unsigned int cmd, char* buf, ErlDrvSizeT len, char** rbuf, ErlDrvSizeT rsize) { drv_ctx_t* ctx = (drv_ctx_t*) d; char ref_buf[sizeof(uint32_t)]; DEBUGF("uart_drv: ctl: cmd=%u(%s), len=%d", cmd, format_command(cmd), len); ctx->self.caller = driver_caller(ctx->self.port); dthread_control(ctx->other, &ctx->self, cmd, buf, len); put_uint32((unsigned char*)ref_buf, (uint32_t) ctx->self.ref); return ctl_reply(UART_OK, ref_buf, sizeof(ref_buf), rbuf, rsize); }
/* * Find the EXTERNAL command which matches the given name 'param'. If there is * more than one possibility, make a popup menu of the matching commands and * allow the user to select one. Return the selected command. */ PRIVATE char *lookup_external ARGS2( char *, param, BOOL, only_overriders) { int pass, num_disabled, num_matched, num_choices, cur_choice; int length = 0; char *cmdbuf = NULL; char **choices = 0; lynx_list_item_type *ptr = 0; for (pass = 0; pass < 2; pass++) { num_disabled = 0; num_matched = 0; num_choices = 0; for (ptr = externals; ptr != 0; ptr = ptr->next) { if (match_item_by_name(ptr, param, only_overriders)) { ++num_matched; CTRACE((tfp, "EXTERNAL: '%s' <==> '%s'\n", ptr->name, param)); if (no_externals && !ptr->always_enabled && !only_overriders) { ++num_disabled; } else { if (pass == 0) { length++; } else if (pass != 0) { cmdbuf = format_command(ptr->command, param); if (length > 1) choices[num_choices] = cmdbuf; } num_choices++; } } } if (length > 1) { if (pass == 0) { choices = typecallocn(char *, length + 1); } else { choices[num_choices] = 0; } }