Example #1
0
File: cspec.c Project: faloi/cspec
 void _cspec_it_post(const char* description) {
     if (IT_FAILURES_SHULDS) {
         print_description(description, "", "  ", FAILURE);
     } else {
         print_description(description, "", "  ", SUCCESS);
     }
 }
Example #2
0
void print_parameter_info()
{
  int name_len = 0;

  for (int i = 0; i < g_kim.nparams; ++i)
    if (strlen(g_kim.params[i].name) > name_len)
      name_len = strlen(g_kim.params[i].name);

  name_len = ((name_len + 7) & ~7);

  const int type_len = 8;
  const int extent_len = 8;
  const int desc_len = 60;

  print_string_space("Name", name_len);
  print_string_space("Type", type_len);
  print_string_space("Extent", extent_len);
  print_string_space("Description", desc_len);
  printf("\n");
  for (int i = 0; i < name_len + type_len + extent_len + desc_len; ++i)
    printf("-");
  printf("\n");

  for (int i = 0; i < g_kim.nparams; ++i) {
    print_string_space(g_kim.params[i].name, name_len);
    print_string_space(KIM_DataType_ToString(g_kim.params[i].type), type_len);
    print_int_space(g_kim.params[i].extent, extent_len - 2);
    printf("  ");
    print_description(g_kim.params[i].desc, name_len + type_len + extent_len, desc_len);
  }
  printf("\n");
}
Example #3
0
int main (int argc, char **argv)
{
	int flag;
	glutInit (&argc, argv);
	print_description ();
	flag = SDL_Init (SDL_INIT_VIDEO);
	if (flag < 0) {
		fprintf (stderr, "SDL initialize Hum! \n");
	}
	atexit (SDL_Quit);
	SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
	surface = SDL_SetVideoMode
		(window_width, window_height, 0, SDL_OPENGL | SDL_RESIZABLE);
	if (surface == NULL) {
		fprintf (stderr, "SDL Video initialize Ha!\n");
	}
	SDL_WM_SetCaption (TITLE, NULL);
	initialize();
#ifdef EMSCRIPTEN
	emscripten_set_main_loop (one_iter, 30, 0);
#else /* #ifdef EMSCRIPTEN */
	for (;;) {
		one_iter ();
	}
#endif /* #ifdef EMSCRIPTEN */
	return 1;
}
Example #4
0
File: cspec.c Project: mumuki/cspec
 void __describe_pre(String description) {
     if (DESCRIBE_DEEP_LEVEL == 0) puts("");
     AFTERS [DESCRIBE_DEEP_LEVEL] = NULL;
     BEFORES[DESCRIBE_DEEP_LEVEL] = NULL;
     DESCRIBE_DEEP_LEVEL++;
     CURRENT_DESCRIBE = description;
     print_description(description, "", "", "", DESCRIBE);
 }
 //! Parse the command line arguments
 bool parse(int argc, char** argv) {
   namespace boost_po = boost::program_options;
   
   // Set the program options
   desc.add_options()
     ("ncpus",
      boost_po::value<size_t>(&(ncpus))->
      default_value(ncpus),
      "Number of cpus to use.")
     ("engine",
      boost_po::value<std::string>(&(engine_type))->
      default_value(engine_type),
      "Options are {async, async_sim, synchronous}")
     ("scope",
      boost_po::value<std::string>(&(scope_type))->
      default_value(scope_type),
      "Options are {none, vertex, edge, full}")
     ("scheduler",
      boost_po::value<std::string>(&(scheduler_type))->
      default_value(scheduler_type),
      "There are several scheduler supported by the graphlab framework:"
      "{synchronous, fifo, sweep, multiqueue_fifo, priority, "
      "sampling, splash(splash_size), multiqueue_priority, set, "
      "clustered_priority(one of {metis,bfs,random}, vertices perpartition), "
      "round_robin, colored}");      
   // Parse the arguments
   try{
     boost_po::store(boost_po::command_line_parser(argc, argv).
                     options(desc).positional(pos_opts).run(), vm);
     boost_po::notify(vm);
   } catch( boost_po::error error) {
     std::cout << "Invalid syntax:\n" 
               << "\t" << error.what()
               << "\n\n" << std::endl 
               << "Description:"
               << std::endl;        
     print_description();
     return false;
   }
   if(vm.count("help")) {
     print_description();
     return false;
   }
   return true;
 } // end of parse
Example #6
0
bool WizardsTower::menu(Player *player)
{
    char choice;

    set_locationTitle("Wizards Tower");
    set_description("You stand before the colossus tower,\nyour hairs standing on end at the very thought of the\nmagical essences that radiate from this brick and motor\nplace is more homely than even the most bustling\ngiant which penetrates the very skyline and into the realm of the gods.\n\n");

    do
    {
        print_description();

        cout << "E: Arcane Enchanter Room\n";
        cout << "I: Rejuvenation Temple\n";
        cout << "G: Alchemist Chamber\n";
        cout << "L: Leave\n\n";
        cout << "Q: Quit Game\n\n";
        cout << "> ";

        cin >> choice;

        switch(choice)
        {
            case 'e':
            case 'E':
                //arcaneEnchanterRoom();
                return false;
                break;

            case 'r':
            case 'R':
                //rejuvenationtemple();
                return false;
                break;

            case 'a':
            case 'A':
                //alchemistchamber();
                return false;
                break;

            case 'l':
            case 'L':
                player->set_currentLocation("Devils Cross");
                return false;
                break;

            case 'q':
            case 'Q':
                return true;
                break;
        }

    } while (true);
}
Example #7
0
bool DarkWoods::menu(Player *player)
{
    char choice;

    set_locationTitle("Dark Woods");
    set_description("The woods hold a mysterious aura, that\nmakes you feel uncomfortable as you enter the dark\nlabyrinth of gnarled beast like trees and barbed grass\nblades. No one knows what resides in these woods,\nbut once inside you can never feel alone they say\n\n");

    do
    {
        print_description();

        cout << "S: Murky Swamp\n";
        cout << "C: Strange Cabin\n";
        cout << "O: Unusal Formation\n";
        cout << "L: Leave\n\n";
        cout << "Q: Quit Game\n\n";
        cout << "> ";

        cin >> choice;

        switch(choice)
        {
            case 's':
            case 'S':
                //murkyswamp();
                return false;
                break;

            case 'c':
            case 'C':
                //strangecabin();
                return false;
                break;

            case 'o':
            case 'O':
                //unusualformation();
                return false;
                break;

            case 'l':
            case 'L':
                player->set_currentLocation("Devils Cross");
                return false;
                break;

            case 'q':
            case 'Q':
                return true;
                break;
        }

    } while (true);
}
Example #8
0
bool DevilsCross::menu(Player *player)
{
    char choice;

    set_locationTitle("Devils Cross");
    set_description("you reach the beaten path of the devil's cross,\nwind beating you from all directions. You feel\nslightly overwhelmed at the vastness of it all\nas you look from North to South and back again,\ncontemplating where to go next.\n\n");

    do
    {
        print_description();

        cout << "N: North - Silvergate\n";
        cout << "S: South - The Arena\n";
        cout << "E: East - Dark Woods\n";
        cout << "W: West - The Wizard's Tower\n\n";
        cout << "Q: Quit Game\n\n";
        cout << "> ";

        cin >> choice;

        switch(choice)
        {
            case 'n':
            case 'N':
                player->set_currentLocation("Silvergate");
                return false;
                break;

            case 's':
            case 'S':
                player->set_currentLocation("Arena");
                return false;
                break;

            case 'e':
            case 'E':
                player->set_currentLocation("Dark Woods");
                return false;
                break;

            case 'w':
            case 'W':
                player->set_currentLocation("Wizards Tower");
                return false;
                break;

            case 'q':
            case 'Q':
                return true;
                break;
        }

    } while (true);
}
Example #9
0
void generate_rankings(struct urd_status *game)
{
	game->state.type = URD_RANKINGS;
	sprintf(game->state.description, 
			"You approach the board of rankings. There seems to\n"
			"be a sign written on top. Here's what it says:\n"
			"\t\"The dungeon is not yet open to the public,\n"
			"\t to all aspiring adventurers, hold your\n"
			"\t horses. You shall be notified before\n"
			"\t the official opening.\"\n"
			"\t\t\tSigned: The King.\n\n"
			"You give up and back off, you're obviously not ready\n"
			"yet.\n"
			"\tProceed.");
	print_description(game);
}
Example #10
0
File: zomlib.c Project: bgirard/ZOM
int main(int argc, char* argv[]) {

  register_implement();

  int i = 0; 

  if( argc >= 2 && strcmp(argv[1], "-description" )  == 0 ) {
    print_description();
    return 0;
  }

  if( argc >= 2 && strcmp(argv[1], "-complete" )  == 0 ) {
    int comp_argc = argc - 1;
    char** comp_argv =(char**) malloc( sizeof(char*) * comp_argc );
    comp_argv[0] = argv[0];
    for(i = 1; i < comp_argc; i++ ) {
      comp_argv[i] = argv[i+1];
    }

    get_complete(comp_argc, comp_argv);

    free(comp_argv);

    return 0;
  } else if( argc >= 2 && strcmp(argv[1], "help" )  == 0 ) {
    int comp_argc = argc - 1;
    char** comp_argv =(char**) malloc( sizeof(char*) * comp_argc );
    comp_argv[0] = argv[0];
    for(i = 1; i < comp_argc; i++ ) {
      comp_argv[i] = argv[i+1];
    }

    if( help_func != NULL ) {
      help_func(comp_argc, comp_argv);
    } else {
      printf("This command does not provide help\n");
    }

    free(comp_argv);

    return 0;
  }

  run_command(argc, argv);

  return 0;
}
Example #11
0
int main(int argc, char* argv[]) {
    try {
        google::ParseCommandLineFlags(&argc, &argv, true);
        if (FLAGS_h) {
            print_description();
            return 0;
        }
    } catch (...) {
        fprintf(stderr, "main params error\n");
        return -1;
    }
  
    wyr::WordCountLogger logger; 
    const char* dir = FLAGS_d.c_str();
    const char* file_j = FLAGS_j.c_str();
    if (!logger.init(dir, file_j)) {
       fprintf(stderr, "init log [%s/%s] failed\n", dir, file_j); 
       return -1;
    } 
    
    const char* file_i = FLAGS_i.c_str();
    if (-1 == wyr::wc_conf().load_conf(dir, file_i)) {
        WC_LOG_FATAL("load_conf(%s, %s) failed", dir, file_i);
        return -1;
    }

    wyr::Processor wc_processor;
    if (0 != wc_processor.init()) {
        WC_LOG_FATAL("processor init() failed");
        return -1;
    }
    if (0 != wc_processor.run_processor()) {
        WC_LOG_FATAL("processor run_processor() failed");
        return -1;
    }

    return 0;
}
int
main(int argc, char *argv[])
{
    int             arg;
    char           *current_name = NULL, *cp = NULL;
    oid             name[MAX_OID_LEN];
    size_t          name_length;
    int             description = 0;
    int             print = 0;
    int             find_all = 0;
    int             width = 1000000;

    /*
     * usage: snmptranslate name
     */
    while ((arg = getopt(argc, argv, "Vhm:M:w:D:P:T:O:I:L:")) != EOF) {
        switch (arg) {
        case 'h':
            usage();
            exit(1);

        case 'm':
            setenv("MIBS", optarg, 1);
            break;
        case 'M':
            setenv("MIBDIRS", optarg, 1);
            break;
        case 'D':
            debug_register_tokens(optarg);
            snmp_set_do_debugging(1);
            break;
        case 'V':
            fprintf(stderr, "NET-SNMP version: %s\n",
                    netsnmp_get_version());
            exit(0);
            break;
        case 'w':
	    width = atoi(optarg);
	    if (width <= 0) {
		fprintf(stderr, "Invalid width specification: %s\n", optarg);
		exit (1);
	    }
	    break;
#ifndef NETSNMP_DISABLE_MIB_LOADING
        case 'P':
            cp = snmp_mib_toggle_options(optarg);
            if (cp != NULL) {
                fprintf(stderr, "Unknown parser option to -P: %c.\n", *cp);
                usage();
                exit(1);
            }
            break;
#endif /* NETSNMP_DISABLE_MIB_LOADING */
        case 'O':
            cp = snmp_out_toggle_options(optarg);
            if (cp != NULL) {
                fprintf(stderr, "Unknown OID option to -O: %c.\n", *cp);
                usage();
                exit(1);
            }
            break;
        case 'I':
            cp = snmp_in_toggle_options(optarg);
            if (cp != NULL) {
                fprintf(stderr, "Unknown OID option to -I: %c.\n", *cp);
                usage();
                exit(1);
            }
            break;
        case 'T':
            for (cp = optarg; *cp; cp++) {
                switch (*cp) {
#ifndef NETSNMP_DISABLE_MIB_LOADING
                case 'l':
                    print = 3;
                    print_oid_report_enable_labeledoid();
                    break;
                case 'o':
                    print = 3;
                    print_oid_report_enable_oid();
                    break;
                case 's':
                    print = 3;
                    print_oid_report_enable_symbolic();
                    break;
                case 't':
                    print = 3;
                    print_oid_report_enable_suffix();
                    break;
                case 'z':
                    print = 3;
                    print_oid_report_enable_mibchildoid();
                    break;
#endif /* NETSNMP_DISABLE_MIB_LOADING */
                case 'd':
                    description = 1;
                    snmp_set_save_descriptions(1);
                    break;
                case 'B':
                    find_all = 1;
                    break;
                case 'p':
                    print = 1;
                    break;
                case 'a':
                    print = 2;
                    break;
                default:
                    fprintf(stderr, "Invalid -T<lostpad> character: %c\n",
                            *cp);
                    usage();
                    exit(1);
                    break;
                }
            }
            break;
        case 'L':
            if (snmp_log_options(optarg, argc, argv) < 0) {
                return (-1);
            }
            break;
        default:
            fprintf(stderr, "invalid option: -%c\n", arg);
            usage();
            exit(1);
            break;
        }
    }

    init_snmp("snmpapp");
    if (optind < argc)
        current_name = argv[optind];

    if (current_name == NULL) {
        switch (print) {
        default:
            usage();
            exit(1);
#ifndef NETSNMP_DISABLE_MIB_LOADING
        case 1:
            print_mib_tree(stdout, get_tree_head(), width);
            break;
        case 2:
            print_ascii_dump(stdout);
            break;
        case 3:
            print_oid_report(stdout);
            break;
#endif /* NETSNMP_DISABLE_MIB_LOADING */
        }
        exit(0);
    }

    do {
        name_length = MAX_OID_LEN;
        if (snmp_get_random_access()) {
#ifndef NETSNMP_DISABLE_MIB_LOADING
            if (!get_node(current_name, name, &name_length)) {
#endif /* NETSNMP_DISABLE_MIB_LOADING */
                fprintf(stderr, "Unknown object identifier: %s\n",
                        current_name);
                exit(2);
#ifndef NETSNMP_DISABLE_MIB_LOADING
            }
#endif /* NETSNMP_DISABLE_MIB_LOADING */
        } else if (find_all) {
            if (0 == show_all_matched_objects(stdout, current_name,
                                              name, &name_length,
                                              description, width)) {
                fprintf(stderr,
                        "Unable to find a matching object identifier for \"%s\"\n",
                        current_name);
                exit(1);
            }
            exit(0);
        } else if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, 
					  NETSNMP_DS_LIB_REGEX_ACCESS)) {
#ifndef NETSNMP_DISABLE_MIB_LOADING
            if (0 == get_wild_node(current_name, name, &name_length)) {
#endif /* NETSNMP_DISABLE_MIB_LOADING */
                fprintf(stderr,
                        "Unable to find a matching object identifier for \"%s\"\n",
                        current_name);
                exit(1);
#ifndef NETSNMP_DISABLE_MIB_LOADING
            }
#endif /* NETSNMP_DISABLE_MIB_LOADING */
        } else {
            if (!read_objid(current_name, name, &name_length)) {
                snmp_perror(current_name);
                exit(2);
            }
        }


        if (print == 1) {
#ifndef NETSNMP_DISABLE_MIB_LOADING
            struct tree    *tp;
            tp = get_tree(name, name_length, get_tree_head());
            if (tp == NULL) {
#endif /* NETSNMP_DISABLE_MIB_LOADING */
                snmp_log(LOG_ERR,
                        "Unable to find a matching object identifier for \"%s\"\n",
                        current_name);
                exit(1);
#ifndef NETSNMP_DISABLE_MIB_LOADING
            }
            print_mib_tree(stdout, tp, width);
#endif /* NETSNMP_DISABLE_MIB_LOADING */
        } else {
            print_objid(name, name_length);
            if (description) {
#ifndef NETSNMP_DISABLE_MIB_LOADING
                print_description(name, name_length, width);
#endif /* NETSNMP_DISABLE_MIB_LOADING */
            }
        }
        current_name = argv[++optind];
        if (current_name != NULL)
            printf("\n");
    } while (optind < argc);

    return (0);
}
int
main(int argc, char *argv[])
{
	int err, i;
	char *host=NULL;
	int port=7777;
	int nmixers=0;
	extern int mixlib_trace;
	int interactive=0;

	//mixlib_trace=1;

	while ((i = getopt(argc, argv, "ip:h:")) != EOF)
	switch (i)
	{
	case 'i':
		interactive=1;
		break;
	case 'p':
		port = atoi(optarg);
		break;

	case 'h':
		host=optarg;
		break;
	}

	if ((err=ossmix_init())<0)
	{
		fprintf(stderr, "ossmix_init() failed, err=%d\n");
		exit(EXIT_FAILURE);
	}

	if ((err=ossmix_connect(host, port))<0)
	{
		fprintf(stderr, "ossmix_connect() failed, err=%d\n", err);
		exit(EXIT_FAILURE);
	}

	if ((nmixers=ossmix_get_nmixers())<0)
	{
		fprintf(stderr, "ossmix_get_nmixers() failed, err=%d\n", nmixers);
		exit(EXIT_FAILURE);
	}

	printf("Number of mixers=%d\n", nmixers);

	for (i=0;i<nmixers;i++)
	{
		oss_mixerinfo mi;
		int n, ctl;

		if (ossmix_get_mixerinfo(i, &mi)<0)
		{
			fprintf(stderr, "ossmix_get_mixerinfo(%d) failed\n", i);
			exit(EXIT_FAILURE);
		}

		printf("Mixer %2d: %s\n", i, mi.name);

		if (ossmix_open_mixer(i)<0)
		{
			fprintf(stderr, "ossmix_open_mixer(%d) failed\n", i);
			exit(EXIT_FAILURE);
		}

		if ((n=ossmix_get_nrext(i))<0)
		{
			fprintf(stderr, "ossmix_get_nrext(%d) failed, err=\n", i, n);
			exit(EXIT_FAILURE);
		}

		printf("Mixer has %d nodes\n", n);

		for (ctl=0;ctl<n;ctl++)
		{
			oss_mixext node;
			int value=0;

			if (ossmix_get_nodeinfo(i, ctl, &node)<0)
			{
				fprintf(stderr, "ossmix_get_nodeinfo(%d, %d) failed\n",
						i, ctl);
				exit(EXIT_FAILURE);

			}

			if (node.type != MIXT_DEVROOT && node.type != MIXT_GROUP && node.type != MIXT_MARKER)
			if ((value=ossmix_get_value(i, ctl, node.timestamp))<0)
			{
				fprintf(stderr, "ossmix_get_value(%d, %d, %d) failed, err=%d\n",
						i, ctl, node.timestamp, value);
			}

			printf("%3d: %s = 0x%08x\n", ctl, node.extname, value);

			if (node.type == MIXT_ENUM)
			   print_enum_list(i, ctl);

			if (node.flags & MIXF_DESCR)
			   print_description(i, ctl);
			   
		}

		if (!interactive)
		   ossmix_close_mixer(i);
	}

	if (interactive)
	   interactive_mode();

printf("Disconnecting\n");
	ossmix_disconnect();

	exit(EXIT_SUCCESS);
}
Example #14
0
int main(int argc, char **argv)
{
  int not, bnot, error;
  int xdim, ydim;
  int topol, neigh;
  float alpha1, radius1;
  int fixed, weights;
  float alpha2, radius2;
  float qerror, qerrorb;
  char *in_data_file, *in_test_file, *out_code_file, *alpha_s;
  struct entries *data = NULL;
  struct entries *testdata = NULL;
  struct entries *codes = NULL;
  struct entries *codess = NULL;
  struct entries *tmp;
  struct teach_params params;
  long buffer, length1, length2, noc, nod;
  int qmode;
  struct typelist *type_tmp;

  error = 0;
  global_options(argc, argv);
  print_description();

  not = get_int("Give the number of trials", 0);
  in_data_file = get_str("Give the input data file name");
  in_test_file = get_str("Give the input test file name");
  out_code_file = get_str("Give the output map file name");

  topol = topol_type(get_str("Give the topology type"));
  if (topol == TOPOL_UNKNOWN) {
    ifverbose(2)
      fprintf(stderr, "Unknown topology type, using hexagonal\n");
    topol = TOPOL_HEXA;
  }
  neigh = neigh_type(get_str("Give the neighborhood type"));
  if (neigh == NEIGH_UNKNOWN) {
    ifverbose(2)
      fprintf(stderr, "Unknown neighborhood type, using bubble\n");
    neigh = NEIGH_BUBBLE;
  }

  xdim = get_int("Give the x-dimension", 0);
  ydim = get_int("Give the y-dimension", 0);

  length1 = get_int("Give the training length of first part", 0);
  alpha1 = get_float("Give the training rate of first part", 0.0);
  radius1 = get_float("Give the radius in first part", 0.0);
  length2 = get_int("Give the training length of second part", 0);
  alpha2 = get_float("Give the training rate of second part", 0.0);
  radius2 = get_float("Give the radius in second part", 0.0);

  printf("\n");

  fixed = (int) oatoi(extract_parameter(argc, argv, FIXPOINTS, OPTION), 0);
  weights = (int) oatoi(extract_parameter(argc, argv, WEIGHTS, OPTION), 0);
  buffer = oatoi(extract_parameter(argc, argv, "-buffer", OPTION), 0);
  alpha_s = extract_parameter(argc, argv, "-alpha_type", OPTION);
  qmode = oatoi(extract_parameter(argc, argv, "-qetype", OPTION), 0);

  use_fixed(fixed);
  use_weights(weights);

  label_not_needed(1);

  ifverbose(2)
    fprintf(stderr, "Input entries are read from file %s\n", in_data_file);
  data = open_entries(in_data_file);
  if (data == NULL)
    {
      fprintf(stderr, "Can't open data file '%s'\n", in_data_file);
      error = 1;
      goto end;
    }
  set_buffer(data, buffer);

  ifverbose(2)
    fprintf(stderr, "Test entries are read from file %s\n", in_test_file);
  testdata = open_entries(in_test_file);
  if (testdata == NULL)
    {
      fprintf(stderr, "Can't open test data file '%s'\n", in_test_file);
      error = 1;
      goto end;
    }
  set_buffer(testdata, buffer);

  noc = xdim * ydim;
  if (noc <= 0) 
    {
      fprintf(stderr, "Dimensions of map (%d %d) are incorrect\n", xdim, ydim);
      error = 1;
      goto end;
    }
  if (xdim < 0) 
    {
      fprintf(stderr, "Dimensions of map (%d %d) are incorrect\n", xdim, ydim);
      error = 1;
      goto end;
    }

  if (alpha_s)
    {
      type_tmp = get_type_by_str(alpha_list, alpha_s);
      if (type_tmp->data == NULL)
	{
	  fprintf(stderr, "Unknown alpha type %s\n", alpha_s);
	  error = 1;
	  goto end;
	}
    }
  else
    type_tmp = get_type_by_id(alpha_list, ALPHA_LINEAR);

  params.alpha_type = type_tmp->id;
  params.alpha_func = type_tmp->data;


  codess = NULL;
  qerrorb = FLT_MAX;
  bnot = 0;
  while (not) {
    init_random(not);

    ifverbose(2)
      fprintf(stderr, "Initializing codebook\n");
    
    codes = randinit_codes(data, topol, neigh, xdim, ydim);
    if (codes == NULL)
      {
	fprintf(stderr, "Error initializing random codebook, aborting\n");
	error = 1;
	goto end;
      }

    set_teach_params(&params, codes, NULL, 0);
    set_som_params(&params);
    params.data = data;
    
    params.length = length1;
    params.alpha = alpha1;
    params.radius = radius1;

    ifverbose(2)
      fprintf(stderr, "Training map, first part, rlen: %ld alpha: %f\n", 
	      params.length, params.alpha);
    codes = som_training(&params);

    params.length = length2;
    params.alpha = alpha2;
    params.radius = radius2;
    ifverbose(2)
      fprintf(stderr, "Training map, second part, rlen: %ld alpha: %f\n", 
	      params.length, params.alpha);
    codes = som_training(&params);

    params.data = testdata;
    ifverbose(2)
      fprintf(stderr, "Calculating quantization error\n");

    if (qmode > 0)
      qerror = find_qerror2(&params);
    else
      qerror = find_qerror(&params);
    nod = testdata->num_entries;

    if (qerror < qerrorb) {
      qerrorb = qerror;
      bnot = not;

      tmp = codess;
      codess = codes;
      codes = tmp;
    }

    close_entries(codes);
    codes = NULL;
    ifverbose(1)
      fprintf(stderr, "%3d: %f\n", not, qerror/(float) nod);
    not--;
  }

  if (codess != NULL) 
    {
      ifverbose(2)
	fprintf(stdout, "Codebook entries are saved to file %s\n", out_code_file);
      save_entries(codess, out_code_file);
      ifverbose(1)
	fprintf(stdout, "Smallest error with random seed %3d: %f\n",
                bnot, qerrorb/(float) nod);
    }

 end:
  if (codess)
    close_entries(codess);
  if (data)
    close_entries(data);
  if (testdata)
    close_entries(testdata);
  
  return(error);
}
Example #15
0
void print(char *const name, const size_t n, const int err_info) {
	print_description(global_hospital()->patients, name, n);
	print_err_info(err_info);
}
Example #16
0
static void
print_result (gpgme_verify_result_t result)
{
    gpgme_signature_t sig;
    gpgme_sig_notation_t nt;
    gpgme_tofu_info_t ti;
    int count = 0;

    printf ("Original file name: %s\n", nonnull(result->file_name));
    for (sig = result->signatures; sig; sig = sig->next)
    {
        printf ("Signature %d\n", count++);
        printf ("  status ....: %s\n", gpgme_strerror (sig->status));
        printf ("  summary ...:");
        print_summary (sig->summary);
        putchar ('\n');
        printf ("  fingerprint: %s\n", nonnull (sig->fpr));
        printf ("  created ...: %lu\n", sig->timestamp);
        printf ("  expires ...: %lu\n", sig->exp_timestamp);
        printf ("  validity ..: ");
        print_validity (sig->validity);
        putchar ('\n');
        printf ("  val.reason : %s\n", gpgme_strerror (sig->status));
        printf ("  pubkey algo: %d (%s)\n", sig->pubkey_algo,
                nonnull(gpgme_pubkey_algo_name (sig->pubkey_algo)));
        printf ("  digest algo: %d (%s)\n", sig->hash_algo,
                nonnull(gpgme_hash_algo_name (sig->hash_algo)));
        printf ("  pka address: %s\n", nonnull (sig->pka_address));
        printf ("  pka trust .: %s\n",
                sig->pka_trust == 0? "n/a" :
                sig->pka_trust == 1? "bad" :
                sig->pka_trust == 2? "okay": "RFU");
        printf ("  other flags:%s%s\n",
                sig->wrong_key_usage? " wrong-key-usage":"",
                sig->chain_model? " chain-model":""
               );
        for (nt = sig->notations; nt; nt = nt->next)
        {
            printf ("  notation ..: '%s'\n", nt->name);
            if (strlen (nt->name) != nt->name_len)
                printf ("    warning : name larger (%d)\n", nt->name_len);
            printf ("    flags ...:%s%s (0x%02x)\n",
                    nt->critical? " critical":"",
                    nt->human_readable? " human":"",
                    nt->flags);
            if (nt->value)
                printf ("    value ...: '%s'\n", nt->value);
            if ((nt->value?strlen (nt->value):0) != nt->value_len)
                printf ("    warning : value larger (%d)\n", nt->value_len);
        }
        for (ti = sig->tofu; ti; ti = ti->next)
        {
            printf ("  tofu addr .: %s\n", ti->address);
            if (!sig->fpr || strcmp (sig->fpr, ti->fpr))
                printf ("    WARNING .: fpr mismatch (%s)\n", ti->fpr);
            printf ("    validity : %u (%s)\n", ti->validity,
                    ti->validity == 0? "conflict" :
                    ti->validity == 1? "no history" :
                    ti->validity == 2? "little history" :
                    ti->validity == 3? "enough history" :
                    ti->validity == 4? "lot of history" : "?");
            printf ("    policy ..: %u (%s)\n", ti->policy,
                    ti->policy == GPGME_TOFU_POLICY_NONE? "none" :
                    ti->policy == GPGME_TOFU_POLICY_AUTO? "auto" :
                    ti->policy == GPGME_TOFU_POLICY_GOOD? "good" :
                    ti->policy == GPGME_TOFU_POLICY_UNKNOWN? "unknown" :
                    ti->policy == GPGME_TOFU_POLICY_BAD? "bad" :
                    ti->policy == GPGME_TOFU_POLICY_ASK? "ask" : "?");
            printf ("    sigcount : %hu\n", ti->signcount);
            printf ("    firstseen: %u\n", ti->firstseen);
            printf ("    lastseen : %u\n", ti->lastseen);
            printf ("    desc ....: ");
            print_description (nonnull (ti->description), 15);
        }
    }
}
Example #17
0
File: cspec.c Project: mumuki/cspec
 void __skip(String description, Function function) {
     PENDING_COUNT++;
     print_description(description, "", "  ", "", PENDING);
 }
Example #18
0
File: cspec.c Project: faloi/cspec
 void _cspec_skip(const char* description) {
     PENDING_SHOULDS++;
     print_description(description, " (WTF - SKIPPED)", "  ", PENDING);
 }
Example #19
0
File: cspec.c Project: faloi/cspec
 void _cspec_describe_pre(const char* description) {
     if (DESCRIBE_DEEP_LEVEL == 0) puts("");
     DESCRIBE_DEEP_LEVEL++;
     print_description(description, "", "", DESCRIBE);
 }