/*
 * Perform Tests.
 */
void PerformTests(void)
{
    int                     Loop;

    for (Loop = 0; Loop < Index; Loop++)
        if (Test[Loop].SkipFlag) {
            MESSAGE(2, ("Skipping -- %s (%s) \n", Test[Loop].Description, Test[Loop].Name));
        } else {
            MESSAGE(2, ("Testing  -- %s (%s) \n", Test[Loop].Description, Test[Loop].Name));
            MESSAGE(5, ("===============================================\n"));
            Test[Loop].NumErrors = num_errs;
	    Test_parameters = Test[Loop].Parameters;
	    ALARM_ON;
            Test[Loop].Call();
	    ALARM_OFF;
            Test[Loop].NumErrors = num_errs - Test[Loop].NumErrors;
            MESSAGE(5, ("===============================================\n"));
            MESSAGE(5, ("There were %d errors detected.\n\n", (int)Test[Loop].NumErrors));
        }

    Test_parameters = NULL;     /* clear it. */
    MESSAGE(2, ("\n\n"))

    if (num_errs)
        print_func("!!! %d Error(s) were detected !!!\n\n", (int) num_errs);
    else
        print_func("All tests were successful. \n\n");
}
/*
 * Print test info.
 */
void TestInfo(const char *ProgName)
{
    unsigned major, minor, release;

    H5get_libversion(&major, &minor, &release);

    print_func("\nFor help use: %s -help\n",ProgName);
    print_func("Linked with hdf5 version %u.%u release %u\n", major, minor, release);
}
예제 #3
0
파일: print.c 프로젝트: crherar/Admin
void
hx509_bitstring_print(const heim_bit_string *b,
		      hx509_vprint_func func, void *ctx)
{
    int i;
    print_func(func, ctx, "\tlength: %d\n\t", b->length);
    for (i = 0; i < (b->length + 7) / 8; i++)
	print_func(func, ctx, "%02x%s%s",
		   ((unsigned char *)b->data)[i],
		   i < (b->length - 7) / 8
		   && (i == 0 || (i % 16) != 15) ? ":" : "",
		   i != 0 && (i % 16) == 15 ?
		   (i <= ((b->length + 7) / 8 - 2) ? "\n\t" : "\n"):"");
}
예제 #4
0
파일: seq.c 프로젝트: jgensler8/cs251
extern void seq_print(Seq seq, void (* print_func)(void *)){
    Node *temp;
    temp = seq->head;
    while( temp != NULL){
	print_func(temp->a);
	temp = temp->fw;
    }
}
예제 #5
0
파일: print2.c 프로젝트: craftJ/c_fun
int external_print2()
{
	printf("22222222 [%s][%d] !!!\n",__func__,__LINE__);

	print_func();

	return 0;
}
예제 #6
0
파일: disas.cpp 프로젝트: DirektSPEED/hhvm
void print_unit(Output& out, const Unit* unit) {
  out.fmtln("# {} starts here", unit->filepath()->data());
  out.nl();
  print_unit_metadata(out, unit);
  for (auto* func : unit->funcs())       print_func(out, func);
  for (auto& cls : unit->preclasses())   print_cls(out, cls.get());
  out.fmtln("# {} ends here", unit->filepath()->data());
}
예제 #7
0
파일: print.c 프로젝트: crherar/Admin
void
hx509_oid_print(const heim_oid *oid, hx509_vprint_func func, void *ctx)
{
    char *str;
    hx509_oid_sprint(oid, &str);
    print_func(func, ctx, "%s", str);
    free(str);
}
예제 #8
0
int main() {
    int queue[MAX];

    initQue(queue);
    print_func(queue);
    initQue(queue);
    input(queue, 3);
    input(queue, 4);
    input(queue, 5);
    print_func(queue);
    input(queue, 8);
    print_func(queue);
    pop(queue);
    print_func(queue);

    return 0;



}
예제 #9
0
파일: theme.c 프로젝트: jetlive/xynth
void print_main (char *name)
{
        int f;
        int b;
        int v;
        
	printf(
	"\n"
	"void theme_init (s_theme_t *theme)\n"
	"{\n");

	for (f = 0; f < THEME_FORM_MAX; f++) {
		for (v = 0; v < 2; v++) {
			printf("\t");
			print_func(f_names[f][v]);
			printf("(&theme->form[%d][%d]);\n", v, f);
		}
		printf("\n");
	}
	for (b = 0; b < THEME_BUTTON_MAX; b++) {
		for (v = 0; v < 3; v++) {
			printf("\t");
			print_func(b_names[b][v]);
			printf("(&theme->button[%d][%d]);\n", v, b);
		}
		printf("\n");
	}

	printf("\ttheme->form_min.w = %d;\n", s_theme.form_min.w);
	printf("\ttheme->form_min.w_ = %d;\n", s_theme.form_min.w_);
	printf("\ttheme->form_min.h = %d;\n", s_theme.form_min.h);
	printf("\ttheme->text_color[1] = 0x%06x;\n", s_theme.text_color[1]);
	printf("\ttheme->text_color[0] = 0x%06x;\n", s_theme.text_color[0]);
	printf("\ttheme->text_v_off[1] = %d;\n", s_theme.text_v_off[1]);
	printf("\ttheme->text_v_off[0] = %d;\n", s_theme.text_v_off[0]);
	printf("\ttheme->title_full = %d;\n", s_theme.title_full);
	printf("\ttheme->text_alignment = %d;\n", s_theme.text_alignment);

	printf(
	"}\n");
}
예제 #10
0
static void
static_delta_usage (char    **argv,
                    gboolean  is_error)
{
  OstreeCommand *command = static_delta_subcommands;
  void (*print_func) (const gchar *format, ...);

  if (is_error)
    print_func = g_printerr;
  else
    print_func = g_print;

  print_func ("usage: ostree static-delta\n");
  print_func ("Builtin commands:\n");

  while (command->name)
    {
      print_func ("  %s\n", command->name);
      command++;
    }
}
예제 #11
0
파일: ot-main.c 프로젝트: gcampax/ostree
int
ostree_usage (char **argv, OstreeBuiltin *builtins, gboolean is_error)
{
  OstreeBuiltin *builtin = builtins;
  void (*print_func) (const gchar *format, ...);

  if (is_error)
    print_func = g_printerr;
  else
    print_func = g_print;

  print_func ("usage: %s --repo=PATH COMMAND [options]\n",
              argv[0]);
  print_func ("Builtin commands:\n");

  while (builtin->name)
    {
      print_func ("  %s\n", builtin->name);
      builtin++;
    }
  return (is_error ? 1 : 0);
}
예제 #12
0
int
__display_breakpoint_list (void (*print_func)(target_register_t))
{
  struct breakpoint_list *l = breakpoint_list;

  while (l != NULL)
    {
      print_func(l->addr);
      l = l->next;
    }

  return 0;
}
예제 #13
0
파일: l_ipcio.c 프로젝트: MagnoNogueira/L4
/*-----------------------------------------------------------------
 * ROUTINE NAME - L_IPCIO_HandleIPCReqMsg
 *-----------------------------------------------------------------
 * FUNCTION: This function will deal the ipcio msg.
 * INPUT   : msg_p             - the ipcio msg.
 *           print_func        - the function for output.
 * OUTPUT  : need_wait_key_p   - a I/O service provider should a flag
 *                               to track if someone is waitting for keyin.
 *                               while TRUE, it means that someone
 *                               needs to get user keyin and
 *                               the I/O service provider must
 *                               call L_IPCIO_ParseKey() when caller(UI)
 *                               get user keyin.
 * RETUEN  : TRUE  - need to send response.
 *           FALSE - not need to send response.
 * NOTE    : None.
 *----------------------------------------------------------------*/
BOOL_T L_IPCIO_HandleIPCReqMsg(SYSFUN_Msg_T *msg_p, void (*print_func)(const char *), BOOL_T *need_wait_key_p)
{
    L_IPCIO_Msg_T *l_ipcio_msg_p = (L_IPCIO_Msg_T *)msg_p->msg_buf;
    BOOL_T need_resp = FALSE;

    if (msg_p == NULL || need_wait_key_p == NULL)
        return FALSE;

    switch (l_ipcio_msg_p->ipcio_cmd)
    {
        case L_IPCIO_CMD_GETCHAR:
            if (*need_wait_key_p)
            {
                msg_p->msg_size = L_IPCIO_SIZE_OF_MSG(sizeof(l_ipcio_msg_p->ipcio_arg_ch));
                l_ipcio_msg_p->ipcio_arg_ch = '\0';
                need_resp = TRUE;
            }
            else
            {
                memcpy(l_ipcio_msg_buf, msg_p, SYSFUN_SIZE_OF_MSG(L_IPCIO_SIZE_OF_MSG(0)));
                *need_wait_key_p = TRUE;
            }
            break;

        case L_IPCIO_CMD_GETLINE:
            if (*need_wait_key_p)
            {
                msg_p->msg_size = L_IPCIO_SIZE_OF_MSG(1);
                l_ipcio_msg_p->ipcio_arg_buffer[0] = '\0';
                need_resp = TRUE;
            }
            else
            {
                memcpy(l_ipcio_msg_buf, msg_p, SYSFUN_SIZE_OF_MSG(L_IPCIO_SIZE_OF_MSG(0)));
                l_ipcio_wait_size = (l_ipcio_msg_p->ipcio_arg_size < sizeof(l_ipcio_msg_p->ipcio_arg_buffer) ?
                                        l_ipcio_msg_p->ipcio_arg_size : sizeof(l_ipcio_msg_p->ipcio_arg_buffer)) - 1;
                *need_wait_key_p = TRUE;
            }
            break;

        case L_IPCIO_CMD_PRINT:
            if (print_func)
                print_func(l_ipcio_msg_p->ipcio_arg_buffer);
            break;

        default:
            printf("%s: invalid command.\n", __FUNCTION__);
    }

    return need_resp;
}
예제 #14
0
void print_resources(void)
{
  TYPEINFO *type_ptr;
  int i;

  COUTPUT(("/* TWIN Resource Compiler Version " RC_VERSION " */\n"));
  COUTPUT(("\n"));
  COUTPUT(("#define NOAPIPROTO\n"));
  COUTPUT(("\n"));
  COUTPUT(("#include \"windows.h\"\n"));
  COUTPUT(("#include \"Resources.h\"\n"));
  COUTPUT(("\n"));
  for(i = 0; i < MAX_TYPES; i++)
  {
    type_ptr = resource_table + i;
    if (type_ptr->rcscount > 0 )
      print_func(type_ptr);
  }
  
  parse_module();      /* Load the Module Definition file */

  COUTPUT(("%sTYPEINFO hsmt_resource_%s[] = {\n",
      (strlen(tbl_name))?"":"static ",
      (strlen(tbl_name))?tbl_name:"table"));

  for (i = 0; i < MAX_TYPES; i++)
    {
      type_ptr = resource_table + i;
      if (type_ptr->rcscount > 0 )
	{
	  if (HIWORD((DWORD)type_ptr->rcstypename) == 0)
	    COUTPUT(( "\t{ (char *) %d, ", LOWORD((DWORD)type_ptr->rcstypename)));
	  else
	    COUTPUT(( "\t{ \"%s\", ", type_ptr->rcstypename));
	  COUTPUT(( " %d, ", type_ptr->rcscount));
	  if ((HIWORD((DWORD)type_ptr->rcstypename) == 0) &&
	      (LOWORD((DWORD)type_ptr->rcstypename) < 16))
	    COUTPUT(( " %s },\n", info_name_tbl[LOWORD((DWORD)type_ptr->rcstypename) - 1]));
	  else
	    if (HIWORD(type_ptr->rcstypename) == 0)
	      COUTPUT(( "u%d_info},\n", (int)type_ptr->rcstypename));
	    else
	      COUTPUT(( "%s_info},\n", type_ptr->rcstypename));
	  
	}
    }
  print_last_entry(3);
  COUTPUT(("};\n\n"));
  print_module();
}
예제 #15
0
Logging::Logging(ELogLevel level, string file, int line, string function_name)
{
    do_logging = level >= global_level;
    
    if (do_logging)
    {
        switch(level)
        {
        case LOGLEVEL_DEBUG:
            print_func("[DEBUG] ");
            break;
        case LOGLEVEL_INFO:
            print_func("[INFO]  ");
            break;
        case LOGLEVEL_WARNING:
            print_func("[WARN]  ");
            break;
        case LOGLEVEL_ERROR:
            print_func("[ERROR] ");
            break;
        }
    }
}
예제 #16
0
int
pkgsys_ostree_usage (char **argv,
                     PkgsysOstreeCommand *commands,
                     gboolean is_error)
{
  PkgsysOstreeCommand *command = commands;
  void (*print_func) (const gchar *format, ...);

  if (is_error)
    print_func = g_printerr;
  else
    print_func = g_print;

  print_func ("usage: %s --repo=PATH COMMAND [options]\n",
              argv[0]);
  print_func ("Builtin commands:\n");

  while (command->name)
    {
      print_func ("  %s\n", command->name);
      command++;
    }
  return (is_error ? 1 : 0);
}
예제 #17
0
 std::ostream& node(const ast::abstract::Node& node) {
   switch(node) {
   case ast::ExternNode:
     print_extern(dynamic_cast<const ast::Extern&>(node));
     break;
   case ast::FuncNode:
     print_func(dynamic_cast<const ast::Func&>(node));
     break;
   case ast::VariableNode:
     print_variable(dynamic_cast<const ast::Variable&>(node));
     break;
   case ast::ConstantNode:
     print_constant(dynamic_cast<const ast::Constant&>(node));
     break;
   case ast::CastNode:
     print_cast(dynamic_cast<const ast::Cast&>(node));
     break;
   case ast::UnOpNode:
     print_un_op(dynamic_cast<const ast::UnOp&>(node));
     break;
   case ast::BinOpNode:
     print_bin_op(dynamic_cast<const ast::BinOp&>(node));
     break;
   case ast::CallNode:
     print_call(dynamic_cast<const ast::Call&>(node));
     break;
   case ast::ReturnNode:
     print_return(dynamic_cast<const ast::Return&>(node));
     break;
   case ast::BranchNode:
     print_branch(dynamic_cast<const ast::Branch&>(node));
     break;
   case ast::AssignmentNode:
     print_assignment(dynamic_cast<const ast::Assignment&>(node));
     break;
   case ast::WhileNode:
     print_while(dynamic_cast<const ast::While&>(node));
     break;
   case ast::VoidContextNode:
     print_void_context(dynamic_cast<const ast::VoidContext&>(node));
     break;
   default:
     stream << "[Unknown Node] ??";
   }
   return stream;
 }
예제 #18
0
int main()
{
  int prev_val[ARRAY_HEIGHT][ARRAY_WIDTH];
  int next_val[ARRAY_HEIGHT][ARRAY_WIDTH];

  define_init_val(prev_val);

  for (int i = 0; i <= LIFE_SPAN; i++)
  {
    sleep(1);
    printf("第%d世代\n", i);
    print_func(prev_val);
    generational_change(prev_val, next_val);
    cp_prev_to_next(prev_val, next_val);
  }

  return 1;
}
/*
 * Display test summary.
 */
void TestSummary(void)
{
    int                     Loop;

    print_func("Summary of Test Results:\n");
    print_func("Name of Test     Errors Description of Test\n");
    print_func("---------------- ------ --------------------------------------\n");

    for (Loop = 0; Loop < Index; Loop++) {
        if (Test[Loop].NumErrors == -1)
            print_func("%16s %6s %s\n", Test[Loop].Name, "N/A", Test[Loop].Description);
        else
            print_func("%16s %6d %s\n", Test[Loop].Name, (int)Test[Loop].NumErrors, Test[Loop].Description);
    }

    print_func("\n\n");
}
예제 #20
0
파일: log.c 프로젝트: naihe2010/acnchess
void
acclog_f (const char *subsys, int loglevel, const char *format, ...)
{
  va_list ap;
  char buf[1024];
  int len;

  va_start (ap, format);

  if (print_func)
    {
      len = snprintf (buf, sizeof buf, "%s:", subsys);
      vsnprintf (buf + len, sizeof buf - len, format, ap);
      print_func (buf, print_arg);
    }
  else
    {
      printf ("%s:", subsys);
      vprintf (format, ap);
    }

  va_end (ap);
}
예제 #21
0
파일: theme.c 프로젝트: d33tah/whitix
void init_buf (char *file, s_image_t *img)
{
        int y;
        int x;
	unsigned int *tmp_d;

	s_image_img(file, img);
	s_image_get_handler(img);

	printf("\n"
	       "/*\n"
               " * %s\n"
               " */\n", file);

	printf("static void ");
        print_func(file);
	printf(" (s_image_t *img)\n");

        printf("{\n");
        printf("\tunsigned int rgba[%d] = {\n", img->w * img->h);

        tmp_d = img->rgba;
	for (y = 0; y < img->h; y++) {
		printf("\t");
		for (x = 0; x < img->w; x++) {
			printf("0x%08x, ", *tmp_d);
			tmp_d++;
		}
		printf("\n");
	}

	printf("\t};\n");
	printf("\n");
	printf("\ttheme_set(img, rgba, %d, %d);\n", img->w, img->h);
        printf("}\n");
}
gboolean
ot_admin_builtin_instutil (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError **error)
{
  gboolean ret = FALSE;
  OstreeAdminInstUtilCommand *subcommand;
  const char *subcommand_name = NULL;
  gboolean want_help = FALSE;
  int in, out, i;
  gboolean skip;

  for (in = 1, out = 1; in < argc; in++, out++)
    {
      /* The non-option is the command, take it out of the arguments */
      if (argv[in][0] != '-')
        {
          skip = (subcommand_name == NULL);
          if (subcommand_name == NULL)
            subcommand_name = argv[in];
        }

      /* The global long options */
      else if (argv[in][1] == '-')
        {
          skip = FALSE;

          if (g_str_equal (argv[in], "--"))
            {
              break;
            }
          else if (g_str_equal (argv[in], "--help"))
            {
              want_help = TRUE;
            }
          else if (subcommand_name == NULL)
            {
              g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
                           "Unknown or invalid admin instutil option: %s", argv[in]);
              goto out;
            }
        }

      /* The global short options */
      else
        {
          skip = FALSE;
          for (i = 1; argv[in][i] != '\0'; i++)
            {
              switch (argv[in][i])
              {
                case 'h':
                  want_help = TRUE;
                  break;

                default:
                  if (subcommand_name == NULL)
                    {
                      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
                                   "Unknown or invalid admin instutil option: %s", argv[in]);
                      goto out;
                    }
                  break;
              }
            }
        }

      /* Skipping this argument? */
      if (skip)
        out--;
      else
        argv[out] = argv[in];
    }

  argc = out;

  if (subcommand_name == NULL)
    {
      void (*print_func) (const gchar *format, ...) = want_help ? g_print : g_printerr;

      subcommand = admin_instutil_subcommands;
      print_func ("usage: ostree admin instutil COMMAND [options]\n");
      print_func ("Builtin commands:\n");
      while (subcommand->name)
        {
          print_func ("  %s\n", subcommand->name);
          subcommand++;
        }

      if (want_help)
        ret = TRUE;
      else
        g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
                             "No command specified");
      goto out;
    }

  subcommand = admin_instutil_subcommands;
  while (subcommand->name)
    {
      if (g_strcmp0 (subcommand_name, subcommand->name) == 0)
        break;
      subcommand++;
    }

  if (!subcommand->name)
    {
      g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
                   "Unknown admin instutil command '%s'", subcommand_name);
      goto out;
    }

  g_set_prgname (g_strdup_printf ("ostree admin instutil %s", subcommand_name));

  if (!subcommand->fn (argc, argv, sysroot, cancellable, error))
    goto out;
 
  ret = TRUE;
 out:
  return ret;
}
/*
 * Print test usage.
 *	First print the common test options, then the extra options if provided.
 *
 * Modification:
 * 	2004/08/18 Albert Cheng.  Add TestPrivateUsage feature.
 */
void TestUsage(void)
{
	int i;

	print_func("Usage: %s [-v[erbose] (l[ow]|m[edium]|h[igh]|0-9)] %s\n",
	    TestProgName, (TestPrivateUsage ? "<extra options>" : ""));
	print_func("              [-[e]x[clude] name]+ \n");
	print_func("              [-o[nly] name]+ \n");
	print_func("              [-b[egin] name] \n");
	print_func("              [-s[ummary]]  \n");
	print_func("              [-c[leanoff]]  \n");
	print_func("              [-h[elp]]  \n");
	print_func("\n\n");
	print_func("verbose   controls the amount of information displayed\n");
	print_func("exclude   to exclude tests by name\n");
	print_func("only      to name tests which should be run\n");
	print_func("begin     start at the name of the test givin\n");
	print_func("summary   prints a summary of test results at the end\n");
	print_func("cleanoff  does not delete *.hdf files after execution of tests\n");
	print_func("help      print out this information\n");
	if (TestPrivateUsage){
	    print_func("\nExtra options\n");
	    TestPrivateUsage();
	}
	print_func("\n\n");
	print_func("This program currently tests the following: \n\n");
	print_func("%16s %s\n", "Name", "Description");
	print_func("%16s %s\n", "----", "-----------");

	for (i = 0; i < Index; i++)
		print_func("%16s %s\n", Test[i].Name, Test[i].Description);

	print_func("\n\n");
}
예제 #24
0
파일: sdp.c 프로젝트: ghent360/bluez
static void decode_data_elements(uint32_t position, uint8_t indent,
				const uint8_t *data, uint32_t size,
				void (*print_func) (uint32_t, uint8_t, uint8_t,
						const uint8_t *, uint32_t))

{
	uint32_t datalen, elemlen, extrabits;
	int i;

	if (!size)
		return;

	extrabits = get_bits(data, size);

	if (size < 1 + (extrabits / 8)) {
		print_text(COLOR_ERROR, "data element descriptor too short");
		packet_hexdump(data, size);
		return;
	}

	datalen = get_size(data, size);

	if (size < 1 + (extrabits / 8) + datalen) {
		print_text(COLOR_ERROR, "data element size too short");
		packet_hexdump(data, size);
		return;
	}

	elemlen = 1 + (extrabits / 8) + datalen;

	for (i = 0; type_table[i].str; i++) {
		uint8_t type = (data[0] & 0xf8) >> 3;

		if (type_table[i].value != type)
			continue;

		if (print_func) {
			print_func(position, indent, type,
					data + 1 + (extrabits / 8), datalen);
			break;
		}

		print_field("%*c%s (%d) with %u byte%s [%u extra bits] len %u",
					indent, ' ', type_table[i].str, type,
					datalen, datalen == 1 ? "" : "s",
					extrabits, elemlen);
		if (!valid_size(data[0] & 0x07, type_table[i].sizes)) {
			print_text(COLOR_ERROR, "invalid data element size");
			packet_hexdump(data + 1 + (extrabits / 8), datalen);
			break;
		}

		if (type_table[i].recurse)
			decode_data_elements(0, indent + 2,
					data + 1 + (extrabits / 8), datalen,
								print_func);
		else if (type_table[i].print)
			type_table[i].print(indent + 2,
					data + 1 + (extrabits / 8), datalen);
		break;
	}

	if (elemlen > size) {
		print_text(COLOR_ERROR, "invalid data element size");
		return;
	}

	data += elemlen;
	size -= elemlen;

	decode_data_elements(position + 1, indent, data, size, print_func);
}
예제 #25
0
int main(int argc, char **argv)
{
    struct Option *input;
    struct Option *output;
    struct Option *coords;
    struct Flag *format;
    struct Flag *quiet;
    struct Flag *reverse;
    struct GModule *module;
    FILE *infile, *outfile;
    struct survey_record record;
    const char *cptr;
    char *ss;
    int verbose = 1, linenum = 0;
    int (*parse_line) (const char *, struct survey_record *);
    void (*print_func) (FILE *, struct survey_record *);

    G_gisinit(argv[0]);

    module = G_define_module();
    G_add_keyword(_("miscellaneous"));
    G_add_keyword(_("distance"));
    module->label = _("A simple utility for converting bearing and "
		      "distance measurements to coordinates and vice versa.");
    module->description = _("It assumes a cartesian coordinate system");

    format = G_define_flag();
    format->key = 'l';
    format->description = _("Lines are labelled");

    quiet = G_define_flag();
    quiet->key = 'q';
    quiet->description = _("Suppress warnings");

    reverse = G_define_flag();
    reverse->key = 'r';
    reverse->description =
	_("Convert from coordinates to bearing and distance");

    input = G_define_standard_option(G_OPT_F_INPUT);
    input->required = NO;
    input->answer = "-";

    output = G_define_standard_option(G_OPT_F_OUTPUT);
    output->required = NO;
    output->answer = "-";

    coords = G_define_option();
    coords->key = "coord";
    coords->key_desc = "x,y";
    coords->type = TYPE_DOUBLE;
    coords->required = NO;
    coords->description = _("Starting coordinate pair");
    coords->answer = "0.0,0.0";

    if (G_parser(argc, argv) != 0)
	exit(EXIT_FAILURE);


    if (input->answer && input->answer[0] != '-') {
	infile = fopen(input->answer, "r");
	if (infile == NULL)
	    G_fatal_error(_("Couldn't open COGO file <%s>"), input->answer);
    }
    else {
	infile = stdin;
    }

    if (output->answer && output->answer[0] != '-') {
	outfile = fopen(output->answer, "w");
	if (outfile == NULL)
	    G_fatal_error(_("Couldn't open output file <%s>"),
			  output->answer);
    }
    else {
	outfile = stdout;
    }

    record.label[0] = '\0';
    if (format->answer) {
	record.haslabel = YES;
    }
    else {
	record.haslabel = NO;
    }

    if (quiet->answer)
	verbose = 0;

    if (reverse->answer) {
	parse_line = parse_reverse;
	print_func = print_cogo;
    }
    else {
	parse_line = parse_forward;
	print_func = print_coordinates;
    }

    if (coords->answer) {
	record.x = strtod(coords->answers[0], &ss);
	if (ss == coords->answers[0])
	    G_fatal_error(_("Converting starting coordinate pair"));
	record.y = strtod(coords->answers[1], &ss);
	if (ss == coords->answers[1])
	    G_fatal_error(_("Converting starting coordinate pair"));
    }
    else {
	record.x = record.y = 0.0;
    }

    while ((cptr = next_line(infile))) {
	linenum++;

	if ((cptr[0] == '#') || (cptr[0] == '\0') || (cptr[0] == '\n')) {
	    /* remove \n check once module is updated to use G_getl2() */
	    continue;		/* line is a comment or blank */
	}

	if (!parse_line(cptr, &record)) {
	    if (verbose)
		G_warning(_("Input parse error on line %d"), linenum);
	    continue;
	}
	print_func(outfile, &record);
    }

    if (infile != stdin)
	fclose(infile);
    if (outfile != stdout)
	fclose(stdout);

    exit(EXIT_SUCCESS);
}
예제 #26
0
/* Use read insn_nemaweaver to read and print_func to print. */
int print_insn_nemaweaver (bfd_vma memaddr, struct disassemble_info * info)
{
    fprintf_ftype       print_func = info->fprintf_func;
    void *              stream = info->stream;
    unsigned long       inst, prev_inst;
    struct op_code_struct * op, *pop;
    int                 immval = 0;
    bfd_boolean         immfound = FALSE;
    static bfd_vma      prev_insn_addr = -1; /* Init the prev insn addr.  */
    static int          prev_insn_vma = -1;  /* Init the prev insn vma.  */
    int                 curr_insn_vma = info->buffer_vma;
    int i;

    info->bytes_per_chunk = 4;

    inst = read_insn_nemaweaver (memaddr, info, &op);

    if (inst == INVALID_INST) {
	return -1;
    }

    /* If we are continuing from the last expanded command. */
    if (prev_insn_vma == curr_insn_vma)
    {
    	if (memaddr-(info->bytes_per_chunk) == prev_insn_addr)
        {
    	    prev_inst = read_insn_nemaweaver (prev_insn_addr, info, &pop);
    	    if (prev_inst == INVALID_INST) {
    		return -1;
    	    }
    	    /* This code seems quite legit... I dont see why it is
    	     * commented out */
    	    //if (pop->instr == imm)
    	    //  {
    	    //    immval = (get_int_field_imm (prev_inst) << 16) & 0xffff0000;
    	    //    immfound = TRUE;
    	    //  }
    	    //else
    	    //  {
    	    immval = 0;
    	    immfound = FALSE;
    	    //  }
    	}
    }

    /* Make curr insn as prev insn.  */
    prev_insn_addr = memaddr;
    prev_insn_vma  = curr_insn_vma;

    if ( strlen(op->name) == 0)
	print_func (stream, ".word\t0x%08x", inst);
    else
    {
	print_func (stream, "%s", op->name);

	for (i=0 ; !INVALID_ARG(i, op); i++) {
	    print_func (stream, " %s", GET_ARGUMENT(i, inst, op));
	    if (!INVALID_ARG(i+1, op))
		print_func (stream, ",");
	}
    }
    /* Say how many bytes we consumed.  */
    return 4;
}
예제 #27
0
Logging::~Logging()
{
    if (do_logging)
        print_func("\n");
}
예제 #28
0
파일: print_inst.cpp 프로젝트: jzeng4/top
void print_program()
{
#ifdef DEBUG
	fprintf(stdout, "starting print program...\n");
#endif

	output = fopen("output_a.out.c", "w");
	if(!output){
		fprintf(stderr, "error in print_program\n");
		exit(0);
	}

	print_header();	
	print_func_decaration();
	print_safety_guard();
	print_print_pc();
	
	//yang
	unsigned  instsize = 0;
	unsigned int globalsize = 0;
	globalsize = print_dependence_data_to_file();
	
////////	
	for(PROGRAM::iterator it = g_current_program->begin();//dump functions
			it != g_current_program->end();it++){
		
#ifdef WINDOWS_NAKED
	fprintf(output, "__declspec( naked ) ");
#endif
		if(g_main_pc == it->first){
			fprintf(output, "void main(){\n");
//Hush.b
//extern variables in dst
#ifdef DEBUG
			fprintf(stderr, "----dst_map size is %d\n", dst_map.size());	
#endif

#if 0
			if(!dst_map.empty()){
				for(map<unsigned int, Dst_item*>::iterator it= dst_map.begin();
					it!=dst_map.end();it++){
					fprintf(output, "extern %s;\n", it->second->name);	
				}	
			}
#endif
			fprintf(output, "output=fopen(\"log\", \"w\");\n");
//Hush.e
		}else{
			fprintf(output, "int func_0x%x(){\n", it->first);
		}
#ifdef DEBUG
		fprintf(stderr, "----function start pc:%x\t%x\n", it->first, it->second);
#endif
		g_current_func = it->second;
		print_func(it->second);
		fprintf(output, "}\n");

		instsize += it->second->size();
	}
	fclose(output);
#ifdef STATISTICS
	fprintf(stderr, "program:%s\n", PEMU_binary_name);
	fprintf(stderr, "number of executed inst:\t%d\n", g_inst_num);
	fprintf(stderr, "symbolized addresses %d\n", g_symbol_nums);
	fprintf(stderr, "direct jmp:\t%d\njcc:\t%d\ndirect call:\t%d\ndata:\t%d\ndis:\t%d\nimm:\t%d\n", 
			g_jmp_num, g_jcc_num, g_call_num, g_dump_data, g_dis_nums, g_imm_nums);
	fprintf(stderr, "checks num:%d\n", g_check_nums);
#endif
}
int
func (void)
{
  print_func ("local string");
  return 0;
}
예제 #30
0
const Logging& operator<<(const Logging& log, const char* str)
{
    if (log.do_logging)
        print_func("%s", str);
    return log;
}