当前位置: 首页>>代码示例>>C++>>正文


C++ print_file函数代码示例

本文整理汇总了C++中print_file函数的典型用法代码示例。如果您正苦于以下问题:C++ print_file函数的具体用法?C++ print_file怎么用?C++ print_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了print_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

bool
atf_check::run_status_check(const atf::check::check_result &r)
    const
{
    int status = r.status();
    bool retval = true;

    if (m_status_check == sc_equal) {
        if (m_status_arg != status) {
            std::cerr << "Fail: incorrect exit status: "
                      << status << ", expected: "
                      << m_status_arg << std::endl;
            retval = false;
        }
    } else if (m_status_check == sc_not_equal) {
        if (m_status_arg == status) {
            std::cerr << "Fail: incorrect exit status: "
                      << status << ", expected: "
                      << "anything other" << std::endl;
            retval = false;
        }
    }

    if (retval == false) {
        std::cerr << "stdout:" << std::endl;
        print_file(r.stdout_path());
        std::cerr << std::endl;

        std::cerr << "stderr:" << std::endl;
        print_file(r.stderr_path());
        std::cerr << std::endl;
    }

    return retval;
}
开发者ID:capricalabs,项目名称:c,代码行数:35,代码来源:atf-check.cpp

示例2: unit_test_jit_fragment_tree

void
unit_test_jit_fragment_tree()
{
    uint i;
    bb_node_t *node_list[FRAGMENT_TREE_TEST_NODE_COUNT]; /* N.B.: may contain NULLs */

    print_file(STDERR, "test DGC fragment tree: ");

    dynamo_options.opt_jit = true;

    fragment_tree = fragment_tree_create();
    set_random_seed((uint) query_time_millis());

    for (i = 0; i < 3; i++) {
        print_file(STDERR, "pass %d... ", i+1);

        unit_test_insert_random_nodes(node_list, FRAGMENT_TREE_TEST_NODE_COUNT);
        unit_test_remove_random_spans(node_list, FRAGMENT_TREE_TEST_NODE_COUNT);
        fragment_tree_clear(fragment_tree);
        unit_test_churn_narrow_span(node_list, FRAGMENT_TREE_TEST_NODE_COUNT);
        fragment_tree_clear(fragment_tree);
    }

    fragment_tree_destroy(fragment_tree);

    print_file(STDERR, "\n");
}
开发者ID:AVGirl,项目名称:dynamorio,代码行数:27,代码来源:jit_opt.c

示例3: unit_test_string

void
unit_test_string(void)
{
    static const char test_path[] = "/path/to/file";
    const char *ret;
    char buf[MAXIMUM_PATH];
    unsigned long num;

    print_file(STDERR, "testing string\n");

    /* strchr */
    ret = strchr(identity(test_path), '/');
    EXPECT(ret == test_path, true);
    ret = strchr(identity(test_path), '\0');
    EXPECT(ret != NULL, true);
    EXPECT(*ret, '\0');

    /* strrchr */
    ret = strrchr(identity(test_path), '/');
    EXPECT(strcmp(ret, "/file"), 0);
    ret = strrchr(identity(test_path), '\0');
    EXPECT(ret != NULL, true);
    EXPECT(*ret, '\0');

    /* strncpy, strncat */
    strncpy(buf, test_path, sizeof(buf));
    EXPECT(is_region_memset_to_char((byte *) buf + strlen(test_path),
                                    sizeof(buf) - strlen(test_path), '\0'),
           true);
    strncat(buf, "/foo_wont_copy", 4);
    EXPECT(strcmp(buf, "/path/to/file/foo"), 0);

    /* strtoul */
    num = strtoul(identity("-10"), NULL, 0);
    EXPECT((long)num, -10);  /* negative */
    num = strtoul(identity("0777"), NULL, 0);
    EXPECT(num, 0777);  /* octal */
    num = strtoul(identity("0xdeadBEEF"), NULL, 0);
    EXPECT(num, 0xdeadbeef);  /* hex */
    num = strtoul(identity("deadBEEF next"), (char **) &ret, 16);
    EXPECT(num, 0xdeadbeef);  /* non-0x prefixed hex */
    EXPECT(strcmp(ret, " next"), 0);  /* end */
    num = strtoul(identity("1001a"), NULL, 2);
    EXPECT(num, 9);  /* binary */
    num = strtoul(identity("1aZ"), NULL, 36);
    EXPECT(num, 1 * 36 * 36 + 10 * 36 + 35);  /* weird base */
    num = strtoul(identity("1aZ"), (char **) &ret, 37);
    EXPECT(num, ULONG_MAX);  /* invalid base */
    EXPECT(ret == NULL, true);

    /* memmove */
    strncpy(buf, test_path, sizeof(buf));
    memmove(buf + 4, buf, strlen(buf) + 1);
    strncpy(buf, "/foo", 4);
    EXPECT(strcmp(buf, "/foo/path/to/file"), 0);

    print_file(STDERR, "done testing string\n");
}
开发者ID:stoyannk,项目名称:dynamorio,代码行数:58,代码来源:string.c

示例4: cgiMain

int
cgiMain()
{ 
	cgiHeaderContentType("text/html");
	
	int serverside = 0;
	cgiFormInteger("serverside", &serverside, 0);
	
	char function_call[50];
	int callback = 0;
	if (cgiFormString("function_call", &function_call[0], 50) == cgiFormSuccess)
		callback = 1;
	
	if(serverside) {
		/* Initialise the SEE library */
		SEE_init();
		
		/* Initialise an interpreter */
		SEE_interpreter_init(&g_interp_storage);
		g_interp = &g_interp_storage;
	
		/* Bring our native functions into the interpreter */
		SEE_CFUNCTION_PUTA(g_interp, g_interp->Global, "println", g_println, 1, 0);
		SEE_CFUNCTION_PUTA(g_interp, g_interp->Global, "include", g_include, 1, 0);
		SEE_CFUNCTION_PUTA(g_interp, g_interp->Global, "version", g_version, 1, 0);
		
		/* evaluate bootstrapping code, and then script, then transform events */
		evaluate_file(g_interp, &g_result, "/Users/alan/working/golf/boot/serverside.js");
		evaluate_file(g_interp, &g_result, cgiPathTranslated);
		
		/* this is dangerous lol.  should check to make sure the callback is a function */
		if(callback)
			evaluate_string(g_interp, &g_result, function_call);
		
		/* this converts elements with onclick event attributes into links */
		evaluate_file(g_interp, &g_result, "/Users/alan/working/golf/boot/transform.js");
		evaluate_string(g_interp, &g_result, "document.render();");
		
	} else {
		
		fprintf(cgiOut, "<html>\n<head>\n");
		fprintf(cgiOut, "<script type = \"text/javascript\">\n");
		fprintf(cgiOut, "function boot() {\n");
		print_file("/Users/alan/working/golf/boot/clientside.js");
		print_file(cgiPathTranslated);
		fprintf(cgiOut, "\n}\n");
		fprintf(cgiOut, "</script>\n</head>\n");
		fprintf(cgiOut, "<body onload = \"boot();\">\n");
		fprintf(cgiOut, "</body>\n</html>");
		
	}
	
	return EXIT_SUCCESS;
}
开发者ID:alandipert,项目名称:cgolf,代码行数:54,代码来源:golf.c

示例5: dump_thread_kstats

void
dump_thread_kstats(dcontext_t *dcontext)
{
    if (dcontext->thread_kstats == NULL)
        return;

    /* add thread id's in case outfile is rerouted to process_kstats_outfile */
    print_file(dcontext->thread_kstats->outfile_kstats, "Thread %d KSTATS {\n",
               dcontext->thread_kstats->thread_id);
    kstat_report(dcontext->thread_kstats->outfile_kstats,
                 &dcontext->thread_kstats->vars_kstats);
    print_file(dcontext->thread_kstats->outfile_kstats, "} KSTATS\n");
}
开发者ID:AVGirl,项目名称:dynamorio,代码行数:13,代码来源:stats.c

示例6: print_help

/** 도움말을 출력합니다
 *
 * 인자로 받은 도움말 종류중 하나를 출력합니다
 *
 * @param int help 출력할 도움말 `HELP_ALL` , `HELP_START`, `HELP_DONE` ,
 *                 `HELP_LIST` , `HELP_REPORT` 중 하나
 */
void print_help(int help) {
  switch(help) {
    case HELP_ALL:
      print_file("./docs/help.md");
      break;
    case HELP_START:
      print_file("./docs/help_start.md");
      break;
    case HELP_DONE:
      print_file("./docs/help_done.md");
      break;
    default:
      printf("unrecognize option for HELP");
  }
}
开发者ID:admire93,项目名称:secon,代码行数:22,代码来源:sched_help.c

示例7: main

/**
 * Prints a graphical view of the directory structure.
 */
int main(int argc, char *argv[]) {

  // directory to list
  char *dir_name;
  // directory listing
  struct dirent **dir_list;
  // file count and loop variable
  int count, i;


  // check if we provided an arguement
  if( argc < 2 ) {
    // use the current dir
    dir_name = ".";
  } else {
    // use the provided dir
    dir_name = argv[1];
  }

  // read directory listing into array
  count = scandir(dir_name, &dir_list, file_select, alphasort);

  // loop through each file
  for (i=1; i<count+1; ++i)
    print_file(dir_list[i-1]);

  // exit cleanly
  return 0;

}
开发者ID:Slaughterfest1,项目名称:cpsc315,代码行数:33,代码来源:myls.c

示例8: main

int
main(int argc, char **argv, char **envp)
{
    dcontext_t *dc = standalone_init();

    /* Each test will abort if it fails, so we just call each in turn and return
     * 0 for success.  If we want to be able to call each test independently, it
     * might be worth looking into gtest, which already does this.
     */
    unit_test_io();
#ifdef UNIX
    unit_test_string();
    unit_test_os();
#endif
    unit_test_utils();
    unit_test_options();
    unit_test_vmareas();
#ifdef WINDOWS
    unit_test_drwinapi();
#endif
    unit_test_asm(dc);
    unit_test_atomic_ops();
    unit_test_jit_fragment_tree();
    print_file(STDERR, "all done\n");
    return 0;
}
开发者ID:AVGirl,项目名称:dynamorio,代码行数:26,代码来源:unit_tests.c

示例9: main

int main(int ac, char **av) {
  /* Function opens, sends to print, and closes file to be printed */
  int fd;

  if (ac != 2) /* Confirm there are two arguments */
    return 1;

  fd = open(av[1], O_RDONLY); /* Opens the file */
  if (fd == -1) {
    perror("open");
    return 1;
  }

  if (print_file(fd) == 1){ /* Prints the file */
    perror("read");
    return 1;
  }

  if (close(fd) == -1) { /* Close the file */
    perror("close");
    return 1;
  }

  return 0;
}
开发者ID:jm689336,项目名称:low,代码行数:25,代码来源:0-print_content.c

示例10: mount

/* funcao responsavel pela montagem do arquivo. Une  todos processos. */
void mount(char* fileFrom, char* fileTo) {
    set_table s_table;
    label_table l_table = build_labels(fileFrom, &s_table);

    print_file(fileFrom, fileTo, l_table, s_table);
    free_tables(s_table, l_table);
}
开发者ID:gciotto,项目名称:workspace,代码行数:8,代码来源:montador_ias.c

示例11: main

int main()
{

	printf("Hello world! \n");
	int i=0;
	char *liste;
	int16_t taille_liste=0;
	int16_t nb_block= 500;
	sfs = createSfs("sfstest", nb_block);
	printf("dans createSfs la signature est %s \n", sfs.sb.signature);
	printf("taille de sfs en block %d \n", sfs.sb.nbBlockTotal);
	sfsadd(&sfs, "fichier.txt");
	sfsadd(&sfs, "fichier2.txt");


	liste=sfslist(&sfs,&taille_liste);
	printf("Dans main liste est \n");
	for(i=0; i<taille_liste; i++)
		printf("%c", liste[i]);
	printf("\n");;

	printf("sfs.name[0] %s \n", sfs.fe[0].name);
	printf("sfs.name[1] %s \n", sfs.fe[1].name);
	printf("sfs.name[2] %s \n", sfs.fe[2].name);
	print_file(sfs.fc.data[2]);
	createImage();
	return 0;
}
开发者ID:bilgin1812,项目名称:hepiaOS,代码行数:28,代码来源:main.c

示例12: print_dir

void		print_dir(t_files *head, char *dir_name, t_ls_args *args)
{
	int		links_column;
	int		size_column;

	links_column = get_length_column(head, 1);
	size_column = get_length_column(head, 2);
	ft_putstr(dir_name);
	ft_putendl(":");
	if (ft_strchr(args->options, 'l') && head)
	{
		ft_putstr("total ");
		ft_putnbr(get_total_size(head));
		ft_putchar('\n');
	}
	while (head)
	{
		if (ft_strchr(args->options, 's'))
		{
			ft_putnbr(head->blocks);
			ft_putchar(' ');
		}
		print_file(head, args, links_column, size_column);
		head = head->next;
	}
}
开发者ID:adevbungert,项目名称:42-Projects,代码行数:26,代码来源:print_files.c

示例13: main

int main(int argc, char *argv[]) {
    num_tokens = 0;
    num_vars = 0;

    // set yyin to file if passed by user
    if(argc > 1) {
        yyin = fopen(argv[1], "r");
        if(yyin == NULL) {
            printf("error: invalid file\n");
            exit(1);
        }
    }
    else {
        printf("> "); // prompt
    }

    yyparse();
    fclose(yyin);
    generate_pla(root);

    and_or_not(root);
    freopen ("/dev/tty", "a", stdout); // make sure stdout is restored

    free_ast(root);
    empty_tokens();
    reformat_output();

    // print output
    char *fname = (char *)"out.pla";
    print_file(&fname);

    return 0;
}
开发者ID:johncburnett,项目名称:b-logic,代码行数:33,代码来源:and_or_not.c

示例14: kstat_print_individual

/* PR 312534: reduce stack usage (gcc does not combine locals) */
static void
kstat_print_individual(file_t outf, kstat_variable_t *kv,
                       const char *name, const char *desc)
{
    print_file(outf, "%20s:"FIXED_TIMESTAMP_FORMAT" totc,"
               "%8u num,"
               FIXED_TIMESTAMP_FORMAT" minc,"
               FIXED_TIMESTAMP_FORMAT" avg,"
               FIXED_TIMESTAMP_FORMAT" maxc,"
               FIXED_TIMESTAMP_FORMAT" self,"
               FIXED_TIMESTAMP_FORMAT" sub,"
               "\n"
               "                   "
               FIXED_TIMESTAMP_FORMAT" ms,"
               FIXED_TIMESTAMP_FORMAT" ms out,"
               "%s\n",
               name,
               kv->total_self + kv->total_sub,
               kv->num_self,
               (kv->min_cum == (timestamp_t)-1) ? 0 : kv->min_cum,
               (kv->total_self + kv->total_sub) / kv->num_self,
               kv->max_cum,
               kv->total_self,
               kv->total_sub,
               (kv->total_self + kv->total_sub) / kstat_frequency_per_msec,
               kv->total_outliers/ kstat_frequency_per_msec,
               desc);
}
开发者ID:AVGirl,项目名称:dynamorio,代码行数:29,代码来源:stats.c

示例15: print_file2

double print_file2()
{
  char filename[100];
  FILE *fr;
  
  printf("Zadejte jmeno souboru: ");
  scanf("%s", filename);

  if ((fr = fopen(filename, "r")) == NULL) {
    printf("Soubor %s nebyl nalezen!\n", filename);
    return filename_is_k(filename) ? 2.2 : 1.1;
  }

  print_file(fr);
  
  if (fclose(fr) == EOF) {
    printf("Nepodarilo se zavrit soubor %s!\n", filename);
    return 0.5;
  }

  if (filename_is_k(filename)) {
    return 2.2;
  }

  return 0.5;

}
开发者ID:tomaskrizek,项目名称:c-programming-herout,代码行数:27,代码来源:08.c


注:本文中的print_file函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。