static int _ocsp_db_save(mget_hashmap_t *map, const char *fname, int save_hosts) { FILE *fp; int ret = -1, size; if ((size = mget_hashmap_size(map)) <= 0) return -1; if ((fp = fopen(fname, "w"))) { fputs("#OCSP 1.0 file\n", fp); fputs("#Generated by Mget " PACKAGE_VERSION ". Edit at your own risk.\n", fp); if (save_hosts) { fputs("<hostname> <time_t maxage> <time_t mtime>\n\n", fp); mget_hashmap_browse(map, (int(*)(void *, const void *, void *))_ocsp_save_host, fp); } else { fputs("<sha256 fingerprint of cert> <time_t maxage> <time_t mtime> <valid>\n\n", fp); mget_hashmap_browse(map, (int(*)(void *, const void *, void *))_ocsp_save_entry, fp); } if (!ferror(fp)) ret = 0; if (fclose(fp)) ret = -1; if (ret) error_printf(_("Failed to write to OCSP file '%s' (%d)\n"), fname, errno); else debug_printf(_("saved %d OCSP entr%s into '%s'\n"), size, size != 1 ? "ies" : "y", fname); } else error_printf(_("Failed to open OCSP file '%s' (%d)\n"), fname, errno); return ret; }
sftp_error_report(BDRVSSHState *s, const char *fs, ...) { va_list args; va_start(args, fs); error_vprintf(fs, args); if ((s)->sftp) { char *ssh_err; int ssh_err_code; unsigned long sftp_err_code; /* This is not an errno. See <libssh2.h>. */ ssh_err_code = libssh2_session_last_error(s->session, &ssh_err, NULL, 0); /* See <libssh2_sftp.h>. */ sftp_err_code = libssh2_sftp_last_error((s)->sftp); error_printf(": %s (libssh2 error code: %d, sftp error code: %lu)", ssh_err, ssh_err_code, sftp_err_code); } va_end(args); error_printf("\n"); }
static int forward_process(int fd, int ttyfd) { pthread_t tid[NUM_THREADS]; thread_param_t arg[NUM_THREADS] = { { "fwd_send", /* name */ fd, /* from */ ttyfd /* to */ }, { "fwd_receive", /* name */ ttyfd, /* from */ fd /* to */ } }; if (forward_create_thread(tid, arg) != 0) { error_printf("forward_create_thread error\n"); if (0 != close(ttyfd)) error_printf("Note: couldn't close file: %s correctly\n", tty_name); exit(EXIT_FAILURE); } if (forward_wait_thread(tid) != 0) { error_printf("forward_wait_thread error\n"); exit(EXIT_FAILURE); } debug_printf("forward_process exit\n"); return 0; }
static FILE * init_files(lame_global_flags * gf, char const *inPath, char const *outPath) { FILE *outf; /* Mostly it is not useful to use the same input and output name. This test is very easy and buggy and don't recognize different names assigning the same file */ if (0 != strcmp("-", outPath) && 0 == strcmp(inPath, outPath)) { error_printf("Input file and Output file are the same. Abort.\n"); return NULL; } /* open the wav/aiff/raw pcm or mp3 input file. This call will * open the file, try to parse the headers and * set gf.samplerate, gf.num_channels, gf.num_samples. * if you want to do your own file input, skip this call and set * samplerate, num_channels and num_samples yourself. */ if (init_infile(gf, inPath) < 0) { error_printf("Can't init infile '%s'\n", inPath); return NULL; } if ((outf = init_outfile(outPath, lame_get_decode_only(gf))) == NULL) { error_printf("Can't init outfile '%s'\n", outPath); return NULL; } return outf; }
static int serial_open(char *name) { int fd = 0, ft = 0; if ((fd = open(name, O_RDWR | O_NOCTTY | O_NDELAY)) == -1) { error_printf("Can't open serial port %s: %s\n", name, strerror(errno)); return EXIT_FAILURE; } else { debug_printf("Open serial port [%s] success, fd-open=%d\n", name, fd); } /* set serial to block status wait for read from serial port */ ft = fcntl(fd, F_SETFL, 0); if (-1 == ft) error_printf("fcntl failed!\n"); else debug_printf("fcntl=%d\n", ft); if (isatty(fd) == 1) debug_printf("isatty(%d) = 1, [%s] is a terminal device\n", fd, name); else debug_printf("isatty(%d) = 0, [%s] is not a terminal device\n", fd, name); return fd; }
static int write_xing_frame(lame_global_flags * gf, FILE * outf, size_t offset) { unsigned char mp3buffer[LAME_MAXMP3BUFFER]; size_t imp3, owrite; imp3 = lame_get_lametag_frame(gf, mp3buffer, sizeof(mp3buffer)); if (imp3 <= 0) { return 0; /* nothing to do */ } if (global_ui_config.silent <= 0) { console_printf("Writing LAME Tag..."); } if (imp3 > sizeof(mp3buffer)) { error_printf ("Error writing LAME-tag frame: buffer too small: buffer size=%d frame size=%d\n", sizeof(mp3buffer), imp3); return -1; } assert( offset <= LONG_MAX ); if (fseek(outf, (long) offset, SEEK_SET) != 0) { error_printf("fatal error: can't update LAME-tag frame!\n"); return -1; } owrite = fwrite(mp3buffer, 1, imp3, outf); if (owrite != imp3) { error_printf("Error writing LAME-tag \n"); return -1; } if (global_ui_config.silent <= 0) { console_printf("done\n"); } assert( imp3 <= INT_MAX ); return (int) imp3; }
static int write_xing_frame(lame_global_flags * gf, FILE * outf) { unsigned char mp3buffer[LAME_MAXMP3BUFFER]; size_t imp3, owrite; imp3 = lame_get_lametag_frame(gf, mp3buffer, sizeof(mp3buffer)); if (imp3 > sizeof(mp3buffer)) { error_printf("Error writing LAME-tag frame: buffer too small: buffer size=%d frame size=%d\n" , sizeof(mp3buffer) , imp3 ); return -1; } if (imp3 <= 0) { return 0; } owrite = (int) fwrite(mp3buffer, 1, imp3, outf); if (owrite != imp3) { error_printf("Error writing LAME-tag \n"); return -1; } if (flush_write == 1) { fflush(outf); } return imp3; }
bool flushOBJ(FILE *fp) { // initialized check if(vertices == NULL || faces == NULL) { error_printf("not initialized\n"); exit(EXIT_FAILURE); } // flush vertices for(unsigned i = 0; i < num_vertices; ++i) { vertex_t *v = &vertices[i]; if(fprintf(fp, "v %f %f %f\n", v->x, v->y, v->z) < 0) { error_printf("failed to write file\n"); goto ON_ERROR; } } // flush faces for(unsigned i = 0; i < num_faces; ++i) { face_t *f = &faces[i]; if(fprintf(fp, "f %d %d %d\n", f->v1 + 1, f->v2 + 1, f->v3 + 1) < 0) { error_printf("failed to write file\n"); goto ON_ERROR; } } return true; ON_ERROR: FREE(vertices); FREE(faces); fclose(fp); return false; }
void Core::collapse_check_loop(TL::PragmaCustomStatement construct) { TL::PragmaCustomClause collapse = construct.get_pragma_line().get_clause("collapse"); if (!collapse.is_defined()) return; TL::ObjectList<Nodecl::NodeclBase> expr_list = collapse.get_arguments_as_expressions(construct); if (expr_list.size() != 1) { error_printf("%s: error: collapse clause needs exactly one argument\n", locus_to_str(construct.get_locus())); return; } Nodecl::NodeclBase expr = expr_list[0]; if (!expr.is_constant() || !is_any_int_type(expr.get_type().get_internal_type())) { error_printf("%s: error: collapse clause requires an integer constant expression\n", locus_to_str(construct.get_locus())); return; } const_value_t* cval = expr.get_constant(); if (!const_value_is_one(cval)) { error_printf("%s: error: only collapse(1) is supported\n", locus_to_str(construct.get_locus())); return; } }
int main(int argc, char *argv[]) { if(argc < 2) { error_printf("missing file argument\n"); fprintf(stderr, "usage : %s output_filename\n", argv[0]); exit(EXIT_FAILURE); } if((pt = malloc(capacity * sizeof(point_t))) == NULL) { error_printf("out of memory\n"); exit(EXIT_FAILURE); } if((file_out = fopen(argv[1], "w")) == NULL) { error_printf("failed to open %s for write\n"); FREE(pt); exit(EXIT_FAILURE); } glutInitWindowSize(600, WINDOW_HEIGHT); glutInitWindowPosition(10, 10); glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutCreateWindow(argv[0]); glClearColor(1.0, 1.0, 1.0, 0.0); glColor3f(0.0, 0.0, 0.0); glPointSize(7.0); glutDisplayFunc(display); glutReshapeFunc(reshape); glutMouseFunc(handle_mouse); glutKeyboardFunc(handle_keyboard); glutMainLoop(); return 0; }
char *mget_read_file(const char *fname, size_t *size) { int fd; ssize_t nread; char *buf = NULL; if (!fname) return NULL; if (strcmp(fname,"-")) { if ((fd = open(fname, O_RDONLY)) != -1) { struct stat st; if (fstat(fd, &st) == 0) { off_t total = 0; buf = xmalloc(st.st_size + 1); while (total < st.st_size && (nread = read(fd, buf + total, st.st_size - total)) > 0) { total += nread; } buf[total] = 0; if (size) *size = total; if (total != st.st_size) error_printf(_("WARNING: Size of %s changed from %lld to %lld while reading. This may lead to unwanted results !\n"), fname, (long long)st.st_size, (long long)total); } else error_printf(_("Failed to fstat %s\n"), fname); close(fd); } else error_printf(_("Failed to open %s\n"), fname); } else { // read data from STDIN. char tmp[4096]; mget_buffer_t buffer; mget_buffer_init(&buffer, NULL, 4096); while ((nread = read(STDIN_FILENO, tmp, sizeof(tmp))) > 0) { mget_buffer_memcat(&buffer, tmp, nread); } if (size) *size = buffer.length; buf = buffer.data; buffer.data = NULL; mget_buffer_deinit(&buffer); } return buf; }
static int fit_load_kernel(const struct fit_loader *ldr, const void *itb, int cfg, void *opaque, hwaddr *pend) { const char *name; const void *data; const void *load_data; hwaddr load_addr, entry_addr; int img_off, err; size_t sz; int ret; name = fdt_getprop(itb, cfg, "kernel", NULL); if (!name) { error_printf("no kernel specified by FIT configuration\n"); return -EINVAL; } load_data = data = fit_load_image_alloc(itb, name, &img_off, &sz); if (!data) { error_printf("unable to load kernel image from FIT\n"); return -EINVAL; } err = fit_image_addr(itb, img_off, "load", &load_addr); if (err) { error_printf("unable to read kernel load address from FIT\n"); ret = err; goto out; } err = fit_image_addr(itb, img_off, "entry", &entry_addr); if (err) { error_printf("unable to read kernel entry address from FIT\n"); ret = err; goto out; } if (ldr->kernel_filter) { load_data = ldr->kernel_filter(opaque, data, &load_addr, &entry_addr); } if (pend) { *pend = load_addr + sz; } load_addr = ldr->addr_to_phys(opaque, load_addr); rom_add_blob_fixed(name, load_data, sz, load_addr); ret = 0; out: g_free((void *) data); if (data != load_data) { g_free((void *) load_data); } return ret; }
static const void *fit_load_image_alloc(const void *itb, const char *name, int *poff, size_t *psz) { const void *data; const char *comp; void *uncomp_data; char path[FIT_LOADER_MAX_PATH]; int off, sz; ssize_t uncomp_len; snprintf(path, sizeof(path), "/images/%s", name); off = fdt_path_offset(itb, path); if (off < 0) { return NULL; } if (poff) { *poff = off; } data = fdt_getprop(itb, off, "data", &sz); if (!data) { return NULL; } comp = fdt_getprop(itb, off, "compression", NULL); if (!comp || !strcmp(comp, "none")) { if (psz) { *psz = sz; } uncomp_data = g_malloc(sz); memmove(uncomp_data, data, sz); return uncomp_data; } if (!strcmp(comp, "gzip")) { uncomp_len = UBOOT_MAX_GUNZIP_BYTES; uncomp_data = g_malloc(uncomp_len); uncomp_len = gunzip(uncomp_data, uncomp_len, (void *) data, sz); if (uncomp_len < 0) { error_printf("unable to decompress %s image\n", name); g_free(uncomp_data); return NULL; } data = g_realloc(uncomp_data, uncomp_len); if (psz) { *psz = uncomp_len; } return data; } error_printf("unknown compression '%s'\n", comp); return NULL; }
static void create_user_file(const char *file) { FILE *fp; fp = fopen(file, "w+"); if (!fp) { error_printf("can't open file: %s\n", file); return; } if (0 != fclose(fp)) error_printf("Note: couldn't close file: %s correctly\n", file); }
int mget_cookie_db_save(mget_cookie_db_t *cookie_db, const char *fname, int keep_session_cookies) { FILE *fp; int it, ret = -1; time_t now = time(NULL); if (!cookie_db || !fname) return -1; info_printf(_("saving cookies to '%s'\n"), fname); if ((fp = fopen(fname, "w"))) { fputs("# HTTP cookie file\n", fp); fputs("#Generated by Mget " PACKAGE_VERSION ". Edit at your own risk.\n\n", fp); mget_thread_mutex_lock(&cookie_db->mutex); for (it = 0; it < mget_vector_size(cookie_db->cookies) && !ferror(fp); it++) { mget_cookie_t *cookie = mget_vector_get(cookie_db->cookies, it); if (cookie->persistent) { if (cookie->expires < now) continue; } else if (!keep_session_cookies) continue; fprintf(fp, "%s%s%s\t%s\t%s\t%s\t%"PRId64"\t%s\t%s\n", cookie->http_only ? "#HttpOnly_" : "", cookie->domain_dot ? "." : "", // compatibility, irrelevant since RFC 6562 cookie->domain, cookie->host_only ? "FALSE" : "TRUE", cookie->path, cookie->secure_only ? "TRUE" : "FALSE", (int64_t)cookie->expires, cookie->name, cookie->value); } mget_thread_mutex_unlock(&cookie_db->mutex); if (!ferror(fp)) ret = 0; if (fclose(fp)) ret = -1; if (ret) error_printf(_("Failed to write to cookie file '%s' (%d)\n"), fname, errno); } else error_printf(_("Failed to open cookie file '%s' (%d)\n"), fname, errno); return ret; }
void set_debug_file(const char *fn) { if (Console_IO.Report_fp == NULL) { Console_IO.Report_fp = lame_fopen(fn, "a"); if (Console_IO.Report_fp != NULL) { error_printf("writing debug info into: %s\n", fn); } else { error_printf("Error: can't open for debug info: %s\n", fn); } } }
static int read_config_file(serial_control_t *ctrl) { char mode[10], baudrate[20], bits[10], parity[10], stop[10]; if (read_conf_value("MODE", mode, tty_config) != 0) { error_printf("serial_config: get MODE failed\n"); return EXIT_FAILURE; } if (read_conf_value("BAUDRATE", baudrate, tty_config) != 0) { error_printf("serial_config: get BAUDRATE failed\n"); return EXIT_FAILURE; } if (read_conf_value("DATA_BITS", bits, tty_config) != 0) { error_printf("serial_config: get DATA_BITS failed\n"); return EXIT_FAILURE; } if (read_conf_value("PARITY", parity, tty_config) != 0) { error_printf("serial_config: get PARITY failed\n"); return EXIT_FAILURE; } if (read_conf_value("STOP_BITS", stop, tty_config) != 0) { error_printf("serial_config: get STOP_BITS failed\n"); return EXIT_FAILURE; } if ((strcmp(mode, "RAW") == 0)||(strcmp(mode, "raw") == 0)) { ctrl->mode = RAW_MODE; } else { ctrl->mode = NORMAL_MODE; } ctrl->speed = STRTOL(baudrate); ctrl->bits = STRTOL(bits); ctrl->parity = STRTOL(parity); ctrl->stop = STRTOL(stop); debug_printf("read_config_file -> %s\n", tty_config); debug_printf("----------------------------------\n"); debug_printf("serial_config: MODE=%s\n", mode); debug_printf("serial_config: BAUDRATE=%d\n", ctrl->speed); debug_printf("serial_config: DATA_BITS=%d\n", ctrl->bits); debug_printf("serial_config: PARITY=%s\n", parity); debug_printf("serial_config: STOP_BITS=%d\n", ctrl->stop); debug_printf("----------------------------------\n"); return EXIT_SUCCESS; }
/* Adding a new counter in counters list */ int add_counter(screen_t* const s, char* alias, char* config, char* type) { uint64_t int_conf = 0; uint32_t int_type = 0; int err=0; int n; expression* expr = NULL; if (s->num_counters >= MAX_EVENTS) { error_printf("Too many counters (max %d) in screen '%s', ignoring '%s'\n" "(change MAX_EVENTS and recompile)\n", MAX_EVENTS, s->name, alias); return -1; } int_type = get_counter_type(type, &err); if (err > 0) { /* error*/ error_printf("Bad type '%s': ignoring counter '%s'\n", type, alias); return -1; } /* Parse the configuration */ expr = parser_expression(config); err=0; int_conf = evaluate_counter_expression(expr, &err); free_expression(expr); if (err > 0) { /* error*/ error_printf("Bad config '%s': ignoring counter '%s'\n", config, alias); return -1; } n = s->num_counters; /* check max available hw counter */ if (n == s->num_alloc_counters) { s->counters = realloc(s->counters, sizeof(counter_t) * (n + alloc_chunk)); s->num_alloc_counters += alloc_chunk; } /* initialisation */ s->counters[n].used = 0; s->counters[n].type = int_type; s->counters[n].config = int_conf; s->counters[n].alias = strdup(alias); s->num_counters++; return n; }
int try_bind_port(int port) { struct addrinfo hints; memset(&hints, 0, sizeof hints); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE; char port_str[10]; snprintf(port_str, 10, "%d", port); struct addrinfo *res; int rv = getaddrinfo(NULL, port_str, &hints, &res); if (rv != 0) { error_printf("server: getaddrinfo: %s\n", gai_strerror(rv)); return -1; } int sockfd; struct addrinfo *p; for(p = res; p != NULL; p = p->ai_next) { sockfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol); if (sockfd == -1) { error_printf("server: socket: %s\n", strerror(errno)); continue; } int yes=1; if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) { close(sockfd); error_printf("server: setsockopt: %s\n", strerror(errno)); continue; } if (bind(sockfd, p->ai_addr, p->ai_addrlen) == -1) { close(sockfd); char buf[128]; error_printf("server: bind %s:%d %s (trying next)\n", inet_string(buf, 128, p), port, strerror(errno)); continue; } break; } freeaddrinfo(res); if (p == NULL) { error_printf("server: failed to bind port %d\n", port); return -1; } return sockfd; }
void init_geometry() { num_vertices = num_faces = 0; capacity_vertices = INIT_BUFSIZE_VERTICES; capacity_faces = INIT_BUFSIZE_FACES; if((vertices = malloc(capacity_vertices * sizeof(vertex_t))) == NULL) { error_printf("out of memory(faces)\n"); exit(EXIT_FAILURE); } if((faces = malloc(capacity_faces * sizeof(face_t))) == NULL) { error_printf("out of memory(vertices)\n"); FREE(vertices); exit(EXIT_FAILURE); } }
int client_connect(const char*cookie) { int port; parse_cookie(cookie, &port); struct addrinfo hints; memset(&hints, 0, sizeof hints); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; char port_str[10]; snprintf(port_str, 10, "%d", port); struct addrinfo *res; int rv = getaddrinfo(NULL, port_str, &hints, &res); if (rv != 0) { error_printf("client: getaddrinfo: %s\n", gai_strerror(rv)); return -1; } int sockfd; struct addrinfo *p; for(p = res; p != NULL; p = p->ai_next) { sockfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol); if (sockfd == -1) { error_printf("client: socket: %s\n", strerror(errno)); continue; } if (connect(sockfd, p->ai_addr, p->ai_addrlen) == -1) { close(sockfd); char buf[128]; error_printf("client: connect %s:%d %s (trying next)\n", inet_string(buf, 128, p), port, strerror(errno)); continue; } break; } freeaddrinfo(res); if (p == NULL) { error_printf("client: failed to connect\n"); return -1; } debug_printf("client: connecting\n"); return sockfd; }
/* Adding a new counter in counters list */ int add_counter_by_value(screen_t* const s, char* alias, uint64_t config_val, uint32_t type_val) { int n = s->num_counters; if (n >= MAX_EVENTS) { error_printf("Too many counters (max %d) in screen '%s', ignoring '%s'\n" "(change MAX_EVENTS and recompile)", MAX_EVENTS, s->name, alias); return -1; } /* check max available hw counter */ if (n == s->num_alloc_counters) { s->counters = realloc(s->counters, sizeof(counter_t) * (n + alloc_chunk)); s->num_alloc_counters += alloc_chunk; } /* initialisation */ s->counters[n].used = 0; s->counters[n].config = config_val; s->counters[n].alias = strdup(alias); s->counters[n].type = type_val; s->num_counters++; return n; }
/* Navigate into expressions, and mark used counters */ static void check_counters_used(expression* e, screen_t* s, int* error) { int i = 0; int found; if (e->type == ELEM && e->ele->type == COUNT) { found = -1; if (strcmp(e->ele->alias, "CPU_TOT") == 0 || strcmp(e->ele->alias, "CPU_SYS") == 0 || strcmp(e->ele->alias, "CPU_USER") == 0 || strcmp(e->ele->alias, "NUM_THREADS") == 0 || strcmp(e->ele->alias, "PROC_ID") == 0) return ; for(i=0; i < s->num_counters; i++) { assert(s->counters[i].alias != NULL); if (strcmp(e->ele->alias, s->counters[i].alias) == 0) found = i; } if (found >= 0) s->counters[found].used++; else{ error_printf("Undeclared counter '%s' in screen '%s': column ignored\n", e->ele->alias, s->name); (*error)++; } } else if (e->type == OPER && e->op != NULL) { check_counters_used(e->op->exp1, s, error); check_counters_used(e->op->exp2, s, error); } }
/************************************************************************************************** * @fn npi_termpoll * * @brief Poll Thread terminate function * * input parameters * * @param ptr * * output parameters * * None. * * @return None. ************************************************************************************************** */ static void npi_termpoll(void) { //This will cause the Thread to exit npi_poll_terminate = 1; error_printf("%s:%d: Terminating poll because...well, we're %s().\n", __FUNCTION__, __LINE__, __FUNCTION__); #ifdef SRDY_INTERRUPT pthread_cond_signal(&npi_srdy_H2L_poll); #else // In case of polling mechanism, send the Signal to continue pthread_cond_signal(&npi_poll_cond); #endif #ifdef SRDY_INTERRUPT pthread_mutex_destroy(&npiSrdyLock); #endif pthread_mutex_destroy(&npi_poll_mutex); // wait till the thread terminates pthread_join(npiPollThread, NULL); #ifdef SRDY_INTERRUPT pthread_join(npiEventThread, NULL); #endif //SRDY_INTERRUPT }
static int forward_create_thread(pthread_t *tid, thread_param_t *arg) { int t; pthread_attr_t attr; struct sched_param param; pthread_attr_init(&attr); pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); pthread_attr_setschedpolicy(&attr, DEF_SCHED_POLICY); pthread_attr_getschedparam(&attr, ¶m); param.sched_priority = DEF_PRIORITY; pthread_attr_setschedparam(&attr, ¶m); for (t = 0; t < NUM_THREADS; t++) { if (pthread_create(&tid[t], &attr, forward_thread, (void *) &arg[t])) { error_printf("forward_create_thread failed\n"); return -1; } } pthread_attr_destroy(&attr); return 0; }
static int c_main(int argc, char *argv[]) { lame_t gf; int ret; #if macintosh argc = ccommand(&argv); #endif #ifdef __EMX__ /* This gives wildcard expansion on Non-POSIX shells with OS/2 */ _wildcard(&argc, &argv); #endif #if defined( _WIN32 ) && !defined(__MINGW32__) set_process_affinity(); #endif frontend_open_console(); gf = lame_init(); /* initialize libmp3lame */ if (NULL == gf) { error_printf("fatal error during initialization\n"); ret = 1; } else { ret = lame_main(gf, argc, argv); lame_close(gf); } frontend_close_console(); return ret; }
static void char_pty_open(Chardev *chr, ChardevBackend *backend, bool *be_opened, Error **errp) { PtyChardev *s; int master_fd, slave_fd; char pty_name[PATH_MAX]; char *name; master_fd = qemu_openpty_raw(&slave_fd, pty_name); if (master_fd < 0) { error_setg_errno(errp, errno, "Failed to create PTY"); return; } close(slave_fd); qemu_set_nonblock(master_fd); chr->filename = g_strdup_printf("pty:%s", pty_name); error_printf("char device redirected to %s (label %s)\n", pty_name, chr->label); s = PTY_CHARDEV(chr); s->ioc = QIO_CHANNEL(qio_channel_file_new_fd(master_fd)); name = g_strdup_printf("chardev-pty-%s", chr->label); qio_channel_set_name(QIO_CHANNEL(s->ioc), name); g_free(name); s->timer_src = NULL; *be_opened = false; }
shape_t *new_shape() { shape_t *s = malloc(sizeof(shape_t)); if(s == NULL) { error_printf("out of memory\n"); exit(EXIT_FAILURE); } s->num_vertices = 0; s->capacity_vertices = INIT_BUFSIZE_SHAPE; if((s->vertices = malloc(s->capacity_vertices * sizeof(vertex_id))) == NULL) { error_printf("out of memory\n"); FREE(s); exit(EXIT_FAILURE); } return s; }
/* * Print an error message to current monitor if we have one, else to stderr. * Format arguments like vsprintf(). The resulting message should be * a single phrase, with no newline or trailing punctuation. * Prepend the current location and append a newline. * It's wrong to call this in a QMP monitor. Use error_setg() there. */ void error_vreport(const char *fmt, va_list ap) { GTimeVal tv; gchar *timestr; if (enable_timestamp_msg && !cur_mon) { g_get_current_time(&tv); timestr = g_time_val_to_iso8601(&tv); error_printf("%s ", timestr); g_free(timestr); } error_print_loc(); error_vprintf(fmt, ap); error_printf("\n"); }
/** * \param[in] hashname Name of the hashing algorithm (see table below) * \return A constant to be used by libwget hashing functions * * Get the hashing algorithms list item that corresponds to the named hashing algorithm. * * This function returns a constant that uniquely identifies a known supported hashing algorithm * within libwget. All the supported algorithms are listed in the ::wget_digest_algorithm_t enum. * * Algorithm name | Constant * -------------- | -------- * sha1 or sha-1|WGET_DIGTYPE_SHA1 * sha256 or sha-256|WGET_DIGTYPE_SHA256 * sha512 or sha-512|WGET_DIGTYPE_SHA512 * sha224 or sha-224|WGET_DIGTYPE_SHA224 * sha384 or sha-384|WGET_DIGTYPE_SHA384 * md5|WGET_DIGTYPE_MD5 * md2|WGET_DIGTYPE_MD2 * rmd160|WGET_DIGTYPE_RMD160 */ wget_digest_algorithm_t wget_hash_get_algorithm(const char *hashname) { if (hashname) { if (*hashname == 's' || *hashname == 'S') { if (!wget_strcasecmp_ascii(hashname, "sha-1") || !wget_strcasecmp_ascii(hashname, "sha1")) return WGET_DIGTYPE_SHA1; else if (!wget_strcasecmp_ascii(hashname, "sha-256") || !wget_strcasecmp_ascii(hashname, "sha256")) return WGET_DIGTYPE_SHA256; else if (!wget_strcasecmp_ascii(hashname, "sha-512") || !wget_strcasecmp_ascii(hashname, "sha512")) return WGET_DIGTYPE_SHA512; else if (!wget_strcasecmp_ascii(hashname, "sha-224") || !wget_strcasecmp_ascii(hashname, "sha224")) return WGET_DIGTYPE_SHA224; else if (!wget_strcasecmp_ascii(hashname, "sha-384") || !wget_strcasecmp_ascii(hashname, "sha384")) return WGET_DIGTYPE_SHA384; } else if (!wget_strcasecmp_ascii(hashname, "md5")) return WGET_DIGTYPE_MD5; else if (!wget_strcasecmp_ascii(hashname, "md2")) return WGET_DIGTYPE_MD2; else if (!wget_strcasecmp_ascii(hashname, "rmd160")) return WGET_DIGTYPE_RMD160; } error_printf(_("Unknown hash type '%s'\n"), hashname); return WGET_DIGTYPE_UNKNOWN; }