Exemplo n.º 1
0
static void stest_usage(const char *argv0, const char **test_usage,
		int exitstatus)
{
	fprintf(stderr, "%s: a Redfish system test\n", argv0);
	{
		static const char *usage_lines[] = {
"See http://www.club.cc.cmu.edu/~cmccabe/redfish.html for the most up-to-date",
"information about Redfish.",
"",
"System test options:",
"-d <directory>",
"    Set the directory to use for test metadata.  Defaults to a temporary ",
"    directory",
"-f",
"    Run in the foreground (do not daemonize)",
"-h",
"    Show this help message",
NULL
		};
		print_lines(stderr, usage_lines);
	}
	fprintf(stderr, "\nTest information:\n");
	print_lines(stderr, test_usage);
	exit(exitstatus);
}
Exemplo n.º 2
0
	~Statistics() {
	    long total = 0;
	    for (int i = 0; i < max_small;i ++) {
		if (alloc_count[i] > 0) {
		    printf("size %d left is %d for size %d\n",
			i * sizeof(size_t),
			alloc_count[i],
			i * sizeof(size_t)*alloc_count[i]);
		    print_lines(headers[i]);
		    total += i * sizeof(size_t)*alloc_count[i];
		    }
		}
	    size_rec *next = big;
	    while (next) {
		if (next->count > 0) {
		    printf("size %d left is %d for size %d\n",
                        next->size * sizeof(size_t),
                        next->count,
                        next->size * sizeof(size_t)*next->count);
		    print_lines(next->headers);
                    total += next->size * sizeof(size_t)*next->count;
		    }
		next = next->next;
		}
	    printf("total allocation remaining %d\n",total);
	    }
Exemplo n.º 3
0
gboolean insert_in_tree(GNode *directory, File *file)
{
	GNode *new_file, *file_ptr, *dir_ptr;
	int position;

	if (file->name[0] == '.' && FILE(directory)->show_dotfiles == FALSE) {
		insert_sorted_in_dotfiles(directory, file);

		return FALSE;
	}

	new_file = insert_sorted_in_tree(directory, file);
	for (dir_ptr = directory; !G_NODE_IS_ROOT(dir_ptr); dir_ptr = dir_ptr->parent) {
		if (FILE(dir_ptr)->open == FALSE)
			return FALSE;
	}
	if (FILE(dir_ptr)->open == FALSE)
		return FALSE;

	file_ptr = get_previous_file(new_file);
	position = g_list_position(lines, FILE(file_ptr)->line);
	lines = g_list_insert(lines, new_file, position + 1);
	file->line = g_list_nth(lines, position + 1);

	if (g_list_length(first_line) - g_list_length(last_line) + 1) {
		if (g_list_previous(first_line) == file->line)
			first_line = file->line;
		else if (g_list_next(last_line) == file->line)
			last_line = file->line;
	}
	if (g_list_position(lines, first_line) <= position + 1 &&
			position + 1 <= g_list_position(lines, last_line)) {
		if (position + 1 < g_list_position(lines, selected_line)) {
			if (g_list_length(first_line) <= getmaxy(tree_window))
				print_lines(first_line, last_line, FALSE);
			else {
				first_line = g_list_next(first_line);
				print_lines(first_line, file->line, FALSE);
			}
		} else {
			if (g_list_length(first_line) > getmaxy(tree_window))
				last_line = g_list_previous(last_line);

			if (g_node_last_sibling(new_file) == new_file)
				print_lines(g_list_previous(file->line), last_line, FALSE);
			else
				print_lines(file->line, last_line, FALSE);
		}

		return TRUE;
	}

	return FALSE;
}
Exemplo n.º 4
0
/* Print out all stored ID3v2 fields with their 4-character IDs. */
void print_raw_v2(mpg123_id3v2 *v2)
{
	size_t i;
	for(i=0; i<v2->texts; ++i)
	{
		char id[5];
		char lang[4];
		memcpy(id, v2->text[i].id, 4);
		id[4] = 0;
		memcpy(lang, v2->text[i].lang, 3);
		lang[3] = 0;
		if(v2->text[i].description.fill)
		printf("%s language(%s) description(%s)\n", id, lang, v2->text[i].description.p);
		else printf("%s language(%s)\n", id, lang);

		print_lines(" ", &v2->text[i].text);
	}
	for(i=0; i<v2->extras; ++i)
	{
		char id[5];
		memcpy(id, v2->extra[i].id, 4);
		id[4] = 0;
		printf( "%s description(%s)\n",
		        id,
		        v2->extra[i].description.fill ? v2->extra[i].description.p : "" );
		print_lines(" ", &v2->extra[i].text);
	}
	for(i=0; i<v2->comments; ++i)
	{
		char id[5];
		char lang[4];
		memcpy(id, v2->comment_list[i].id, 4);
		id[4] = 0;
		memcpy(lang, v2->comment_list[i].lang, 3);
		lang[3] = 0;
		printf( "%s description(%s) language(%s):\n",
		        id,
		        v2->comment_list[i].description.fill ? v2->comment_list[i].description.p : "",
		        lang );
		print_lines(" ", &v2->comment_list[i].text);
	}
	for(i=0; i<v2->pictures; ++i)
	{
		mpg123_picture* pic;

		pic = &v2->picture[i];
		fprintf(stderr, "APIC type(%i, %s) mime(%s) size(%"SIZE_P")\n",
			pic->type, pic_type(pic->type), pic->mime_type.p, (size_p)pic->size);
		print_lines(" ", &pic->description);
	}
}
Exemplo n.º 5
0
static void fortran_prescanner_process(prescanner_t* prescanner)
{
	file_lines = NULL;
	last_line = file_lines;

	// Load all the file into memory
	read_lines(prescanner);

	// Cut lines to be of width 'prescanner.width'
	cut_lines(prescanner);

	// We used to remove comments here but it is better to convert them
	convert_whole_line_comments();

	// Join continuated lines
	join_continuated_lines(prescanner);

#if 0
	// Lines that were not appended any continuation line have not been trimmed
	// their inline comments
	remove_inlined_comments();
#endif

	convert_lines(prescanner);

	if (!prescanner->append)
	{
		continuate_lines(prescanner);
	}

	print_lines(prescanner);

    close_files(prescanner);
}
Exemplo n.º 6
0
int process_copy_output(process_info_t* p, FILE* stream) {
  char buf[1024];
  int fd, r;
  FILE* f;

  fd = _open_osfhandle((intptr_t)p->stdio_out, _O_RDONLY | _O_TEXT);
  if (fd == -1)
    return -1;
  f = _fdopen(fd, "rt");
  if (f == NULL) {
    _close(fd);
    return -1;
  }

  r = fseek(f, 0, SEEK_SET);
  if (r < 0)
    return -1;

  while (fgets(buf, sizeof(buf), f) != NULL)
    print_lines(buf, strlen(buf), stream);
  
  if (ferror(f))
    return -1;

  fclose(f);
  return 0;
}
Exemplo n.º 7
0
int main(int argc, const char * argv[]) {
	FILE *file;
	if (argc < 2 || !(file = fopen(argv[1], "r"))) {
		puts("No argument provided / File not found.");
		return 1;
	}

	file = fopen(argv[1], "r");
	char line[LINE_BUFFER];
	fgets(line, LINE_BUFFER, file);
	int number_of_lines = atoi(line);

	char lines_to_print[number_of_lines][LINE_BUFFER];
	initialize(lines_to_print, number_of_lines, file);
	sort_lines(lines_to_print, number_of_lines);

	int end = number_of_lines - 1;
	int shortest_long_line_length = strlen(lines_to_print[end]);
	int line_length;
	while (fgets(line, LINE_BUFFER, file)) {
		if ((line_length = strlen(line)) > shortest_long_line_length) {
			strcpy(lines_to_print[end], line);
			sort_lines(lines_to_print, number_of_lines);
			shortest_long_line_length = strlen(lines_to_print[end]);
		}
	}
	
	print_lines(lines_to_print, number_of_lines);
}
Exemplo n.º 8
0
int					print_args(t_param *debut)
{
	int			col;
	t_param		*buf;
	int			nb_col;
	int			nb_row;

	buf = debut;
	col = 0;
	nb_col = get_nb_col(debut);
	nb_row = get_nb_row(debut, nb_col);
	if (nb_row >= get_height())
		return (-2);
	if (print_lines(nb_row) == -1)
		return (-1);
	while (col < nb_col)
	{
		if ((buf = print_col(buf, nb_row, col, get_nb_tab(debut))) == NULL)
			return (-2);
		if (buf->nb == 0)
			break ;
		if (move_cursor_up(nb_row, get_nb_tab(debut)) < 0)
			return (-1);
		col++;
	}
	return (0);
}
Exemplo n.º 9
0
/**
 * USE: Provide sample points and how many to setup_hough() transformation and plot those points
 * using plot_point() with each index of points you want to convert. The use print_classifier()
 * or get_lines() to see the lines extracted.
 */
int main(int argc, char **argv) {

	// Get points from image
	SIZE_TYPE size;
	POINT_TYPE *points = NULL;
	sizep_t count = get_points("sample_small.bmp", &points, &size);

	/*
	 *  points 		: Array of points
	 *  num_points	: Number of points in the array
	 *  threshold	: Threshold to consider line intersection
	 *  tolerance_t	: Tolerance (in grades) to consider two lines are the same
	 *  tolerance_r	: Distance (in pixels) to consider two lines are the same
	 *  precision	: Precision for degrees (10 = decimals, 100 = cents...)
	 *  size		: Size of the image
	 *  max_lines	: Lines to look for (value -1 falls back to 500)
	 */
	clock_t cp = clock();
	setup_hough(points, count, 12, 15.0, 5.0, 1, size, 10000);

	// Plot every point and measure clock ticks
	int n;
	for (n=0; n<_num_points; n++) {
		plot_point(n);
	}
	printf("_plot_point() ticks: %.4f\n", ((double)(clock()-cp))/1000000l);
	print_accumulator("accumulator.bmp");
	print_classifier();//*/

	// Get lines from classifier
	LINE_TYPE *lines;
	sizep_t clines = get_lines(&lines);

	// Print lines
	print_lines("output.bmp", "sample.bmp", lines, clines, 10);
	print_lines("output_small.bmp", "sample_small.bmp", lines, clines, 1);

	// Free memory
	finish_hough();
	free(lines);
	free(points);
	printf("All clear!");

	return EXIT_SUCCESS;
}
Exemplo n.º 10
0
int main()
{
	struct indicator *indicators;
	struct strategy *strategies;
	struct coll_ctrl_blk *coll_ctrl_blks;

	indicators = load_indicators("indicators.xml");
	print_indicators(indicators);
	//destroy_indicators(indicators);
	strategies = load_strategies("strategies.xml");
	print_strategies(strategies);
	//destroy_strategies(strategies);
	//printf("name offset in Indicator is: %u\n", offsetof(struct indicator, name));
	//printf("size of int: %u\n", sizeof(int));
	struct data data;
	init_data(&data);
	put_value(&data, "hello", "wold");
	struct pair *pair_ptr = get_pair(&data, "hello");
	printf("%s, %s\n", pair_ptr->name, pair_ptr->value);
	coll_ctrl_blks = generate_coll_ctrl_blks(indicators, strategies);
	print_coll_ctrl_blks(coll_ctrl_blks);
	struct coll_ctrl_blk *coll_ctrl_blk_ptr = find_coll_ctrl_blk(coll_ctrl_blks, 1);
	printf("Indicator NAME: %s\n", coll_ctrl_blk_ptr->indicator_ptr->name);
	generate_coll_commands(coll_ctrl_blk_ptr);
	
	destroy_indicators(indicators);
	destroy_strategies(strategies);

	ssh_init();
	struct ssh_client client;
	struct line *lines;
	init_client(&client);
	login(&client, "127.0.0.1", 22, "tshi", "123456");
	lines = exec_command(&client, "date");
	print_lines(lines);
	destroy_lines(lines);
	lines = exec_command(&client, "top -b -n 1");
	print_lines(lines);
	destroy_lines(lines);
	close_client(&client);
	ssh_exit();
	
	return (0);
}
Exemplo n.º 11
0
Arquivo: ui.c Projeto: Harvie/Programs
void open_directory(GNode *directory)
{
	if (FILE(directory)->read == FALSE && read_directory(directory) == FALSE)
		return;

	FILE(directory)->open = TRUE;
	add_directory_content(directory);
	update_last_line();
	print_lines(g_list_next(FILE(directory)->line), last_line, TRUE);
}
Exemplo n.º 12
0
bool esp_run_command(serial_handle_t handle, std::string const &command, bool printresult)
{
	std::vector<std::string> lines;
	if (esp_run_command(handle, command, &lines, 3)) {
		if (printresult) {
			print_lines(&lines);
		}
		return true;
	}
	return false;
}
Exemplo n.º 13
0
void shn_error(shn_config config, char *msg, ...)
{
  va_list args;
  char msgbuf[BUF_SIZE];

  va_start(args,msg);

  shn_vsnprintf(msgbuf,BUF_SIZE,msg,args);

  switch (config.error_output_method) {
    case ERROR_OUTPUT_STDERR:
      print_lines(PACKAGE ": ",msgbuf);
      break;
    default:
      if (0 != config.verbose)
        print_lines(PACKAGE " [error]: ",msgbuf);
  }

  va_end(args);
}
Exemplo n.º 14
0
void print_tree(GtkWidget *widget, rbtree_node node) {
  if (node != NULL) {
    char *s = (char*) malloc(3 * sizeof(char));
    sprintf(s, "%d", node->key);

    print_lines(widget, node->left != NULL, node->right != NULL, node->x, node->y, node->r);

    print_tree(widget, node->left);
    print_circle(widget, s, node_color(node), node->x, node->y, 15, 16);
    print_tree(widget, node->right);
  }
}
Exemplo n.º 15
0
Arquivo: ui.c Projeto: Harvie/Programs
void scroll_tree(int n_lines)
{
	int min_n_lines, max_n_lines;

	if ((min_n_lines = -g_list_position(lines, first_line)) > n_lines)
		n_lines = min_n_lines;
	else if ((max_n_lines = g_list_length(last_line) - 1) < n_lines)
		n_lines = max_n_lines;

	wscrl(tree_window, n_lines);
	if (n_lines < 0) {
		first_line = g_list_nth(lines, g_list_position(lines, first_line) + n_lines);
		update_last_line();
		print_lines(first_line, g_list_nth(first_line, -n_lines), FALSE);
	} else if (n_lines > 0) {
		first_line = g_list_nth(first_line, n_lines);
		update_last_line();
		print_lines(g_list_nth(lines, g_list_position(lines, last_line) - n_lines),
				last_line, TRUE);
	}
}
Exemplo n.º 16
0
void st_debug_internal(int level,char *msg,va_list args)
{
  char debugprefix[16];

  if (level > st_priv.debug_level)
    return;

  st_vsnprintf(msgbuf,BUF_SIZE,msg,args);

  st_snprintf(debugprefix,16,"debug%d: ",level);

  print_lines(debugprefix,msgbuf);
}
Exemplo n.º 17
0
void print_edit(char** file_a, char** file_b, int idx_a, int idx_b, int nb_diff_a, int nb_diff_b, int edit_type) {

    char edit_code[] = {'a', 'd', 'c'};

    print_range(idx_a, nb_diff_a);
    putchar(edit_code[edit_type]);
    print_range(idx_b, nb_diff_b);

    putchar('\n');

    if (edit_type == ADDITION)
        print_lines(file_b, idx_b, nb_diff_b, '>');
    else if (edit_type == DELETION)
        print_lines(file_a, idx_a, nb_diff_a, '<');
    else if (edit_type == MODIFICATION)
    {
        print_lines(file_a, idx_a, nb_diff_a, '<');
        puts("---");
        print_lines(file_b, idx_b, nb_diff_b, '>');
    }

}
Exemplo n.º 18
0
void shn_debug(shn_config config, char *msg, ...)
{
  va_list args;
  char msgbuf[BUF_SIZE];

  va_start(args,msg);

  shn_vsnprintf(msgbuf,BUF_SIZE,msg,args);

  if (0 != config.verbose)
    print_lines(PACKAGE " [debug]: ",msgbuf);

  va_end(args);
}
Exemplo n.º 19
0
void st_error(char *msg, ...)
{
  va_list args;

  va_start(args,msg);

  st_vsnprintf(msgbuf,BUF_SIZE,msg,args);

  print_lines("error: ",msgbuf);

  va_end(args);

  exit(ST_EXIT_ERROR);
}
Exemplo n.º 20
0
/* Print out the named ID3v2  fields. */
void print_v2(mpg123_id3v2 *v2)
{
	print_lines("Title: ",   v2->title);
	print_lines("Artist: ",  v2->artist);
	print_lines("Album: ",   v2->album);
	print_lines("Year: ",    v2->year);
	print_lines("Comment: ", v2->comment);
	print_lines("Genre: ",   v2->genre);
}
Exemplo n.º 21
0
void st_warning(char *msg, ...)
{
  va_list args;

  if (st_priv.suppress_warnings || st_priv.suppress_stderr)
    return;

  va_start(args,msg);

  st_vsnprintf(msgbuf,BUF_SIZE,msg,args);

  print_lines("warning: ",msgbuf);

  va_end(args);
}
Exemplo n.º 22
0
Arquivo: ui.c Projeto: Harvie/Programs
void close_directory(GNode *directory)
{
	GNode *directory_sibling;
	GList *line_ptr;

	directory_sibling = get_next_file_not_deepper(directory);

	for (line_ptr = g_list_next(FILE(directory)->line); line_ptr != NULL &&
			NODE(line_ptr) != directory_sibling; line_ptr = g_list_next(FILE(directory)->line))
		lines = g_list_delete_link(lines, line_ptr);

	FILE(directory)->open = FALSE;
	update_last_line();
	print_lines(g_list_next(FILE(directory)->line), last_line, TRUE);
}
Exemplo n.º 23
0
void	player(t_line *lines)
{
	int nb;

	nb = al_count(lines);
	if (nb == 0)
		ft_putstr("You win the game. But we know you know the trick..\n");
	else
	{
		print_lines(&lines);
		ft_putstr("Player's turn : ");
		remove_al(&lines, ask_nb(lines));
		playia(lines);
	}
}
Exemplo n.º 24
0
int main(int argc, char *argv[]) {

int argument = 10;
	
	if (argc == 2)
		argument = abs(atoi(argv[1]));	

	if (argument == 0)
		argument = 10;

	char currentline[500];
	init_lineholder(argument);
	while (getline1(currentline) > 0) {
		insert_line(currentline);
	}
	print_lines();
}
Exemplo n.º 25
0
void st_help(char *msg, ...)
{
  va_list args;

  va_start(args,msg);

  st_vsnprintf(msgbuf,BUF_SIZE,msg,args);

  print_lines("error: ",msgbuf);

  va_end(args);

  print_prefix();
  fprintf(stderr,"\n");
  print_prefix();
  fprintf(stderr,"type '%s -h' for help\n",st_priv.fullprogname);

  exit(ST_EXIT_ERROR);
}
Exemplo n.º 26
0
int process_copy_output(process_info_t* p, FILE* stream) {
  DWORD read;
  char buf[1024];

  if (SetFilePointer(p->stdio_out,
                     0,
                     0,
                     FILE_BEGIN) == INVALID_SET_FILE_POINTER) {
    return -1;
  }

  while (ReadFile(p->stdio_out, &buf, sizeof(buf), &read, NULL) && read > 0)
    print_lines(buf, read, stream);

  if (GetLastError() != ERROR_HANDLE_EOF)
    return -1;

  return 0;
}
Exemplo n.º 27
0
static void usage(int exitstatus)
{
	static const char *usage_lines[] = {
"fishosd: the Redfish object storage daemon",
"See http://www.club.cc.cmu.edu/~cmccabe/redfish.html for the most up-to-date",
"information about Redfish.",
"",
"fishosd usage:",
"-c <osd-configuration-file>",
"    Set the osd configuration file.",
"-k <osd ID>",
"    The ID number of this OSD.  This is an index into the array of ",
"    OSDs in the configuration file.",
"-f",
"    Run in the foreground (do not daemonize)",
"-h",
"    Show this help message",
NULL
	};
	print_lines(stderr, usage_lines);
	exit(exitstatus);
}
Exemplo n.º 28
0
static bool esp_get_mac_address_(serial_handle_t handle, std::string const &cmd, std::string const &key, mac_address_t *out)
{
	*out = mac_address_t();
	std::vector<std::string> lines;
	if (esp_run_command(handle, cmd, &lines)) {
		print_lines(&lines);
		std::string t;
		if (lookup(&lines, key, &t)) {
			t = trim_quot(t);
			int a, b, c, d, e, f;
			if (sscanf(t.c_str(), "%02x:%02x:%02x:%02x:%02x:%02x", &a, &b, &c, &d, &e, &f) == 6) {
				out->a = a;
				out->b = b;
				out->c = c;
				out->d = d;
				out->e = e;
				out->f = f;
			}
			return true;
		}
	}
	return false;
}
Exemplo n.º 29
0
int print_header(FILE *fp, char *hname)
{
  int c;
  struct file_info *fi;
  FILE *header_file;

  if (hname)
    {
      if ((fi = open_file(hname, "r")) == NULL)
	{
	  fprintf(stderr, "umat: can't read PS header file %s\n", hname);
	  return 1;
	}
      header_file = fi2fp(fi);
      while ((c = fgetc(header_file)) != EOF)
	fputc(c, fp);
      close_file(fi);
    }
  else
    print_lines(fp, psheader);

  return 0;
}
Exemplo n.º 30
0
gboolean remove_from_tree(GNode *file, gboolean unmount)
{
	int position = g_list_position(lines, FILE(file)->line);
	gboolean refresh_needed = FALSE;
	GList *line_ptr, *line_ptr2;
	GNode *dir_ptr;

	if (G_NODE_IS_ROOT(file)) {
		endwin();
		clean_up();
		printf("The tree root was removed\n");
		exit(EXIT_SUCCESS);
	}
	if (g_node_is_ancestor(file, NODE(selected_line)))
		select_file(file);
	if (FILE(file)->type == directory_type) {
		close_directory(file);
		destroy_directory_content_real(file, FALSE);
		if (unmount)
			return TRUE;
	} else if (FILE(file)->type == file_type) {
		for (dir_ptr = file->parent; !G_NODE_IS_ROOT(dir_ptr);
				dir_ptr = dir_ptr->parent) {
			if (FILE(dir_ptr)->open == FALSE) {
				g_node_unlink(file);
				return FALSE;
			}
		}
		if (FILE(dir_ptr)->open == FALSE) {
			g_node_unlink(file);
			return FALSE;
		}
	}
	g_node_unlink(file);

	if (g_list_position(lines, first_line) <= position &&
			position <= g_list_position(lines, last_line)) {
		if (first_line == FILE(file)->line && selected_line == FILE(file)->line) {
			selected_line = first_line = g_list_previous(first_line);
			lines = g_list_delete_link(lines, FILE(file)->line);
			print_lines(first_line, first_line, FALSE);
		} else if (position < g_list_position(lines, selected_line)) {
			if (first_line == FILE(file)->line)
				first_line = g_list_next(first_line);
			line_ptr = g_list_previous(FILE(file)->line);
			lines = g_list_delete_link(lines, FILE(file)->line);
			if ((line_ptr2 = g_list_previous(first_line)) != NULL) {
				first_line = line_ptr2;
				print_lines(first_line, line_ptr, FALSE);
			} else if ((line_ptr2 = g_list_next(last_line)) != NULL) {
				last_line = line_ptr2;
				print_lines(line_ptr, last_line, FALSE);
			} else
				print_lines(line_ptr, last_line, TRUE);
		} else {
			if (FILE(file)->line == selected_line)
				selected_line = g_list_previous(selected_line);
			if (last_line == FILE(file)->line)
				last_line = g_list_previous(last_line);
			line_ptr = g_list_previous(FILE(file)->line);
			lines = g_list_delete_link(lines, FILE(file)->line);
			if ((line_ptr2 = g_list_next(last_line)) != NULL) {
				last_line = line_ptr2;
				print_lines(line_ptr, last_line, FALSE);
			} else
				print_lines(line_ptr, last_line, TRUE);
		}
		refresh_needed = TRUE;
	} else {
		if (last_line == g_list_previous(FILE(file)->line)) {
			lines = g_list_delete_link(lines, FILE(file)->line);
			print_lines(last_line, last_line, FALSE);
			refresh_needed = TRUE;
		} else
			lines = g_list_delete_link(lines, FILE(file)->line);
	}
	free_node_data(file, NULL);
	g_node_destroy(file);

	return refresh_needed;
}