示例#1
0
文件: gen_idt.c 项目: bboozzoo/zephyr
static void validate_vector_id(void)
{
	int  i;
	int  vectors[MAX_NUM_VECTORS] = {0};

	for (i = 0; i < genidt_header.num_entries; i++) {
		if (supplied_entry[i].vector_id == UNSPECIFIED_INT_VECTOR) {
			/*
			 * Vector is to be allocated.  No further validation to be
			 * done at the moment.
			 */
			continue;
		}

		if (supplied_entry[i].vector_id >= num_vectors) {
			fprintf(stderr,
					"Vector ID exceeds specified # of vectors (%d).\n",
					num_vectors);
			show_entry(&supplied_entry[i]);
			clean_exit(-1);
		}

		if (vectors[supplied_entry[i].vector_id] != 0) {
			fprintf(stderr, "Duplicate vector ID found.\n");
			show_entry(&supplied_entry[i]);
			clean_exit(-1);
		}
	vectors[supplied_entry[i].vector_id]++;
	}
}
示例#2
0
文件: tree-diff.c 项目: Inkdit/git
static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2, const char *base, int baselen, struct diff_options *opt)
{
	unsigned mode1, mode2;
	const char *path1, *path2;
	const unsigned char *sha1, *sha2;
	int cmp, pathlen1, pathlen2;
	char *fullname;

	sha1 = tree_entry_extract(t1, &path1, &mode1);
	sha2 = tree_entry_extract(t2, &path2, &mode2);

	pathlen1 = tree_entry_len(path1, sha1);
	pathlen2 = tree_entry_len(path2, sha2);
	cmp = base_name_compare(path1, pathlen1, mode1, path2, pathlen2, mode2);
	if (cmp < 0) {
		show_entry(opt, "-", t1, base, baselen);
		return -1;
	}
	if (cmp > 0) {
		show_entry(opt, "+", t2, base, baselen);
		return 1;
	}
	if (!DIFF_OPT_TST(opt, FIND_COPIES_HARDER) && !hashcmp(sha1, sha2) && mode1 == mode2)
		return 0;

	/*
	 * If the filemode has changed to/from a directory from/to a regular
	 * file, we need to consider it a remove and an add.
	 */
	if (S_ISDIR(mode1) != S_ISDIR(mode2)) {
		show_entry(opt, "-", t1, base, baselen);
		show_entry(opt, "+", t2, base, baselen);
		return 0;
	}

	if (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode1)) {
		int retval;
		char *newbase = malloc_base(base, baselen, path1, pathlen1);
		if (DIFF_OPT_TST(opt, TREE_IN_RECURSIVE)) {
			newbase[baselen + pathlen1] = 0;
			opt->change(opt, mode1, mode2,
				    sha1, sha2, newbase);
			newbase[baselen + pathlen1] = '/';
		}
		retval = diff_tree_sha1(sha1, sha2, newbase, opt);
		free(newbase);
		return retval;
	}

	fullname = malloc_fullname(base, baselen, path1, pathlen1);
	opt->change(opt, mode1, mode2, sha1, sha2, fullname);
	free(fullname);
	return 0;
}
示例#3
0
int diff_tree(struct tree_desc *t1, struct tree_desc *t2,
	      const char *base_str, struct diff_options *opt)
{
	struct strbuf base;
	int baselen = strlen(base_str);
	enum interesting t1_match = entry_not_interesting;
	enum interesting t2_match = entry_not_interesting;

	/* Enable recursion indefinitely */
	opt->pathspec.recursive = DIFF_OPT_TST(opt, RECURSIVE);
	opt->pathspec.max_depth = -1;

	strbuf_init(&base, PATH_MAX);
	strbuf_add(&base, base_str, baselen);

	for (;;) {
		if (diff_can_quit_early(opt))
			break;
		if (opt->pathspec.nr) {
			skip_uninteresting(t1, &base, opt, &t1_match);
			skip_uninteresting(t2, &base, opt, &t2_match);
		}
		if (!t1->size) {
			if (!t2->size)
				break;
			show_entry(opt, "+", t2, &base);
			update_tree_entry(t2);
			continue;
		}
		if (!t2->size) {
			show_entry(opt, "-", t1, &base);
			update_tree_entry(t1);
			continue;
		}
		switch (compare_tree_entry(t1, t2, &base, opt)) {
		case -1:
			update_tree_entry(t1);
			continue;
		case 0:
			update_tree_entry(t1);
			/* Fallthrough */
		case 1:
			update_tree_entry(t2);
			continue;
		}
		die("git diff-tree: internal error");
	}

	strbuf_release(&base);
	return 0;
}
示例#4
0
static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2,
			      struct strbuf *base, struct diff_options *opt)
{
	unsigned mode1, mode2;
	const char *path1, *path2;
	const unsigned char *sha1, *sha2;
	int cmp, pathlen1, pathlen2;
	int old_baselen = base->len;

	sha1 = tree_entry_extract(t1, &path1, &mode1);
	sha2 = tree_entry_extract(t2, &path2, &mode2);

	pathlen1 = tree_entry_len(path1, sha1);
	pathlen2 = tree_entry_len(path2, sha2);
	cmp = base_name_compare(path1, pathlen1, mode1, path2, pathlen2, mode2);
	if (cmp < 0) {
		show_entry(opt, "-", t1, base);
		return -1;
	}
	if (cmp > 0) {
		show_entry(opt, "+", t2, base);
		return 1;
	}
	if (!DIFF_OPT_TST(opt, FIND_COPIES_HARDER) && !hashcmp(sha1, sha2) && mode1 == mode2)
		return 0;

	/*
	 * If the filemode has changed to/from a directory from/to a regular
	 * file, we need to consider it a remove and an add.
	 */
	if (S_ISDIR(mode1) != S_ISDIR(mode2)) {
		show_entry(opt, "-", t1, base);
		show_entry(opt, "+", t2, base);
		return 0;
	}

	strbuf_add(base, path1, pathlen1);
	if (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode1)) {
		if (DIFF_OPT_TST(opt, TREE_IN_RECURSIVE)) {
			opt->change(opt, mode1, mode2,
				    sha1, sha2, base->buf, 0, 0);
		}
		strbuf_addch(base, '/');
		diff_tree_sha1(sha1, sha2, base->buf, opt);
	} else {
		opt->change(opt, mode1, mode2, sha1, sha2, base->buf, 0, 0);
	}
	strbuf_setlen(base, old_baselen);
	return 0;
}
示例#5
0
static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2, const char *base, struct diff_options *opt)
{
	unsigned mode1, mode2;
	const char *path1, *path2;
	const unsigned char *sha1, *sha2;
	int cmp, pathlen1, pathlen2;

	sha1 = extract(t1, &path1, &mode1);
	sha2 = extract(t2, &path2, &mode2);

	pathlen1 = strlen(path1);
	pathlen2 = strlen(path2);
	cmp = base_name_compare(path1, pathlen1, mode1, path2, pathlen2, mode2);
	if (cmp < 0) {
		show_entry(opt, "-", t1, base);
		return -1;
	}
	if (cmp > 0) {
		show_entry(opt, "+", t2, base);
		return 1;
	}
	if (!opt->find_copies_harder &&
	    !memcmp(sha1, sha2, 20) && mode1 == mode2)
		return 0;

	/*
	 * If the filemode has changed to/from a directory from/to a regular
	 * file, we need to consider it a remove and an add.
	 */
	if (S_ISDIR(mode1) != S_ISDIR(mode2)) {
		show_entry(opt, "-", t1, base);
		show_entry(opt, "+", t2, base);
		return 0;
	}

	if (opt->recursive && S_ISDIR(mode1)) {
		int retval;
		char *newbase = malloc_base(base, path1, pathlen1);
		if (opt->tree_in_recursive)
			opt->change(opt, mode1, mode2,
				    sha1, sha2, base, path1);
		retval = diff_tree_sha1(sha1, sha2, newbase, opt);
		free(newbase);
		return retval;
	}

	opt->change(opt, mode1, mode2, sha1, sha2, base, path1);
	return 0;
}
示例#6
0
void				ls_l_prepare(char *options, t_arraylist *filedirs)
{
	t_l_info		*neoinfo;
	t_arlst_iter	*iter;
	int				iter_ret;
	t_filedir		*temp_filedir;
	unsigned int	file_count;

	neoinfo = ls_get_info();
	ft_bzero(neoinfo, sizeof(t_l_info));
	file_count = 0;
	iter = arlst_iter(filedirs);
	iter_ret = 1;
	while (iter_ret)
	{
		temp_filedir = iter->pip(iter, &iter_ret);
		if (show_entry(options, temp_filedir->name) && ++file_count)
			extract_l_info(neoinfo, temp_filedir);
	}
	free(iter);
	if ((neoinfo->block_mem_total || file_count) && !ft_strchr(options, 'F'))
		ls_print_total(neoinfo->block_mem_total);
	if (ft_strchr(options, 'F'))
		*(ft_strchr(options, 'F')) = 'l';
}
示例#7
0
/* A whole sub-tree went away or appeared */
static void show_tree(struct diff_options *opt, const char *prefix, struct tree_desc *desc, const char *base)
{
	while (desc->size) {
		if (interesting(desc, base))
			show_entry(opt, prefix, desc, base);
		update_tree_entry(desc);
	}
}
示例#8
0
文件: gen_idt.c 项目: bboozzoo/zephyr
static void validate_priority(void)
{
	int  i;

	/* Validate the priority. */
	for (i = 0; i < genidt_header.num_entries; i++) {
		if (supplied_entry[i].priority == UNSPECIFIED_PRIORITY) {
			if (supplied_entry[i].vector_id == UNSPECIFIED_INT_VECTOR) {
				fprintf(stderr,
						"Either priority or vector ID must be specified.\n");
				show_entry(&supplied_entry[i]);
				clean_exit(-1);
			}
		} else if (supplied_entry[i].priority >= MAX_PRIORITIES) {
			fprintf(stderr, "Priority must not exceed %d.\n",
					MAX_PRIORITIES - 1);
			show_entry(&supplied_entry[i]);
			clean_exit(-1);
		}
	}
}
示例#9
0
文件: ls_loop.c 项目: sploadie/ft-ls
static void	ls_loop_content(char *options, t_filedir *tmp_fldr, char dots)
{
	if (isdots(tmp_fldr->name) && !dots)
		return ;
	if (show_entry(options, tmp_fldr->name) || isdots(tmp_fldr->name))
	{
		ls_loop_return(options, tmp_fldr->path);
		ls_buckle(options, ls_gen_filedirs(options, tmp_fldr));
	}
	else if (ft_strchr(options, 'R'))
		ls_loop(options, ls_gen_filedirs(options, tmp_fldr), 0);
}
示例#10
0
文件: gen_idt.c 项目: bboozzoo/zephyr
static void validate_dpl(void)
{
	int  i;

	for (i = 0; i < genidt_header.num_entries; i++) {
		if (supplied_entry[i].dpl != 0) {
			fprintf(stderr,
					"Invalid DPL bits specified.  Must be zero.\n");
			show_entry(&supplied_entry[i]);
			clean_exit(-1);
		}
	}
}
示例#11
0
/******************************************************************************
 *                                                                            *
 ******************************************************************************/
static void show_namelist(int file)
{
    NML *fl = &file_list[file];
    int i, j;

    for (i = 0; i < fl->count; i++) {
        NML_Section *ns = &fl->section[i];
        fprintf(stderr, "Section %s has %d entries\n", ns->name, ns->count);
        for (j = 0; j < ns->count; j++) {
            show_entry(&ns->entry[j]);
        }
    }
}
示例#12
0
文件: tree-diff.c 项目: Jinyan/git
int diff_tree(struct tree_desc *t1, struct tree_desc *t2, const char *base, struct diff_options *opt)
{
	int baselen = strlen(base);

	for (;;) {
		if (DIFF_OPT_TST(opt, QUICK) &&
		    DIFF_OPT_TST(opt, HAS_CHANGES))
			break;
		if (opt->nr_paths) {
			skip_uninteresting(t1, base, baselen, opt);
			skip_uninteresting(t2, base, baselen, opt);
		}
		if (!t1->size) {
			if (!t2->size)
				break;
			show_entry(opt, "+", t2, base, baselen);
			update_tree_entry(t2);
			continue;
		}
		if (!t2->size) {
			show_entry(opt, "-", t1, base, baselen);
			update_tree_entry(t1);
			continue;
		}
		switch (compare_tree_entry(t1, t2, base, baselen, opt)) {
		case -1:
			update_tree_entry(t1);
			continue;
		case 0:
			update_tree_entry(t1);
			/* Fallthrough */
		case 1:
			update_tree_entry(t2);
			continue;
		}
		die("git diff-tree: internal error");
	}
	return 0;
}
示例#13
0
文件: gen_idt.c 项目: bboozzoo/zephyr
static void validate_irq(void)
{
	int  i;
	int  num_irqs[MAX_IRQS] = {0};

	/* Validate the IRQ number */
	for (i = 0; i < genidt_header.num_entries; i++) {
		if (supplied_entry[i].irq == UNSPECIFIED_IRQ) {
			if (supplied_entry[i].vector_id == UNSPECIFIED_INT_VECTOR) {
				fprintf(stderr,
						"Either IRQ or vector ID must be specified.\n");
				show_entry(&supplied_entry[i]);
				clean_exit(-1);
			}
			continue;
		}

		if (supplied_entry[i].irq >= num_irq_lines) {
			/*
			 * If code to support the PIC is re-introduced, then this
			 * check will need to be updated.
			 */
			fprintf(stderr, "IRQ must be between 0 and %d inclusive.\n",
					num_irq_lines - 1);
			show_entry(&supplied_entry[i]);
			clean_exit(-1);
		}
		num_irqs[supplied_entry[i].irq]++;
	}

	for (i = 0; i < num_irq_lines; i++) {
		if (num_irqs[i] > 1) {
			fprintf(stderr, "Multiple requests (%d) for IRQ %d detected.\n",
				num_irqs[i], i);
			clean_exit(-1);
		}
	}
}
static int extract_feature_visitor_feature_node(GtNodeVisitor *nv,
                                                GtFeatureNode *fn, GtError *err)
{
  GtExtractFeatureVisitor *efv;
  GtFeatureNodeIterator *fni;
  GtFeatureNode *child;
  GtStrArray *target_ids = NULL;
  GtStr *seqid = NULL,
        *description,
        *sequence;
  int had_err = 0;
  gt_error_check(err);
  efv = gt_extract_feature_visitor_cast(nv);
  gt_assert(efv->region_mapping);
  fni = gt_feature_node_iterator_new(fn);
  if (efv->target)
    target_ids = gt_str_array_new();
  if (efv->seqid)
    seqid = gt_str_new();
  description = gt_str_new();
  sequence = gt_str_new();
  while (!had_err && (child = gt_feature_node_iterator_next(fni))) {
    if (seqid)
      gt_str_reset(seqid);
    if (target_ids)
      gt_str_array_reset(target_ids);
    if (gt_extract_feature_sequence(sequence, (GtGenomeNode*) child, efv->type,
                                    efv->join, seqid, target_ids,
                                    efv->region_mapping, err)) {
      had_err = -1;
    }

    if (!had_err && gt_str_length(sequence)) {
      efv->fastaseq_counter++;
      construct_description(description, efv->type, efv->fastaseq_counter,
                            efv->join, efv->translate, seqid, target_ids);
      had_err = show_entry(description, sequence, efv->translate, efv->width,
                           efv->outfp);
      gt_str_reset(description);
      gt_str_reset(sequence);
    }

  }
  gt_str_delete(sequence);
  gt_str_delete(description);
  gt_str_delete(seqid);
  gt_str_array_delete(target_ids);
  gt_feature_node_iterator_delete(fni);
  return had_err;
}
示例#15
0
int diff_tree(struct tree_desc *t1, struct tree_desc *t2, const char *base, struct diff_options *opt)
{
	while (t1->size | t2->size) {
		if (nr_paths && t1->size && !interesting(t1, base)) {
			update_tree_entry(t1);
			continue;
		}
		if (nr_paths && t2->size && !interesting(t2, base)) {
			update_tree_entry(t2);
			continue;
		}
		if (!t1->size) {
			show_entry(opt, "+", t2, base);
			update_tree_entry(t2);
			continue;
		}
		if (!t2->size) {
			show_entry(opt, "-", t1, base);
			update_tree_entry(t1);
			continue;
		}
		switch (compare_tree_entry(t1, t2, base, opt)) {
		case -1:
			update_tree_entry(t1);
			continue;
		case 0:
			update_tree_entry(t1);
			/* Fallthrough */
		case 1:
			update_tree_entry(t2);
			continue;
		}
		die("git-diff-tree: internal error");
	}
	return 0;
}
示例#16
0
/* A whole sub-tree went away or appeared */
static void show_tree(struct diff_options *opt, const char *prefix,
		      struct tree_desc *desc, struct strbuf *base)
{
	int match = 0;
	for (; desc->size; update_tree_entry(desc)) {
		if (match != 2) {
			match = tree_entry_interesting(&desc->entry, base, 0,
						       &opt->pathspec);
			if (match < 0)
				break;
			if (match == 0)
				continue;
		}
		show_entry(opt, prefix, desc, base);
	}
}
示例#17
0
/* A whole sub-tree went away or appeared */
static void show_tree(struct diff_options *opt, const char *prefix,
		      struct tree_desc *desc, struct strbuf *base)
{
	enum interesting match = entry_not_interesting;
	for (; desc->size; update_tree_entry(desc)) {
		if (match != all_entries_interesting) {
			match = tree_entry_interesting(&desc->entry, base, 0,
						       &opt->pathspec);
			if (match == all_entries_not_interesting)
				break;
			if (match == entry_not_interesting)
				continue;
		}
		show_entry(opt, prefix, desc, base);
	}
}
示例#18
0
文件: gen_idt.c 项目: bboozzoo/zephyr
static void read_input_file(void)
{
	ssize_t  bytes_read;
	size_t   bytes_to_read;

	/* Read the header information. */
	bytes_read = read(fds[IFILE], &genidt_header, sizeof(genidt_header));
	if (bytes_read != sizeof(genidt_header)) {
		goto read_error;
	}

	debug("Spurious interrupt handlers found at 0x%x and 0x%x.\n",
		    genidt_header.spurious_addr, genidt_header.spurious_no_error_addr);
	debug("There are %d ISR(s).\n", genidt_header.num_entries);


	if (genidt_header.num_entries > num_vectors) {
		fprintf(stderr,
				"Too many ISRs found. Got %u. Expected no more than %u.\n"
				"Malformed input file?\n",
				genidt_header.num_entries, num_vectors);
		clean_exit(-1);
	}

	bytes_to_read = sizeof(struct genidt_entry_s) * genidt_header.num_entries;
	bytes_read = read(fds[IFILE], supplied_entry, bytes_to_read);
	if (bytes_read != bytes_to_read) {
		goto read_error;
	}

	int i;

	for (i = 0; i < genidt_header.num_entries; i++) {
		show_entry(&supplied_entry[i]);
	}
	return;

read_error:
	fprintf(stderr, "Error occurred while reading input file. Aborting...\n");
	clean_exit(-1);
}
示例#19
0
文件: tree-diff.c 项目: Inkdit/git
/* A whole sub-tree went away or appeared */
static void show_tree(struct diff_options *opt, const char *prefix, struct tree_desc *desc, const char *base, int baselen)
{
	int all_interesting = 0;
	while (desc->size) {
		int show;

		if (all_interesting)
			show = 1;
		else {
			show = tree_entry_interesting(desc, base, baselen,
						      opt);
			if (show == 2)
				all_interesting = 1;
		}
		if (show < 0)
			break;
		if (show)
			show_entry(opt, prefix, desc, base, baselen);
		update_tree_entry(desc);
	}
}
示例#20
0
static void
create_signals (void)
{
   GtkWidget *window = NULL;
   GtkWidget *box1;
   GtkWidget *box2;
   GtkWidget *close_button;
   GtkWidget *box;
   GtkWidget *table;
   GtkWidget *label;
   GtkWidget *separator;
   gfloat *X;
   gfloat *Y;
   GtkDataboxGraph *graph;
   GdkColor color;
   gint i;
   GtkWidget **entries;
   GtkWidget *hbox;

   entries = g_new0 (GtkWidget *, SHOW_NUM_ENTRIES);

   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_widget_set_size_request (window, 500, 500);

   g_signal_connect (G_OBJECT (window), "destroy",
		     G_CALLBACK (gtk_main_quit), NULL);

   gtk_window_set_title (GTK_WINDOW (window), "GtkDatabox: Signals Examples");
   gtk_container_set_border_width (GTK_CONTAINER (window), 0);

   box1 = gtk_vbox_new (FALSE, 0);
   gtk_container_add (GTK_CONTAINER (window), box1);

   label =
      gtk_label_new
      ("The output on the shell and in the text boxes below\nshow you the information that you can get\n by using signals.\n\nSee basics for a usage of this window...");

   gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0);
   separator = gtk_hseparator_new ();
   gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, FALSE, 0);

   hbox = gtk_hbox_new (TRUE, 3);
   gtk_box_pack_start (GTK_BOX (box1), hbox, FALSE, TRUE, 0);

   entries[SHOW_ACTUAL_X] = show_entry (hbox, "Actual X");
   entries[SHOW_ACTUAL_Y] = show_entry (hbox, "Actual Y");
   entries[SHOW_MARKED_X] = show_entry (hbox, "Marked X");
   entries[SHOW_MARKED_Y] = show_entry (hbox, "Marked Y");
   entries[SHOW_DELTA_X] = show_entry (hbox, "Delta X");
   entries[SHOW_DELTA_Y] = show_entry (hbox, "Delta Y");

   /* Create a GtkDatabox widget along with scrollbars and rulers */
   gtk_databox_create_box_with_scrollbars_and_rulers (&box, &table,
						      TRUE, TRUE, TRUE, TRUE);

   gtk_box_pack_start (GTK_BOX (box1), table, TRUE, TRUE, 0);

   entries[SHOW_BOX] = box;

   X = g_new0 (gfloat, POINTS);
   Y = g_new0 (gfloat, POINTS);

   for (i = 0; i < POINTS; i++)
   {
      X[i] = i+100.;
      Y[i] = 100. * sin (i * 2 * G_PI / POINTS);
   }
   color.red = 0;
   color.green = 65535;
   color.blue = 0;

   graph = gtk_databox_points_new (POINTS, X, Y, &color, 1);
   gtk_databox_graph_add (GTK_DATABOX (box), graph);

   Y = g_new0 (gfloat, POINTS);

   for (i = 0; i < POINTS; i++)
   {
      Y[i] = 100. * cos (i * 2 * G_PI / POINTS);
   }
   color.red = 65535;
   color.green = 0;
   color.blue = 0;

   graph = gtk_databox_points_new (POINTS, X, Y, &color, 1);
   gtk_databox_graph_add (GTK_DATABOX (box), graph);

   gtk_databox_auto_rescale (GTK_DATABOX (box), 0.00);

   separator = gtk_hseparator_new ();
   gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);

   box2 = gtk_vbox_new (FALSE, 10);
   gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
   gtk_box_pack_end (GTK_BOX (box1), box2, FALSE, TRUE, 0);
   close_button = gtk_button_new_with_label ("close");
   g_signal_connect_swapped (G_OBJECT (close_button), "clicked",
			     G_CALLBACK (gtk_main_quit), G_OBJECT (box));
   gtk_box_pack_start (GTK_BOX (box2), close_button, TRUE, TRUE, 0);
   GTK_WIDGET_SET_FLAGS (close_button, GTK_CAN_DEFAULT);
   gtk_widget_grab_default (close_button);

   g_signal_connect (G_OBJECT (box), "zoomed",
		     G_CALLBACK (handle_signal_zoomed), NULL);
   g_signal_connect (G_OBJECT (box), "selection-started",
		     G_CALLBACK (handle_signal_selection_started), NULL);
   g_signal_connect (G_OBJECT (box), "selection-finalized",
		     G_CALLBACK (handle_signal_selection_finalized), NULL);
   g_signal_connect (G_OBJECT (box), "selection-canceled",
		     G_CALLBACK (handle_signal_selection_canceled), NULL);
   g_signal_connect_swapped (G_OBJECT (box),
			     "motion_notify_event",
			     G_CALLBACK (show_motion_notify_cb), entries);
   g_signal_connect (G_OBJECT (box), "button_press_event",
		     G_CALLBACK (show_button_press_cb), entries);
   g_signal_connect (G_OBJECT (box), "selection-changed",
		     G_CALLBACK (show_changed_cb), entries);

   gtk_widget_show_all (window);

}
示例#21
0
int last_main(int argc UNUSED_PARAM, char **argv)
{
	struct utmpx ut;
	const char *filename = _PATH_WTMP;
	llist_t *zlist;
	off_t pos;
	time_t start_time;
	time_t boot_time;
	time_t down_time;
	int file;
	smallint going_down;
	smallint boot_down;

	/*opt =*/ getopt32(argv, "Wf:" /* "H" */, &filename);
#ifdef BUT_UTIL_LINUX_LAST_HAS_NO_SUCH_OPT
	if (opt & LAST_OPT_H) {
		/* Print header line */
		if (opt & LAST_OPT_W) {
			printf(HEADER_FORMAT, HEADER_LINE_WIDE);
		} else {
			printf(HEADER_FORMAT, HEADER_LINE);
		}
	}
#endif

	file = xopen(filename, O_RDONLY);
	{
		/* in case the file is empty... */
		struct stat st;
		fstat(file, &st);
		start_time = st.st_ctime;
	}

	time(&down_time);
	going_down = 0;
	boot_down = NORMAL; /* 0 */
	zlist = NULL;
	boot_time = 0;
	/* get file size, rounding down to last full record */
	pos = xlseek(file, 0, SEEK_END) / sizeof(ut) * sizeof(ut);
	for (;;) {
		pos -= (off_t)sizeof(ut);
		if (pos < 0) {
			/* Beyond the beginning of the file boundary =>
			 * the whole file has been read. */
			break;
		}
		xlseek(file, pos, SEEK_SET);
		xread(file, &ut, sizeof(ut));
		/* rewritten by each record, eventially will have
		 * first record's ut_tv.tv_sec: */
		start_time = ut.ut_tv.tv_sec;

		switch (get_ut_type(&ut)) {
		case SHUTDOWN_TIME:
			down_time = ut.ut_tv.tv_sec;
			boot_down = DOWN;
			going_down = 1;
			break;
		case RUN_LVL:
			if (is_runlevel_shutdown(&ut)) {
				down_time = ut.ut_tv.tv_sec;
				going_down = 1;
				boot_down = DOWN;
			}
			break;
		case BOOT_TIME:
			strcpy(ut.ut_line, "system boot");
			show_entry(&ut, REBOOT, down_time);
			boot_down = CRASH;
			going_down = 1;
			break;
		case DEAD_PROCESS:
			if (!ut.ut_line[0]) {
				break;
			}
			/* add_entry */
			llist_add_to(&zlist, memcpy(xmalloc(sizeof(ut)), &ut, sizeof(ut)));
			break;
		case USER_PROCESS: {
			int show;

			if (!ut.ut_line[0]) {
				break;
			}
			/* find_entry */
			show = 1;
			{
				llist_t *el, *next;
				for (el = zlist; el; el = next) {
					struct utmpx *up = (struct utmpx *)el->data;
					next = el->link;
					if (strncmp(up->ut_line, ut.ut_line, __UT_LINESIZE) == 0) {
						if (show) {
							show_entry(&ut, NORMAL, up->ut_tv.tv_sec);
							show = 0;
						}
						llist_unlink(&zlist, el);
						free(el->data);
						free(el);
					}
				}
			}

			if (show) {
				int state = boot_down;

				if (boot_time == 0) {
					state = LOGGED;
					/* Check if the process is alive */
					if ((ut.ut_pid > 0)
					 && (kill(ut.ut_pid, 0) != 0)
					 && (errno == ESRCH)) {
						state = GONE;
					}
				}
				show_entry(&ut, state, boot_time);
			}
			/* add_entry */
			llist_add_to(&zlist, memcpy(xmalloc(sizeof(ut)), &ut, sizeof(ut)));
			break;
		}
		}

		if (going_down) {
			boot_time = ut.ut_tv.tv_sec;
			llist_free(zlist, free);
			zlist = NULL;
			going_down = 0;
		}
	}

	if (ENABLE_FEATURE_CLEAN_UP) {
		llist_free(zlist, free);
	}

	printf("\nwtmp begins %s", ctime(&start_time));

	if (ENABLE_FEATURE_CLEAN_UP)
		close(file);
	fflush_stdout_and_exit(EXIT_SUCCESS);
}
示例#22
0
static void find_tags(const gchar *name, gboolean declaration, gboolean case_sensitive, MatchType match_type)
{
	tagFile *tf;
	GeanyProject *prj;
	gchar *tag_filename = NULL;
	tagEntry entry;
	tagFileInfo info;

	prj = geany_data->app->project;
	if (!prj)
		return;

	msgwin_clear_tab(MSG_MESSAGE);
	msgwin_set_messages_dir(prj->base_path);

	tag_filename = get_tags_filename();
	tf = tagsOpen(tag_filename, &info);

	if (tf)
	{
		if (find_first(tf, &entry, name, match_type))
		{
			GPatternSpec *name_pat;
			gchar *name_case;
			gchar *path = NULL; 
			gint num = 0;

			if (case_sensitive)
				name_case = g_strdup(name);
			else
				name_case = g_utf8_strdown(name, -1);

			SETPTR(name_case, g_strconcat("*", name_case, "*", NULL));
			name_pat = g_pattern_spec_new(name_case);

			if (!filter_tag(&entry, name_pat, declaration, case_sensitive))
			{
				path = g_build_filename(prj->base_path, entry.file, NULL);
				show_entry(&entry);
				num++;
			}
			
			while (find_next(tf, &entry, match_type))
			{
				if (!filter_tag(&entry, name_pat, declaration, case_sensitive))
				{
					if (!path)
						path = g_build_filename(prj->base_path, entry.file, NULL);
					show_entry(&entry);
					num++;
				}
			}
			
			if (num == 1)
			{
				GeanyDocument *doc = document_open_file(path, FALSE, NULL, NULL);
				if (doc != NULL)
				{
					navqueue_goto_line(document_get_current(), doc, entry.address.lineNumber);
					gtk_widget_grab_focus(GTK_WIDGET(doc->editor->sci));
				}
			}

			g_pattern_spec_free(name_pat);
			g_free(name_case);
			g_free(path);
		}

		tagsClose(tf);
	}

	msgwin_switch_tab(MSG_MESSAGE, TRUE);

	g_free(tag_filename);
}
示例#23
0
文件: main.c 项目: hharte/vttest
int
menu2(MENU *table, int top)
{
  int i, tablesize, choice;
  char c;
  char storage[BUFSIZ];
  int pagesize = max_lines - 7 - TITLE_LINE;
  int pagetop = 1;
  int redraw = FALSE;

  tablesize = 0;
  for (i = 0; !end_of_menu(table, i); i++) {
    tablesize++;
  }
  tablesize--;

  for (;;) {
    vt_move(top, 1);
    vt_clear(0);

    println("");
    show_entry(table, 0);
    for (i = 0; i < pagesize; i++) {
      int j = pagetop + i;
      if (end_of_menu(table, j))
        break;
      show_entry(table, pagetop + i);
    }

    printf("\n          Enter choice number (0 - %d): ", tablesize);
    for (;;) {
      char *s = storage;
      inputline(s);
      choice = 0;
      redraw = FALSE;
      while ((c = *s++) != '\0') {
        if (c == '*') {
          choice = -1;
          break;
        } else if (c == '?') {
          redraw = TRUE;
          break;
        } else if (tablesize > pagesize && c == 'n') {
          pagetop = next_menu(table, pagetop, pagesize);
          redraw = TRUE;
          break;
        } else if (tablesize > pagesize && c == 'p') {
          pagetop = prev_menu(pagetop, pagesize);
          redraw = TRUE;
          break;
        } else if (c >= '0' && c <= '9') {
          choice = 10 * choice + c - '0';
        } else {
          choice = tablesize + 1;
          break;
        }
      }

      if (redraw)
        break;

      if (choice < 0) {
        for (choice = 0; choice <= tablesize; choice++) {
          vt_clear(2);
          if (table[choice].dispatch != 0) {
            const char *save = push_menu(choice);
            const char *name = table[choice].description;
            if (LOG_ENABLED)
              fprintf(log_fp, "Menu %s: %s\n", current_menu, name);
            if ((*table[choice].dispatch) (name) == MENU_HOLD)
              holdit();
            pop_menu(save);
          }
        }
        return 1;
      } else if (choice <= tablesize) {
        vt_clear(2);
        if (table[choice].dispatch != 0) {
          const char *save = push_menu(choice);
          const char *name = table[choice].description;
          if (LOG_ENABLED)
            fprintf(log_fp, "Menu %s: %s\n", current_menu, name);
          if ((*table[choice].dispatch) (name) != MENU_NOHOLD)
            holdit();
          pop_menu(save);
        }
        return (table[choice].dispatch != 0);
      }
      printf("          Bad choice, try again: ");
    }
  }
}