/*Controlla la semantica della write e ne ritorna il codice*/ Code write_stat(Pnode write_stat_node){ //Imposto le due parti del nodo Pnode specifier_node = write_stat_node->child; Pnode expr_node = write_stat_node->child->brother; //Definisco la variabile che contiene il codice da ritornare Code write_stat_code; //Calcolo il codice di specifier Pschema schema_specifier = (Pschema) newmem(sizeof(Schema)); Code specifier_code = specifier(specifier_node,schema_specifier); //Controllo che non ci siano errori semantici //Controllo che il tipo di specifier sia corretto if (schema_specifier->type != STRING && schema_specifier->type != NIHIL) semerror(write_stat_node,"Expected string type"); //Genero il codice di write_stat //Genero il codice di expr Pschema schema_expr = (Pschema) newmem(sizeof(Schema)); Code expr_code = expr(expr_node,schema_expr); //La sintassi della write dipende dalla presenza dello specifier if (specifier_node->child == NULL) write_stat_code = appcode(expr_code,make_print_fprint(T_PRINT,get_format(*schema_expr))); else write_stat_code = concode(expr_code,specifier_code,make_print_fprint(T_FPRINT,get_format(*schema_expr)),endcode()); return write_stat_code; }
/* in response to a TOPIC message from the server */ static void p_topic(char *from, char **ArgList) { struct channel *tmp; if (!ArgList[1]) { fake(); return; } tmp = lookup_channel(ArgList[0], from_server, CHAN_NOUNLINK); malloc_strcpy(&tmp->topic, ArgList[1]); if (check_ignore(from, FromUserHost, tmp->channel, IGNORE_TOPICS | IGNORE_CRAP, NULL) != IGNORED) { message_from(ArgList[0], LOG_CRAP); if (do_hook(TOPIC_LIST, "%s %s %s", from, ArgList[0], ArgList[1])) { if (ArgList[1] && *ArgList[1]) { if (get_format(FORMAT_TOPIC_CHANGE_HEADER_FSET)) put_it("%s", convert_output_format(get_format(FORMAT_TOPIC_CHANGE_HEADER_FSET), "%s %s %s %s", update_clock(GET_TIME), from, ArgList[0], ArgList[1])); put_it("%s", convert_output_format(get_format(FORMAT_TOPIC_CHANGE_FSET), "%s %s %s %s", update_clock(GET_TIME), from, ArgList[0], ArgList[1])); } else put_it("%s", convert_output_format(get_format(FORMAT_TOPIC_UNSET_FSET), "%s %s %s", update_clock(GET_TIME), from, ArgList[0])); } message_from(NULL, LOG_CRAP); } update_all_status(curr_scr_win, NULL, 0); }
void bx_param_string_c::text_print(FILE *fp) { char *value = getptr(); int opts = options; if (opts & RAW_BYTES) { char buffer[1024]; buffer[0] = 0; char sep_string[2]; sep_string[0] = separator; sep_string[1] = 0; for (int i=0; i<maxsize; i++) { char eachbyte[16]; sprintf(eachbyte, "%s%02x", (i>0)?sep_string : "", (unsigned int)0xff&val[i]); strncat(buffer, eachbyte, sizeof(eachbyte)); } if (strlen(buffer) > sizeof(buffer)-4) { assert(0); // raw byte print buffer is probably overflowing. increase the max or make it dynamic } value = buffer; } if (get_format()) { fprintf(fp, get_format(), value); } else { if (get_label()) { fprintf(fp, "%s: %s", get_label(), value); } else { fprintf(fp, "%s: %s", get_name(), value); } } }
static int gsc_m2m_open(struct file *file) { struct gsc_dev *gsc = video_drvdata(file); struct gsc_ctx *ctx = NULL; int ret; gsc_dbg("pid: %d, state: 0x%lx", task_pid_nr(current), gsc->state); if (gsc_out_opened(gsc) || gsc_cap_opened(gsc)) return -EBUSY; ctx = kzalloc(sizeof *ctx, GFP_KERNEL); if (!ctx) return -ENOMEM; v4l2_fh_init(&ctx->fh, gsc->m2m.vfd); ret = gsc_ctrls_create(ctx); if (ret) goto error_fh; /* Use separate control handler per file handle */ ctx->fh.ctrl_handler = &ctx->ctrl_handler; file->private_data = &ctx->fh; v4l2_fh_add(&ctx->fh); ctx->gsc_dev = gsc; /* Default color format */ ctx->s_frame.fmt = get_format(0); ctx->d_frame.fmt = get_format(0); /* Setup the device context for mem2mem mode. */ ctx->state |= GSC_CTX_M2M; ctx->flags = 0; ctx->in_path = GSC_DMA; ctx->out_path = GSC_DMA; spin_lock_init(&ctx->slock); INIT_LIST_HEAD(&ctx->fence_wait_list); INIT_WORK(&ctx->fence_work, gsc_m2m_fence_work); ctx->m2m_ctx = v4l2_m2m_ctx_init(gsc->m2m.m2m_dev, ctx, queue_init); if (IS_ERR(ctx->m2m_ctx)) { gsc_err("Failed to initialize m2m context"); ret = PTR_ERR(ctx->m2m_ctx); goto error_fh; } if (gsc->m2m.refcnt++ == 0) set_bit(ST_M2M_OPEN, &gsc->state); gsc_dbg("gsc m2m driver is opened, ctx(0x%p)", ctx); return 0; error_fh: v4l2_fh_del(&ctx->fh); v4l2_fh_exit(&ctx->fh); kfree(ctx); return ret; }
/** * Generates a user-friendly error report. */ string exception::to_string( log_level ll )const { fc::stringstream ss; ss << what() << ":"; for( auto itr = my->_elog.begin(); itr != my->_elog.end(); ++itr ) { if( itr->get_format().size() ) ss << " " << fc::format_string( itr->get_format(), itr->get_data() ); } return ss.str(); }
MeshFactory::MeshFactory (boost::weak_ptr<VertexDataBufferManager> mgr, boost::shared_ptr<GLExtensionProxy> proxy, unsigned head_tessel, unsigned tail_tessel) : head (get_format (), mgr, proxy, enough_head_indices (head_tessel)), tail (get_format (), mgr, proxy, enough_tail_indices (tail_tessel)) { if (head_tessel < 3 || tail_tessel < 2) throw std::logic_error ("impossibly low tessellation requested"); load_head (head, head_tessel); load_tail (tail, tail_tessel); }
void bx_param_bool_c::text_print(FILE *fp) { if (get_format()) { fprintf(fp, get_format(), get() ? "yes" : "no"); } else { const char *format = "%s: %s"; if (get_label()) { fprintf(fp, format, get_label(), get() ? "yes" : "no"); } else { fprintf(fp, format, get_name(), get() ? "yes" : "no"); } } }
/** * \brief Sets the volume of a channel of the current music. * * This function is only supported for .it musics. * * \param channel Index of a channel. * \param volume The volume to set. */ void Music::set_channel_volume(int channel, int volume) { Debug::check_assertion(get_format() == IT, "This function is only supported for .it musics"); it_decoder->set_channel_volume(channel, volume); }
/** * \brief Returns the volume of a channel of the current music. * * This function is only supported for .it musics. * * \param channel Index of a channel. * \return The volume of this channel. */ int Music::get_channel_volume(int channel) { Debug::check_assertion(get_format() == IT, "This function is only supported for .it musics"); return it_decoder->get_channel_volume(channel); }
textbox* textbox_create ( TextboxFlags flags, short x, short y, short w, short h, TextBoxFontType tbft, const char *text ) { textbox *tb = g_malloc0 ( sizeof ( textbox ) ); tb->flags = flags; tb->x = x; tb->y = y; tb->w = MAX ( 1, w ); tb->h = MAX ( 1, h ); tb->changed = FALSE; tb->main_surface = cairo_image_surface_create ( get_format (), tb->w, tb->h ); tb->main_draw = cairo_create ( tb->main_surface ); tb->layout = pango_cairo_create_layout ( tb->main_draw ); PangoFontDescription *pfd = pango_font_description_from_string ( config.menu_font ); pango_layout_set_font_description ( tb->layout, pfd ); pango_font_description_free ( pfd ); textbox_font ( tb, tbft ); if ( ( flags & TB_WRAP ) == TB_WRAP ) { pango_layout_set_wrap ( tb->layout, PANGO_WRAP_WORD_CHAR ); } textbox_text ( tb, text ? text : "" ); textbox_cursor_end ( tb ); // auto height/width modes get handled here textbox_moveresize ( tb, tb->x, tb->y, tb->w, tb->h ); return tb; }
int ft_printf(const char *format, ...) { va_list args; va_list s_arg; t_format *opt; char *p; p = (char *)format; va_start(args, format); va_copy(s_arg, args); while (*p != '\0') { if (*p == '%') { p++; if ((opt = get_format(&p)) == NULL) exit(-1); printf("%d|%d|%d|%d|%d\n", opt->arg, opt->width, opt->precision, opt->flags, opt->type); if (opt->bad_type) ft_build(args, s_arg, opt); ft_memdel((void **)&opt); } else ft_putchar(*(p++)); } va_end(args); return (0); }
-f,--format \"format string\" format string for columns\r\n\ "; #define STATBUFSIZE 1024 int main(int argc, char* argv[]) { std::string buffer; char buf[STATBUFSIZE]; size_t readed; while (readed = read(STDIN_FILENO, buf, STATBUFSIZE) ) { buffer.insert(buffer.begin() + buffer.size(), buf, buf + readed); } std::string format = "mod|links|group|user|size|date:2|name"; auto form = get_format(format); for (auto a : form) std::cerr << a.name << ":" << a.words_ << std::endl; std::vector<char>::const_iterator it; }
static gboolean ffaudio_probe (const gchar * filename, VFSFile * file) { if (! file) return FALSE; return get_format (filename, file) ? TRUE : FALSE; }
static void cb_preview(raw_box* rb) { char *name; name = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(rb->dialog)); if (!name) return; if (!is_valid_file(name)) return; if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(rb->check))) { int samplerate = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(rb->samplerate)); mixer_preview(name, samplerate, rb->channels, get_format(rb),1); } else { int resamp = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(rb->resample_checkbox)); mixer_preview(name, 0, 0, 0, resamp); } return; }
Code write_stat(Pnode p) { /* WRITE_STAT / / N_SPECIFIER --> expr / / [expr-filename] */ Value format; int op; Schema exprschema; Code code = expr(p->child->brother, &exprschema); if (p->child->child != NULL) { // Con specifier code = appcode(code, specifier(p->child)); op = T_FPRINT; } else { // Senza specifier op = T_PRINT; } format.sval = get_format(&exprschema); free_schema(exprschema.next); return concode( code, makecode1(op, format), endcode() ); }
static void get_formats(GB_ARRAY array, bool drag = false) { int i, j; char *fmt; for (i = 0;; i++) { fmt = get_format(i, true, drag); if (!fmt) break; if (*fmt < 'a' || *fmt > 'z') continue; for (j = 0; j < GB.Array.Count(array); j++) { if (strcasecmp(fmt, *((char **)GB.Array.Get(array, j))) == 0) break; } if (j < GB.Array.Count(array)) continue; *((char **)GB.Array.Add(array)) = GB.NewZeroString(fmt); } }
/** * \brief Returns the tempo of the current music. * * This function is only supported for .it musics. * * \return The tempo of the current music. */ int Music::get_tempo() { Debug::check_assertion(get_format() == IT, "This function is only supported for .it musics"); return it_decoder->get_tempo(); }
void search_in_dir(char* dir, int pid){ DIR *d = opendir(dir); struct dirent *de; int counter=0; if(d == NULL) { err(1,"%s" ,dir); } char *buf =malloc(sizeof (PATH_MAX)); while((de = readdir(d)) != NULL) { buf= built_path(de->d_name,dir); if (is_file(buf)){ if(get_format(de->d_name)==1){ if (unlink(buf)<0){ printf("%d : error removing %s\n", pid ,de->d_name); }else { counter++; printf("%d : %s ok \n",pid ,de->d_name ); } } }else{ if(is_dir(buf)){ if((strcmp(de->d_name, ".") != 0) && (strcmp(de->d_name, "..")!=0)){ search_in_dir(buf,pid); } }else{ printf("\t%s It in not a valid file or directory\n", buf); } if ((counter==0) && (strcmp(de->d_name, ".") == 0)) printf("%d : no files to remove in :%s\n", pid ,dir); } } free(buf); closedir(d); }
void bx_param_enum_c::text_print(FILE *fp) { int n = get(); assert(n >= min && n <= max); const char *choice = choices[n - min]; if (get_format()) { fprintf(fp, get_format(), choice); } else { const char *format = "%s: %s"; if (get_label()) { fprintf(fp, format, get_label(), choice); } else { fprintf(fp, format, get_name(), choice); } } }
static int get_options(struct options *options, int argc, char *argv[]) { getopt_reset(); int ch; int long_option_index; while (-1 != (ch = getopt_long(argc, argv, short_options, long_options, &long_option_index))) { switch (ch) { case option_value_debug: options->debug = true; break; case option_value_format: get_format(options, optarg); break; case option_value_help: options->help = true; return optind; case option_value_jrand48: get_jrand48(options, optarg); break; case option_value_verbose: options->verbose = true; break; default: options->error = true; break; } } return optind; }
/** * \brief Sets the tempo of the current music. * * This function is only supported for .it musics. * * \param tempo The tempo to set. */ void Music::set_tempo(int tempo) { Debug::check_assertion(get_format() == IT, "This function is only supported for .it musics"); it_decoder->set_tempo(tempo); }
static void ft_switch(char **s, va_list args, size_t *size, char **p) { t_format *opt; int x; int d; x = 0; d = 0; if (**s == '%') { ++(*s); if (**s) if ((opt = get_format(s, args, 0))) { ft_add(p, ft_build(args, opt), size, 0); ft_memdel((void **)&opt); } } else if ((**s == '{' && *(*s + 1) == 'C') || **s == '}') ft_add(p, set_color(s), size, 2); else { ft_add(p, *s, size, 1); ++(*s); } }
Code read_stat(Pnode p) { Code result, specifiercode; int op; // Vincoli semantici Psymbol symbol = lookup(valname(p->child->brother)); if (symbol == NULL) semerror(p->child, "Unknown identifier"); if (p->child->child != NULL) { // Con specifier op = T_FGET; specifiercode = specifier(p->child); } else { op = T_GET; } Value v1; v1.ival = symbol->oid; Value v2; v2.sval = get_format(symbol->schema); result = makecode2(op, v1, v2); if (op == T_GET) return result; else return appcode(specifiercode, result); }
static AVFormatContext * open_input_file (const gchar * name, VFSFile * file) { AVInputFormat * f = get_format (name, file); if (! f) { fprintf (stderr, "ffaudio: Unknown format for %s.\n", name); return NULL; } AVFormatContext * c = avformat_alloc_context (); AVIOContext * io = io_context_new (file); c->pb = io; gint ret = avformat_open_input (& c, name, f, NULL); if (ret < 0) { fprintf (stderr, "ffaudio: avformat_open_input failed for %s: %s.\n", name, ffaudio_strerror (ret)); io_context_free (io); return NULL; } return c; }
int main() { page_size = sysconf(_SC_PAGESIZE); fd_cam = open(cam_name, O_RDWR, 0); fd_out = open(out_name, O_RDWR|O_CREAT); if(fd_cam < 0 || fd_out < 0 || errno){ perror("open device"); exit(1); } // if(ioctl(fd_cam, VIDIOC_QUERYCAP, &cap) < 0){ // perror("VIDIOC_QUERYCAP"); // exit(1); // } enum_fmt(); get_input(); get_format(); capture(); close(fd_cam); close(fd_out); }
static void p_part(char *from, char **ArgList) { char *channel; if (!from || !*from) return; channel = ArgList[0]; PasteArgs(ArgList, 1); message_from(channel, LOG_CRAP); in_on_who = 1; if ((check_ignore(from, FromUserHost, channel, IGNORE_PARTS | IGNORE_CRAP, NULL) != IGNORED) && do_hook(LEAVE_LIST, "%s %s %s %s", from, channel, FromUserHost, ArgList[1] ? ArgList[1] : empty_str)) put_it("%s", convert_output_format(get_format(FORMAT_LEAVE_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, FromUserHost, channel, ArgList[1] ? ArgList[1] : empty_str)); if (!my_stricmp(from, get_server_nickname(from_server))) { remove_channel(channel, from_server); remove_from_mode_list(channel, from_server); remove_from_join_list(channel, from_server); set_input_prompt(curr_scr_win, get_string_var(INPUT_PROMPT_VAR), 0); } else { remove_from_channel(channel, from, from_server, 0, NULL); } update_all_status(curr_scr_win, NULL, 0); update_input(UPDATE_ALL); message_from(NULL, LOG_CRAP); in_on_who = 0; }
bool vc4_tex_format_supported(enum pipe_format f) { const struct vc4_format *vf = get_format(f); return vf != NULL; }
int camera_init(struct picture_t *out_info) { fd_cam = open(CAM_NAME, O_RDWR); if(fd_cam < 0){ perror("open camera " CAM_NAME); return 0; } if(!get_format()) goto label_close; lib = v4lconvert_create(fd_cam); if(!lib) { perror("v4lconvert_create"); goto label_close; } if(!buf_alloc_mmap()) goto label_free; YUV420_size = current_pic.width*current_pic.height*3/2; if(!(current_pic.buffer = malloc(YUV420_size))){ perror("malloc"); goto label_free; } *out_info = current_pic; return 1; label_free: free_buf_mmap(); v4lconvert_destroy(lib); label_close: close(fd_cam); return 0; }
void* decode(JNIEnv* env, InputStream* stream, bool partially, int* format) { unsigned char magic_numbers[2]; PatchHeadInputStream* patch_head_input_stream; *format = get_format(env, stream); switch (*format) { #ifdef IMAGE_SUPPORT_JPEG case IMAGE_FORMAT_JPEG: magic_numbers[0] = IMAGE_JPEG_MAGIC_NUMBER_0; magic_numbers[1] = IMAGE_JPEG_MAGIC_NUMBER_1; break; #endif #ifdef IMAGE_SUPPORT_PNG case IMAGE_FORMAT_PNG: magic_numbers[0] = IMAGE_PNG_MAGIC_NUMBER_0; magic_numbers[1] = IMAGE_PNG_MAGIC_NUMBER_1; break; #endif #ifdef IMAGE_SUPPORT_GIF case IMAGE_FORMAT_GIF: magic_numbers[0] = IMAGE_GIF_MAGIC_NUMBER_0; magic_numbers[1] = IMAGE_GIF_MAGIC_NUMBER_1; break; #endif default: LOGE(EMSG("Can't detect format %d"), *format); destroy_input_stream(get_env(), &stream); return NULL; } patch_head_input_stream = create_patch_head_input_stream(stream, magic_numbers, 2); if (patch_head_input_stream == NULL){ WTF_OM; destroy_input_stream(get_env(), &stream); return NULL; } switch (*format) { #ifdef IMAGE_SUPPORT_JPEG case IMAGE_FORMAT_JPEG: return JPEG_decode(env, patch_head_input_stream, partially); #endif #ifdef IMAGE_SUPPORT_PNG case IMAGE_FORMAT_PNG: return PNG_decode(env, patch_head_input_stream, partially); #endif #ifdef IMAGE_SUPPORT_GIF case IMAGE_FORMAT_GIF: return GIF_decode(env, patch_head_input_stream, partially); #endif default: LOGE(EMSG("Can't detect format %d"), *format); close_patch_head_input_stream(get_env(), patch_head_input_stream); destroy_patch_head_input_stream(get_env(), &patch_head_input_stream); return NULL; } }
static void p_silence(char *from, char **ArgList) { char *target = ArgList[0]; char *mag = target++; if (do_hook(SILENCE_LIST, "%c %s", *mag, target)) put_it("%s", convert_output_format(get_format(FORMAT_SILENCE_FSET), "%s %c %s", update_clock(GET_TIME), *mag, target)); }