static void tri_swizzled( int offset, obj from, obj to ) { char *comment = NULL; char temp[1000], *d; d = temp; #if INCLUDE_COMMENTS if (OBJ_ISA_PTR(from)) { obj k = OBJ( VAL(from) - POINTER_TAG ); comment = get_comment( k ); } #endif if (offset == -1) d += sprintf( d, " class" ); else if (offset == -2) d += sprintf( d, " self" ); else d += sprintf( d, " [%d]", offset/SLOT(1) ); d += sprintf( d, " %#lx => %#lx", VAL(from), VAL(to) ); if (OBJ_ISA_PTR(to)) { d += sprintf( d, " *" ); } if (comment) { d += sprintf( d, " %s", comment ); } tri_printf( "%s\n", temp ); }
/* This implements the `svn_opt_subcommand_t' interface. */ svn_error_t * svn_cl__lock(apr_getopt_t *os, void *baton, apr_pool_t *pool) { svn_cl__opt_state_t *opt_state = ((svn_cl__cmd_baton_t *) baton)->opt_state; svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx; apr_array_header_t *targets; const char *comment; SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os, opt_state->targets, pool)); /* We only support locking files, so '.' is not valid. */ if (! targets->nelts) return svn_error_create(SVN_ERR_CL_INSUFFICIENT_ARGS, 0, NULL); /* Get comment. */ SVN_ERR(get_comment(&comment, ctx, opt_state, pool)); svn_cl__get_notifier(&ctx->notify_func2, &ctx->notify_baton2, FALSE, FALSE, FALSE, pool); SVN_ERR(svn_client_lock(targets, comment, opt_state->force, ctx, pool)); return SVN_NO_ERROR; }
char *check_header(int fd, header_t *header, int *line_nbr) { char *line; char *name; char *comment; name = NULL; comment = NULL; while ((line = get_next_line(fd)) != NULL) { if (start_cmp(NAME_CMD_STRING, line) == 0 && !(name = get_name(line))) return (line); else if (start_cmp(COMMENT_CMD_STRING, line) == 0 && !(comment = get_comment(line))) return (line); else if (is_comment(line) != 0 && is_empty(line) != 0 && start_cmp(NAME_CMD_STRING, line) != 0 && start_cmp(COMMENT_CMD_STRING, line) != 0) return (line); if (name != NULL && comment != NULL) { fill_header(name, comment, header); return (NULL); } *line_nbr = *line_nbr + 1; } return ("Header incomplet"); }
header_t *get_header(int *flag, int fd, int *l) { header_t *header; int error; error = 0; header = NULL; if ((header = malloc(sizeof(*header))) == NULL) my_merror(); if (get_name(fd, header, l) == EXIT_FAILURE) { my_printf("Asm: Name invalid at line %d.\n", *l); error++; } if (get_comment(fd, header, l) == EXIT_FAILURE) { my_printf("Asm: Comment invalid at line %d.\n", *l); error++; } if (get_extend(flag, fd, l) == EXIT_FAILURE) error++; if (error || !header) return (NULL); header->magic = magic(COREWAR_EXEC_MAGIC); return (header); }
int main(int argc, char *argv[]) { char *ptr; char *ptr2; char buf[1024]; if (argc < 2) { fprintf(stderr, "Usage: %s string\n", argv[0]); exit(1); } //char *line = argv[1]; // First we should get the length of string size_t len = strlen(argv[1]); // Then allocation enough room to store the string char *line = (char *)malloc(len + 1); if (!line) { fprintf(stderr, "Failed to allocate a room.!\n"); exit(-1); } memset(line, 0, len + 1); strncpy(line, argv[1], len); printf("line --> %s\n", line); get_word(line); get_number(line); get_comment(line); // Do some filt of the line, we do not need space and // comments ptr = clean_comment(line); len = strlen(ptr); bzero(buf, sizeof(buf)); strncpy(buf, ptr, len); printf("The buf --> %s\n", buf); ptr2 = clean_space(buf); if (ptr2) printf("The new line is :%s\n", ptr2); // At last, free the space // Array is a fix memory area, so we can not free the array, // we just can free the pointer to a dynamic memory area, once. //free(buf); free(ptr2); free(ptr); free(line); return 0; }
void cell::set_comment(const xlnt::comment &c) { if (c.d_ != d_->comment_.get()) { throw xlnt::attribute_error(); } if (!has_comment()) { get_parent().increment_comments(); } *get_comment().d_ = *c.d_; }
std::ostream §ion_schema::write_additional_info(std::ostream &os) const { // write comment auto comment_lines = string_utils::split(get_comment(), '\n'); for (auto &comment_line : comment_lines) { os << ";" << comment_line << std::endl; } // optional/mandatory std::string info_line = is_mandatory() ? "mandatory" : "optional"; os << ";<" << info_line << ">" << std::endl; return os; }
t_champion *get_list_champ(char **file_content) { char *name; char *comment; t_champion *champion; champion = NULL; if ((name = get_name(file_content[0])) == NULL) return (champion); if ((comment = get_comment(file_content[1])) == NULL) return (champion); if (add_champion(&champion, name, comment) == -1) return (NULL); set_champ_labels(&champion->lst_label, file_content); set_labels_instruction(&champion->lst_label, file_content); show_champions(champion); return (champion); }
char *check_comment(char *arg, int *argc, char **argv) { int n = find_arg(arg, *argc, argv); char *v; if (n < 0) return NULL; /* Remove the "-comment" */ excise_arg(n, argc, argv); if (n >= *argc) { return get_comment_stdin(); } v = argv[n]; excise_arg(n, argc, argv); if (v[0] == '@') { if (v[1] == '-') return get_comment_stdin(); return get_comment(v + 1); } return v; }
static int read_datafile (const char *fname, dataset *dset) { #ifdef PLAY_AUTOFIT_LINE int fitline = 0; #endif char line[256]; int i, err = 0; int got_e = 0, y2data = 0; FILE *fdat; dataset_init(dset); fdat = gretl_fopen(fname, "r"); if (fdat == NULL) { fprintf(stderr, "Couldn't open '%s'\n", fname); return 1; } else { fprintf(stderr, "Reading %s...\n", fname); } while (fgets(line, sizeof line, fdat)) { tailstrip(line); if (get_comment(line, dset)) { continue; } else if (!strcmp(line, "e")) { fprintf(stderr, "Got end of data marker\n"); got_e++; if (got_e == 2) { /* can't handle more than two series! */ break; } } else if (strstr(line, "automatic fitted")) { #ifdef PLAY_AUTOFIT_LINE fitline = 1; #endif continue; } else if (isdigit((unsigned char) line[0])) { if (strstr(line, "title")) { #ifdef PLAY_AUTOFIT_LINE if (fitline) { get_fit_params(line, dset); } #endif continue; } if (!got_e) { dset->n += 1; } else if (!y2data) { y2data = 1; } } } if (dset->n == 0) { fprintf(stderr, "No data in '%s'\n", fname); err = 1; goto bailout; } dset->points = malloc(dset->n * sizeof *dset->points); if (dset->points == NULL) { err = 1; fputs("Out of memory\n", stderr); goto bailout; } if (y2data) { dset->y2 = malloc(dset->n * sizeof *dset->y2); if (dset->y2 == NULL) { err = 1; fputs("Out of memory\n", stderr); goto bailout; } dset->series2 = 1; } rewind(fdat); i = got_e = 0; while (!err && fgets(line, 256, fdat)) { tailstrip(line); if (!strcmp(line, "e")) { got_e++; if (got_e == 2) { break; } i = 0; } else if (isdigit((unsigned char) line[0])) { double x, y; if (strstr(line, "title")) { continue; } if (get_data_x_y(line, &x, &y)) { fprintf(stderr, "Couldn't read data on line %d\n", i + 1); err = 1; } else { if (!got_e) { dset->points[i].x = x; dset->points[i].y = y; } else { dset->y2[i] = y; } } i++; } } bailout: fclose(fdat); if (err) { dataset_free(dset); } return err; }
void vorbis_file_info_box(char *fn) { char *track_name, *performer, *album_name, *date, *track_number; char *genre, *user_comment, *tmp; char *description, *version, *isrc, *copyright, *organization; char *location, *vendor = "N/A"; char *rg_track_gain, *rg_album_gain, *rg_track_peak, *rg_album_peak; int time, minutes, seconds, bitrate, avgbitrate, rate, channels; int filesize, i; OggVorbis_File vf; vorbis_info *vi; vorbis_comment *comment = NULL; FILE *fh; gboolean clear_vf = FALSE; g_free(vte.filename); vte.filename = g_strdup(fn); if (!window) { GtkWidget *info_frame, *info_box; GtkWidget *hbox, *label, *filename_hbox, *vbox, *left_vbox; GtkWidget *table, *bbox, *cancel_button; GtkWidget *save_button, *remove_button; window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE); gtk_signal_connect(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &window); gtk_signal_connect(GTK_OBJECT(window), "key_press_event", keypress_cb, NULL); gtk_container_set_border_width(GTK_CONTAINER(window), 10); vbox = gtk_vbox_new(FALSE, 10); gtk_container_add(GTK_CONTAINER(window), vbox); filename_hbox = gtk_hbox_new(FALSE, 5); gtk_box_pack_start(GTK_BOX(vbox), filename_hbox, FALSE, TRUE, 0); label = gtk_label_new(_("Filename:")); gtk_box_pack_start(GTK_BOX(filename_hbox), label, FALSE, TRUE, 0); filename_entry = gtk_entry_new(); gtk_editable_set_editable(GTK_EDITABLE(filename_entry), FALSE); gtk_box_pack_start(GTK_BOX(filename_hbox), filename_entry, TRUE, TRUE, 0); hbox = gtk_hbox_new(FALSE, 10); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); left_vbox = gtk_vbox_new(FALSE, 10); gtk_box_pack_start(GTK_BOX(hbox), left_vbox, FALSE, FALSE, 0); tag_frame = gtk_frame_new(_("Ogg Vorbis Tag:")); gtk_box_pack_start(GTK_BOX(left_vbox), tag_frame, FALSE, FALSE, 0); table = gtk_table_new(5, 5, FALSE); gtk_container_set_border_width(GTK_CONTAINER(table), 5); gtk_container_add(GTK_CONTAINER(tag_frame), table); label = gtk_label_new(_("Title:")); gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 5, 5); title_entry = gtk_entry_new(); gtk_table_attach(GTK_TABLE(table), title_entry, 1, 4, 0, 1, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); label = gtk_label_new(_("Artist:")); gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 5, 5); performer_entry = gtk_entry_new(); gtk_table_attach(GTK_TABLE(table), performer_entry, 1, 4, 1, 2, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); label = gtk_label_new(_("Album:")); gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, GTK_FILL, GTK_FILL, 5, 5); album_entry = gtk_entry_new(); gtk_table_attach(GTK_TABLE(table), album_entry, 1, 4, 2, 3, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); label = gtk_label_new(_("Comment:")); gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, GTK_FILL, GTK_FILL, 5, 5); user_comment_entry = gtk_entry_new(); gtk_table_attach(GTK_TABLE(table), user_comment_entry, 1, 4, 3, 4, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); label = gtk_label_new(_("Date:")); gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 4, 5, GTK_FILL, GTK_FILL, 5, 5); date_entry = gtk_entry_new(); gtk_widget_set_usize(date_entry, 60, -1); gtk_table_attach(GTK_TABLE(table), date_entry, 1, 2, 4, 5, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); label = gtk_label_new(_("Track number:")); gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); gtk_table_attach(GTK_TABLE(table), label, 2, 3, 4, 5, GTK_FILL, GTK_FILL, 5, 5); tracknumber_entry = gtk_entry_new_with_max_length(4); gtk_widget_set_usize(tracknumber_entry, 20, -1); gtk_table_attach(GTK_TABLE(table), tracknumber_entry, 3, 4, 4, 5, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); label = gtk_label_new(_("Genre:")); gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 5, 6, GTK_FILL, GTK_FILL, 5, 5); genre_combo = gtk_combo_new(); if (!genre_list) { for (i = 0; i < sizeof(vorbis_genres)/sizeof(*vorbis_genres) ; i++) genre_list = g_list_prepend(genre_list, _(vorbis_genres[i])); genre_list = g_list_sort(genre_list, (GCompareFunc)g_strcasecmp); } gtk_combo_set_popdown_strings(GTK_COMBO(genre_combo), genre_list); gtk_table_attach(GTK_TABLE(table), genre_combo, 1, 4, 5, 6, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); #ifdef ALL_VORBIS_TAGS label = gtk_label_new(_("Description:")); gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 6, 7, GTK_FILL, GTK_FILL, 5, 5); description_entry = gtk_entry_new(); gtk_table_attach(GTK_TABLE(table), description_entry, 1, 4, 6, 7, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); label = gtk_label_new(_("Location:")); gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 7, 8, GTK_FILL, GTK_FILL, 5, 5); location_entry = gtk_entry_new(); gtk_table_attach(GTK_TABLE(table), location_entry, 1, 4, 7, 8, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); label = gtk_label_new(_("Version:")); gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 8, 9, GTK_FILL, GTK_FILL, 5, 5); version_entry = gtk_entry_new(); gtk_widget_set_usize(version_entry, 60, -1); gtk_table_attach(GTK_TABLE(table), version_entry, 1, 2, 8, 9, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); label = gtk_label_new(_("ISRC number:")); gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); gtk_table_attach(GTK_TABLE(table), label, 2, 3, 8, 9, GTK_FILL, GTK_FILL, 5, 5); isrc_entry = gtk_entry_new(); gtk_widget_set_usize(isrc_entry, 20, -1); gtk_table_attach(GTK_TABLE(table), isrc_entry, 3, 4, 8, 9, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); label = gtk_label_new(_("Organization:")); gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 9, 10, GTK_FILL, GTK_FILL, 5, 5); organization_entry = gtk_entry_new(); gtk_table_attach(GTK_TABLE(table), organization_entry, 1, 4, 9, 10, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); label = gtk_label_new(_("Copyright:")); gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 10, 11, GTK_FILL, GTK_FILL, 5, 5); copyright_entry = gtk_entry_new(); gtk_table_attach(GTK_TABLE(table), copyright_entry, 1, 4, 10, 11, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); #endif rg_show_button = gtk_check_button_new_with_label(_("ReplayGain Settings:")); gtk_signal_connect(GTK_OBJECT(rg_show_button), "toggled", GTK_SIGNAL_FUNC(rg_show_cb), NULL); gtk_table_attach(GTK_TABLE(table), rg_show_button, 0, 2, 11, 12, GTK_FILL, GTK_FILL, 5, 5); rg_track_label = gtk_label_new(_("Track gain:")); gtk_misc_set_alignment(GTK_MISC(rg_track_label), 1, 0.5); gtk_table_attach(GTK_TABLE(table), rg_track_label, 2, 3, 11, 12, GTK_FILL, GTK_FILL, 5, 5); rg_track_entry = gtk_entry_new(); gtk_table_attach(GTK_TABLE(table), rg_track_entry, 3, 4, 11, 12, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); rg_track_peak_label = gtk_label_new(_("Track peak:")); gtk_misc_set_alignment(GTK_MISC(rg_track_peak_label), 1, 0.5); gtk_table_attach(GTK_TABLE(table), rg_track_peak_label, 2, 3, 12, 13, GTK_FILL, GTK_FILL, 5, 5); rg_track_peak_entry = gtk_entry_new(); gtk_table_attach(GTK_TABLE(table), rg_track_peak_entry, 3, 4, 12, 13, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); rg_album_label = gtk_label_new(_("Album gain:")); gtk_misc_set_alignment(GTK_MISC(rg_album_label), 1, 0.5); gtk_table_attach(GTK_TABLE(table), rg_album_label, 2, 3, 13, 14, GTK_FILL, GTK_FILL, 5, 5); rg_album_entry = gtk_entry_new(); gtk_table_attach(GTK_TABLE(table), rg_album_entry, 3, 4, 13, 14, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); rg_album_peak_label = gtk_label_new(_("Album peak:")); gtk_misc_set_alignment(GTK_MISC(rg_album_peak_label), 1, 0.5); gtk_table_attach(GTK_TABLE(table), rg_album_peak_label, 2, 3, 14, 15, GTK_FILL, GTK_FILL, 5, 5); rg_album_peak_entry = gtk_entry_new(); gtk_table_attach(GTK_TABLE(table), rg_album_peak_entry, 3, 4, 14, 15, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); bbox = gtk_hbutton_box_new(); gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); gtk_box_pack_start(GTK_BOX(left_vbox), bbox, FALSE, FALSE, 0); save_button = gtk_button_new_with_label(_("Save")); gtk_signal_connect(GTK_OBJECT(save_button), "clicked", GTK_SIGNAL_FUNC(save_cb), NULL); GTK_WIDGET_SET_FLAGS(save_button, GTK_CAN_DEFAULT); gtk_box_pack_start(GTK_BOX(bbox), save_button, TRUE, TRUE, 0); gtk_widget_grab_default(save_button); remove_button = gtk_button_new_with_label(_("Remove Tag")); gtk_signal_connect_object(GTK_OBJECT(remove_button), "clicked", GTK_SIGNAL_FUNC(remove_cb), NULL); GTK_WIDGET_SET_FLAGS(remove_button, GTK_CAN_DEFAULT); gtk_box_pack_start(GTK_BOX(bbox),remove_button, TRUE, TRUE, 0); cancel_button = gtk_button_new_with_label(_("Cancel")); gtk_signal_connect_object(GTK_OBJECT(cancel_button), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(window)); GTK_WIDGET_SET_FLAGS(cancel_button, GTK_CAN_DEFAULT); gtk_box_pack_start(GTK_BOX(bbox),cancel_button, TRUE, TRUE, 0); info_frame = gtk_frame_new(_("Ogg Vorbis Info:")); gtk_box_pack_start(GTK_BOX(hbox), info_frame, FALSE, FALSE, 0); info_box = gtk_vbox_new(FALSE, 5); gtk_container_add(GTK_CONTAINER(info_frame), info_box); gtk_container_set_border_width(GTK_CONTAINER(info_box), 10); gtk_box_set_spacing(GTK_BOX(info_box), 0); bitrate_label = gtk_label_new(""); gtk_misc_set_alignment(GTK_MISC(bitrate_label), 0, 0); gtk_label_set_justify(GTK_LABEL(bitrate_label), GTK_JUSTIFY_LEFT); gtk_box_pack_start(GTK_BOX(info_box), bitrate_label, FALSE, FALSE, 0); avgbitrate_label = gtk_label_new(""); gtk_misc_set_alignment(GTK_MISC(avgbitrate_label), 0, 0); gtk_label_set_justify(GTK_LABEL(avgbitrate_label), GTK_JUSTIFY_LEFT); gtk_box_pack_start(GTK_BOX(info_box), avgbitrate_label, FALSE, FALSE, 0); rate_label = gtk_label_new(""); gtk_misc_set_alignment(GTK_MISC(rate_label), 0, 0); gtk_label_set_justify(GTK_LABEL(rate_label), GTK_JUSTIFY_LEFT); gtk_box_pack_start(GTK_BOX(info_box), rate_label, FALSE, FALSE, 0); channel_label = gtk_label_new(""); gtk_misc_set_alignment(GTK_MISC(channel_label), 0, 0); gtk_label_set_justify(GTK_LABEL(channel_label), GTK_JUSTIFY_LEFT); gtk_box_pack_start(GTK_BOX(info_box), channel_label, FALSE, FALSE, 0); length_label = gtk_label_new(""); gtk_misc_set_alignment(GTK_MISC(length_label), 0, 0); gtk_label_set_justify(GTK_LABEL(length_label), GTK_JUSTIFY_LEFT); gtk_box_pack_start(GTK_BOX(info_box), length_label, FALSE, FALSE, 0); filesize_label = gtk_label_new(""); gtk_misc_set_alignment(GTK_MISC(filesize_label), 0, 0); gtk_label_set_justify(GTK_LABEL(filesize_label), GTK_JUSTIFY_LEFT); gtk_box_pack_start(GTK_BOX(info_box), filesize_label, FALSE, FALSE, 0); vendor_label = gtk_label_new(""); gtk_misc_set_alignment(GTK_MISC(vendor_label), 0, 0); gtk_label_set_justify(GTK_LABEL(vendor_label), GTK_JUSTIFY_LEFT); gtk_box_pack_start(GTK_BOX(info_box), vendor_label, FALSE, FALSE, 0); replaygain_label = gtk_label_new(""); gtk_misc_set_alignment(GTK_MISC(replaygain_label), 0, 0); gtk_label_set_justify(GTK_LABEL(replaygain_label), GTK_JUSTIFY_LEFT); gtk_box_pack_start(GTK_BOX(info_box), replaygain_label, FALSE, FALSE, 0); audiophilegain_label = gtk_label_new(""); gtk_misc_set_alignment(GTK_MISC(audiophilegain_label), 0, 0); gtk_label_set_justify(GTK_LABEL(audiophilegain_label), GTK_JUSTIFY_LEFT); gtk_box_pack_start(GTK_BOX(info_box), audiophilegain_label, FALSE, FALSE, 0); peak_label = gtk_label_new(""); gtk_misc_set_alignment(GTK_MISC(peak_label), 0, 0); gtk_label_set_justify(GTK_LABEL(peak_label), GTK_JUSTIFY_LEFT); gtk_box_pack_start(GTK_BOX(info_box), peak_label, FALSE, FALSE, 0); gtk_widget_show_all(window); } else gdk_window_raise(window->window); if (!g_strncasecmp(vte.filename, "http://", 7)) gtk_widget_set_sensitive(tag_frame, FALSE); else gtk_widget_set_sensitive(tag_frame, TRUE); gtk_label_set_text(GTK_LABEL(bitrate_label), ""); gtk_label_set_text(GTK_LABEL(avgbitrate_label), ""); gtk_label_set_text(GTK_LABEL(rate_label), ""); gtk_label_set_text(GTK_LABEL(channel_label), ""); gtk_label_set_text(GTK_LABEL(length_label), ""); gtk_label_set_text(GTK_LABEL(filesize_label), ""); gtk_label_set_text(GTK_LABEL(vendor_label), ""); if ((fh = fopen(vte.filename, "r")) != NULL) { pthread_mutex_lock(&vf_mutex); if (ov_open(fh, &vf, NULL, 0) == 0) { comment = ov_comment(&vf, -1); if (comment && comment->vendor) vendor = comment->vendor; if ((vi = ov_info(&vf, 0)) != NULL) { bitrate = vi->bitrate_nominal/1000; avgbitrate = ov_bitrate(&vf, -1); if (avgbitrate == OV_EINVAL || avgbitrate == OV_FALSE) avgbitrate = 0; rate = vi->rate; channels = vi->channels; clear_vf = TRUE; } else { bitrate = 0; avgbitrate = 0; rate = 0; channels = 0; } time = ov_time_total(&vf, -1); minutes = time / 60; seconds = time % 60; fseek(fh, 0, SEEK_END); filesize = ftell(fh); label_set_text(bitrate_label, _("Nominal bitrate: %d kbps"), bitrate); label_set_text(avgbitrate_label, _("Average bitrate: %.1f kbps"), ((float) avgbitrate) / 1000); label_set_text(rate_label, _("Samplerate: %d Hz"), rate); label_set_text(channel_label, _("Channels: %d"), channels); label_set_text(length_label, _("Length: %d:%.2d"), minutes, seconds); label_set_text(filesize_label, _("File size: %d B"), filesize); label_set_text(vendor_label, _("Vendor: %s"), vendor); } else fclose(fh); } track_name = get_comment(comment, "title"); performer = get_comment(comment, "artist"); album_name = get_comment(comment, "album"); track_number = get_comment(comment, "tracknumber"); genre = get_comment(comment, "genre"); date = get_comment(comment, "date"); user_comment = get_comment(comment, "comment"); location = get_comment(comment, "location"); description = get_comment(comment, "description"); version = get_comment(comment, "version"); isrc = get_comment(comment, "isrc"); organization = get_comment(comment, "organization"); copyright = get_comment(comment, "copyright"); rg_track_gain = get_comment(comment, "replaygain_track_gain"); if (*rg_track_gain == '\0') { g_free(rg_track_gain); rg_track_gain = get_comment(comment, "rg_radio"); /* Old */ } rg_album_gain = get_comment(comment, "replaygain_album_gain"); if (*rg_album_gain == '\0') { g_free(rg_album_gain); rg_album_gain = get_comment(comment, "rg_audiophile"); /* Old */ } rg_track_peak = get_comment(comment, "replaygain_track_peak"); if (*rg_track_peak == '\0') { g_free(rg_track_peak); rg_track_peak = get_comment(comment, "rg_peak"); /* Old */ } rg_album_peak = get_comment(comment, "replaygain_album_peak"); /* Old had no album peak */ /* ov_clear closes the file */ if (clear_vf) ov_clear(&vf); pthread_mutex_unlock(&vf_mutex); /* Fill it all in .. */ gtk_entry_set_text(GTK_ENTRY(title_entry), track_name); gtk_entry_set_text(GTK_ENTRY(performer_entry), performer); gtk_entry_set_text(GTK_ENTRY(album_entry), album_name); gtk_entry_set_text(GTK_ENTRY(user_comment_entry), user_comment); gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(genre_combo)->entry), genre); gtk_entry_set_text(GTK_ENTRY(tracknumber_entry), track_number); gtk_entry_set_text(GTK_ENTRY(date_entry), date); #ifdef ALL_VORBIS_TAGS gtk_entry_set_text(GTK_ENTRY(version_entry), version); gtk_entry_set_text(GTK_ENTRY(description_entry), description); gtk_entry_set_text(GTK_ENTRY(organization_entry), organization); gtk_entry_set_text(GTK_ENTRY(copyright_entry), copyright); gtk_entry_set_text(GTK_ENTRY(isrc_entry), isrc); gtk_entry_set_text(GTK_ENTRY(location_entry), location); #endif gtk_entry_set_text(GTK_ENTRY(filename_entry), vte.filename); gtk_editable_set_position(GTK_EDITABLE(filename_entry), -1); gtk_entry_set_text(GTK_ENTRY(rg_track_entry), rg_track_gain); gtk_entry_set_text(GTK_ENTRY(rg_album_entry), rg_album_gain); gtk_entry_set_text(GTK_ENTRY(rg_track_peak_entry), rg_track_peak); gtk_editable_set_position(GTK_EDITABLE(rg_track_peak_entry), -1); gtk_entry_set_text(GTK_ENTRY(rg_album_peak_entry), rg_album_peak); gtk_editable_set_position(GTK_EDITABLE(rg_album_peak_entry), -1); if (*rg_track_gain == '\0' && *rg_album_gain == '\0' && *rg_track_peak == '\0' && *rg_album_peak == '\0') { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rg_show_button), FALSE); rg_show_cb(rg_show_button, NULL); } else gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rg_show_button), TRUE); tmp = g_strdup_printf(_("File Info - %s"), g_basename(vte.filename)); gtk_window_set_title(GTK_WINDOW(window), tmp); g_free(tmp); /* Cleanup .. */ g_free(track_name); g_free(performer); g_free(album_name); g_free(track_number); g_free(genre); g_free(date); g_free(user_comment); g_free(location); g_free(description); g_free(version); g_free(isrc); g_free(organization); g_free(copyright); g_free(rg_track_gain); g_free(rg_album_gain); g_free(rg_track_peak); g_free(rg_album_peak); }
void nft_rule_to_iptables_command_state(struct nftnl_rule *r, struct iptables_command_state *cs) { struct nftnl_expr_iter *iter; struct nftnl_expr *expr; int family = nftnl_rule_get_u32(r, NFTNL_RULE_FAMILY); struct nft_xt_ctx ctx = { .state.cs = cs, .family = family, }; iter = nftnl_expr_iter_create(r); if (iter == NULL) return; ctx.iter = iter; expr = nftnl_expr_iter_next(iter); while (expr != NULL) { const char *name = nftnl_expr_get_str(expr, NFTNL_EXPR_NAME); if (strcmp(name, "counter") == 0) nft_parse_counter(expr, &ctx.state.cs->counters); else if (strcmp(name, "payload") == 0) nft_parse_payload(&ctx, expr); else if (strcmp(name, "meta") == 0) nft_parse_meta(&ctx, expr); else if (strcmp(name, "bitwise") == 0) nft_parse_bitwise(&ctx, expr); else if (strcmp(name, "cmp") == 0) nft_parse_cmp(&ctx, expr); else if (strcmp(name, "immediate") == 0) nft_parse_immediate(&ctx, expr); else if (strcmp(name, "match") == 0) nft_parse_match(&ctx, expr); else if (strcmp(name, "target") == 0) nft_parse_target(&ctx, expr); expr = nftnl_expr_iter_next(iter); } nftnl_expr_iter_destroy(iter); if (nftnl_rule_is_set(r, NFTNL_RULE_USERDATA)) { const void *data; uint32_t len; struct xtables_match *match; struct xt_entry_match *m; data = nftnl_rule_get_data(r, NFTNL_RULE_USERDATA, &len); match = xtables_find_match("comment", XTF_TRY_LOAD, &cs->matches); if (match == NULL) return; m = calloc(1, sizeof(struct xt_entry_match) + len); if (m == NULL) { fprintf(stderr, "OOM"); exit(EXIT_FAILURE); } memcpy(&m->data, get_comment(data, len), len); m->u.match_size = len + XT_ALIGN(sizeof(struct xt_entry_match)); m->u.user.revision = 0; strcpy(m->u.user.name, match->name); match->m = m; } if (cs->target != NULL) cs->jumpto = cs->target->name; else if (cs->jumpto != NULL) cs->target = xtables_find_target(cs->jumpto, XTF_TRY_LOAD); else cs->jumpto = ""; } void print_header(unsigned int format, const char *chain, const char *pol, const struct xt_counters *counters, bool basechain, uint32_t refs) { printf("Chain %s", chain); if (basechain) { printf(" (policy %s", pol); if (!(format & FMT_NOCOUNTS)) { fputc(' ', stdout); xtables_print_num(counters->pcnt, (format|FMT_NOTABLE)); fputs("packets, ", stdout); xtables_print_num(counters->bcnt, (format|FMT_NOTABLE)); fputs("bytes", stdout); } printf(")\n"); } else { printf(" (%u references)\n", refs); } if (format & FMT_LINENUMBERS) printf(FMT("%-4s ", "%s "), "num"); if (!(format & FMT_NOCOUNTS)) { if (format & FMT_KILOMEGAGIGA) { printf(FMT("%5s ","%s "), "pkts"); printf(FMT("%5s ","%s "), "bytes"); } else { printf(FMT("%8s ","%s "), "pkts"); printf(FMT("%10s ","%s "), "bytes"); } } if (!(format & FMT_NOTARGET)) printf(FMT("%-9s ","%s "), "target"); fputs(" prot ", stdout); if (format & FMT_OPTIONS) fputs("opt", stdout); if (format & FMT_VIA) { printf(FMT(" %-6s ","%s "), "in"); printf(FMT("%-6s ","%s "), "out"); } printf(FMT(" %-19s ","%s "), "source"); printf(FMT(" %-19s "," %s "), "destination"); printf("\n"); }
/* Peel the next preprocessor token off of SRC, and put it in TOK. Mutate TOK to refer to the first token in SRC, and mutate SRC to refer to the text after that token. SRC must be a shared buffer; the resulting TOK will be shared, pointing into the same string SRC does. Initialize TOK's last_token field. Return non-zero if we succeed, or 0 if we didn't find any more tokens in SRC. */ static int get_token (struct macro_buffer *tok, struct macro_buffer *src) { char *p = src->text; char *end = p + src->len; gdb_assert (src->shared); /* From the ISO C standard, ISO/IEC 9899:1999 (E), section 6.4: preprocessing-token: header-name identifier pp-number character-constant string-literal punctuator each non-white-space character that cannot be one of the above We don't have to deal with header-name tokens, since those can only occur after a #include, which we will never see. */ while (p < end) if (macro_is_whitespace (*p)) p++; else if (get_comment (tok, p, end)) p += tok->len; else if (get_pp_number (tok, p, end) || get_character_constant (tok, p, end) || get_string_literal (tok, p, end) /* Note: the grammar in the standard seems to be ambiguous: L'x' can be either a wide character constant, or an identifier followed by a normal character constant. By trying `get_identifier' after we try get_character_constant and get_string_literal, we give the wide character syntax precedence. Now, since GDB doesn't handle wide character constants anyway, is this the right thing to do? */ || get_identifier (tok, p, end) || get_punctuator (tok, p, end)) { /* How many characters did we consume, including whitespace? */ int consumed = p - src->text + tok->len; src->text += consumed; src->len -= consumed; return 1; } else { /* We have found a "non-whitespace character that cannot be one of the above." Make a token out of it. */ int consumed; set_token (tok, p, p + 1); consumed = p - src->text + tok->len; src->text += consumed; src->len -= consumed; return 1; } return 0; }
yXylex(){ int nstr; extern int yXyprevious; while((nstr = yXylook()) >= 0) yXyfussy: switch(nstr){ case 0: if(yXywrap()) return(0); break; case 1: {} break; case 2: {} break; case 3: {return(OBCR_TKN);} break; case 4: {return(TIMEV_TKN);} break; case 5: {return(TIMECHG_TKN);} break; case 6: {return(MSG_TKN);} break; case 7: {return(MSG_TKN);} break; case 8: {return(RMINT_TKN);} break; case 9: {return(GO_TKN);} break; case 10: {return(MACKS_TKN);} break; case 11: {return(END_TKN);} break; case 12: {return(MONON_TKN);} break; case 13: {return(MONOFF_TKN);} break; case 14: {return(OBJSTKSIZE_TKN);} break; case 15: {return(CUTOFF_TKN);} break; case 16: {return(DISP_TKN);} break; case 17: {return(GETF_TKN);} break; case 18: {return(DELFILE_TKN);} break; case 19: {return(PUTF_TKN);} break; case 20: {return(NOSTDT_TKN);} break; case 21: {return(PKTLEN_TKN);} break; case 22: {return(ISLOG_TKN);} break; case 23: {return(DLM_TKN);} break; case 24: {return(IDLEDLM_TKN);} break; case 25: {return(MAXOFF_TKN);} break; case 26: {return(MIGRATIONS_TKN);} break; case 27: {return(DLMINT_TKN);} break; case 28: {return(OBSTATS_TKN);} break; case 29: {return(TPINIT_TKN);} break; case 30: {return(MAXPOOL_TKN);} break; case 31: {return(ALLOWNOW_TKN);} break; case 32: {return(NEST_TKN);} break; case 33: { yXylval.int_val = atoi(yXytext); return (INT_TKN); } break; case 34: { yXylval.long_val = atol(yXytext); return (LONG_TKN); } break; case 35: case 36: case 37: { yXylval.dbl_val = atof(yXytext); return(DOUBLE_TKN); } break; case 38: { /* Call input until a newline is found. */ get_comment(); return(NUL_TKN); } break; case 39: { /* Call input until a closing double quote is found. */ get_string(); return(STR_TKN); } break; case 40: case 41: { yXylval.str_val = calloc(yXyleng + 1, sizeof(char)); strncpy (yXylval.str_val, yXytext, yXyleng); msgtextlen = yXyleng; /* ### */ return (STR_TKN); } break; case 42: {} break; case 43: {return(NUL_TKN);} break; case -1: break; default: fprintf(yXyout,"bad switch yXylook %d",nstr); } return(0); }