void FileParser::parse(const std::string& filename) { std::ifstream file(filename); if (file.good()) { // Refactor this part. It should not rely on order std::string line; std::getline(file, line); _parse_format(line); std::getline(file, line); if (0 == _parse_name(line)) { name = "Placeholder Game"; } std::getline(file, line); if (0 == _parse_conditions(line)) { needed_to_live.push_back(2); needed_to_live.push_back(3); needed_to_born.push_back(3); } // It works fine, but looks like it from 80's int x, y; int x_min = 0; int x_max = 0; int y_min = 0; int y_max = 0; std::pair<int, int> pair; while (file >> x >> y) { if (x > x_max) x_max = x; if (x < x_min) x_min = x; if (y > y_max) y_max = y; if (y < y_min) y_min = y; pair.first = x; pair.second = y; points.push_back(pair); } // Calculating shift int delta = 0; if (x_min < y_min && x_min < 0) { delta = x_min; } else if (y_min < 0) { delta = y_min; } if (0 != delta) { for (auto& pair : points) { pair.first -= delta; // because delta < 0 pair.second -= delta; } } x_max -= delta; y_max -= delta; x_max > y_max ? field_size = x_max + 3 : field_size = y_max + 3; } else {
/* * parse_command_line, fill in params data structure with data */ extern void parse_command_line(int argc, char *argv[]) { char *env_val = NULL; int opt_char; int option_index; hostlist_t host_list; static struct option long_options[] = { {"all", no_argument, 0, 'a'}, {"bg", no_argument, 0, 'b'}, {"dead", no_argument, 0, 'd'}, {"exact", no_argument, 0, 'e'}, {"noheader", no_argument, 0, 'h'}, {"iterate", required_argument, 0, 'i'}, {"long", no_argument, 0, 'l'}, {"cluster", required_argument, 0, 'M'}, {"clusters", required_argument, 0, 'M'}, {"nodes", required_argument, 0, 'n'}, {"Node", no_argument, 0, 'N'}, {"format", required_argument, 0, 'o'}, {"partition", required_argument, 0, 'p'}, {"responding",no_argument, 0, 'r'}, {"list-reasons", no_argument, 0, 'R'}, {"summarize", no_argument, 0, 's'}, {"sort", required_argument, 0, 'S'}, {"states", required_argument, 0, 't'}, {"reservation",no_argument, 0, 'T'}, {"verbose", no_argument, 0, 'v'}, {"version", no_argument, 0, 'V'}, {"help", no_argument, 0, OPT_LONG_HELP}, {"usage", no_argument, 0, OPT_LONG_USAGE}, {"hide", no_argument, 0, OPT_LONG_HIDE}, {NULL, 0, 0, 0} }; if (getenv("SINFO_ALL")) params.all_flag = true; if ( ( env_val = getenv("SINFO_PARTITION") ) ) { params.partition = xstrdup(env_val); params.all_flag = true; } if ( ( env_val = getenv("SINFO_SORT") ) ) params.sort = xstrdup(env_val); if ( ( env_val = getenv("SLURM_CLUSTERS") ) ) { if (!(params.clusters = slurmdb_get_info_cluster(env_val))) { error("'%s' can't be reached now, " "or it is an invalid entry for " "SLURM_CLUSTERS. Use 'sacctmgr --list " "cluster' to see available clusters.", env_val); exit(1); } working_cluster_rec = list_peek(params.clusters); } while((opt_char = getopt_long(argc, argv, "abdehi:lM:n:No:p:rRsS:t:TvV", long_options, &option_index)) != -1) { switch (opt_char) { case (int)'?': fprintf(stderr, "Try \"sinfo --help\" for more information\n"); exit(1); break; case (int)'a': params.all_flag = true; break; case (int)'b': params.cluster_flags = slurmdb_setup_cluster_flags(); if (params.cluster_flags & CLUSTER_FLAG_BG) params.bg_flag = true; else { error("Must be on a BG system to use --bg " "option, if using --cluster option " "put the --bg option " "after the --cluster option."); exit(1); } break; case (int)'d': params.dead_nodes = true; break; case (int)'e': params.exact_match = true; break; case (int)'h': params.no_header = true; break; case (int) 'i': params.iterate= atoi(optarg); if (params.iterate <= 0) { error ("Error: invalid entry for " "--iterate=%s", optarg); exit(1); } break; case (int) 'l': params.long_output = true; break; case (int) 'M': if (params.clusters) list_destroy(params.clusters); if (!(params.clusters = slurmdb_get_info_cluster(optarg))) { error("'%s' can't be reached now, " "or it is an invalid entry for " "--cluster. Use 'sacctmgr --list " "cluster' to see available clusters.", optarg); exit(1); } working_cluster_rec = list_peek(params.clusters); break; case (int) 'n': xfree(params.nodes); params.nodes = xstrdup(optarg); /* * confirm valid nodelist entry */ host_list = hostlist_create(params.nodes); if (!host_list) { error("'%s' invalid entry for --nodes", optarg); exit(1); } if (hostlist_count(host_list) == 1) params.node_name_single = true; else params.node_name_single = false; hostlist_destroy(host_list); break; case (int) 'N': params.node_flag = true; break; case (int) 'o': xfree(params.format); params.format = xstrdup(optarg); break; case (int) 'p': xfree(params.partition); params.partition = xstrdup(optarg); params.all_flag = true; break; case (int) 'r': params.responding_nodes = true; break; case (int) 'R': params.list_reasons = true; break; case (int) 's': params.summarize = true; break; case (int) 'S': xfree(params.sort); params.sort = xstrdup(optarg); break; case (int) 't': xfree(params.states); params.states = xstrdup(optarg); if (!(params.state_list = _build_state_list(optarg))) { error ("valid states: %s", _node_state_list ()); exit (1); } break; case (int) 'T': params.reservation_flag = true; break; case (int) 'v': params.verbose++; break; case (int) 'V': print_slurm_version (); exit(0); case (int) OPT_LONG_HELP: _help(); exit(0); case (int) OPT_LONG_USAGE: _usage(); exit(0); case OPT_LONG_HIDE: params.all_flag = false; break; } } params.cluster_flags = slurmdb_setup_cluster_flags(); if ( params.format == NULL ) { if ( params.summarize ) { params.part_field_flag = true; /* compute size later */ if (params.cluster_flags & CLUSTER_FLAG_BG) params.format = "%9P %.5a %.10l %.32F %N"; else params.format = "%9P %.5a %.10l %.16F %N"; } else if ( params.node_flag ) { params.node_field_flag = true; /* compute size later */ params.part_field_flag = true; /* compute size later */ params.format = params.long_output ? "%N %.6D %.9P %.11T %.4c %.8z %.6m %.8d %.6w %.8f %20E" : "%N %.6D %.9P %6t"; } else if (params.list_reasons) { params.format = params.long_output ? "%20E %12U %19H %6t %N" : "%20E %9u %19H %N"; } else if ((env_val = getenv ("SINFO_FORMAT"))) { params.format = xstrdup(env_val); } else { params.part_field_flag = true; /* compute size later */ params.format = params.long_output ? "%9P %.5a %.10l %.10s %.4r %.5h %.10g %.6D %.11T %N" : "%9P %.5a %.10l %.6D %.6t %N"; } } _parse_format( params.format ); if (params.list_reasons && (params.state_list == NULL)) { params.states = xstrdup ("down,drain,error"); if (!(params.state_list = _build_state_list (params.states))) fatal ("Unable to build state list for -R!"); } if (params.dead_nodes || params.nodes || params.partition || params.responding_nodes ||params.state_list) params.filtering = true; if (params.verbose) _print_options(); }
static int _parse_long_format (char* format_long) { int field_size; bool right_justify, format_all = false; char *tmp_format = NULL, *token = NULL, *str_tmp = NULL; char *sep = NULL; char* suffix = NULL; if (format_long == NULL) { error("Format long option lacks specification"); exit( 1 ); } params.format_list = list_create(NULL); tmp_format = xstrdup(format_long); token = strtok_r(tmp_format, ",",&str_tmp); while (token) { _parse_long_token( token, sep, &field_size, &right_justify, &suffix); if (!xstrcasecmp(token, "all")) { _parse_format ("%all"); } else if (!xstrcasecmp(token, "allocmem")) { params.match_flags.alloc_mem_flag = true; format_add_alloc_mem( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "allocnodes")) { format_add_alloc_nodes( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "available")) { params.match_flags.avail_flag = true; format_add_avail( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "cluster")) { format_add_cluster_name(params.format_list, field_size, right_justify, suffix); } else if (!xstrcasecmp(token, "cpus")) { params.match_flags.cpus_flag = true; format_add_cpus( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "cpusload")) { params.match_flags.cpu_load_flag = true; format_add_cpu_load( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "freemem")) { params.match_flags.free_mem_flag = true; format_add_free_mem( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "cpusstate")) { params.match_flags.cpus_flag = true; format_add_cpus_aiot( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "cores")) { params.match_flags.cores_flag = true; format_add_cores( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "defaulttime")) { params.match_flags.default_time_flag = true; format_add_default_time( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "disk")) { params.match_flags.disk_flag = true; format_add_disk( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "features")) { params.match_flags.features_flag = true; format_add_features( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "features_act")) { params.match_flags.features_act_flag = true; format_add_features_act( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "groups")) { params.match_flags.groups_flag = true; format_add_groups( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "gres")) { params.match_flags.gres_flag = true; format_add_gres( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "maxcpuspernode")) { params.match_flags.max_cpus_per_node_flag = true; format_add_max_cpus_per_node( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "memory")) { params.match_flags.memory_flag = true; format_add_memory( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "nodes")) { format_add_nodes( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "nodeaddr")) { params.match_flags.node_addr_flag = true; format_add_node_address( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "nodeai")) { format_add_nodes_ai( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "nodeaiot")) { format_add_nodes_aiot( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "nodehost")) { params.match_flags.hostnames_flag = true; format_add_node_hostnames( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "nodelist")) { format_add_node_list( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "partition")) { params.match_flags.partition_flag = true; format_add_partition( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "partitionname")) { params.match_flags.partition_flag = true; format_add_partition_name( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "port")) { params.match_flags.port_flag = true; format_add_port( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "preemptmode")) { params.match_flags.preempt_mode_flag = true; format_add_preempt_mode( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "priorityjobfactor")) { params.match_flags.priority_job_factor_flag = true; format_add_priority_job_factor(params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "prioritytier")) { params.match_flags.priority_tier_flag = true; format_add_priority_tier(params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "reason")) { params.match_flags.reason_flag = true; format_add_reason( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "root")) { params.match_flags.root_flag = true; format_add_root( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "oversubscribe") || !xstrcasecmp(token, "share")) { params.match_flags.oversubscribe_flag = true; format_add_oversubscribe( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "size")) { params.match_flags.job_size_flag = true; format_add_size( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "statecompact")) { params.match_flags.state_flag = true; format_add_state_compact( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "statelong")) { params.match_flags.state_flag = true; format_add_state_long( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "sockets")) { params.match_flags.sockets_flag = true; format_add_sockets( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "socketcorethread")) { params.match_flags.sct_flag = true; format_add_sct( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "time")) { params.match_flags.max_time_flag = true; format_add_time( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "timestamp")) { params.match_flags.reason_timestamp_flag = true; format_add_timestamp( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "threads")) { params.match_flags.threads_flag = true; format_add_threads( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "user")) { params.match_flags.reason_user_flag = true; format_add_user( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "userlong")) { params.match_flags.reason_user_flag = true; format_add_user_long( params.format_list, field_size, right_justify, suffix ); } else if (!xstrcasecmp(token, "version")) { params.match_flags.version_flag = true; format_add_version( params.format_list, field_size, right_justify, suffix); } else if (!xstrcasecmp(token, "weight")) { params.match_flags.weight_flag = true; format_add_weight( params.format_list, field_size, right_justify, suffix ); } else if (format_all) { /* ignore */ } else { format_add_invalid( params.format_list, field_size, right_justify, suffix ); error( "Invalid job format specification: %s", token ); } token = strtok_r(NULL, ",", &str_tmp); } xfree(tmp_format); return SLURM_SUCCESS; }
/* * parse_command_line, fill in params data structure with data */ extern void parse_command_line(int argc, char **argv) { char *env_val = NULL; int opt_char; int option_index; hostlist_t host_list; bool long_form = false; bool opt_a_set = false, opt_p_set = false; bool env_a_set = false, env_p_set = false; static struct option long_options[] = { {"all", no_argument, 0, 'a'}, {"bg", no_argument, 0, 'b'}, {"dead", no_argument, 0, 'd'}, {"exact", no_argument, 0, 'e'}, {"federation",no_argument, 0, OPT_LONG_FEDR}, {"help", no_argument, 0, OPT_LONG_HELP}, {"hide", no_argument, 0, OPT_LONG_HIDE}, {"iterate", required_argument, 0, 'i'}, {"local", no_argument, 0, OPT_LONG_LOCAL}, {"long", no_argument, 0, 'l'}, {"cluster", required_argument, 0, 'M'}, {"clusters", required_argument, 0, 'M'}, {"nodes", required_argument, 0, 'n'}, {"noconvert", no_argument, 0, OPT_LONG_NOCONVERT}, {"noheader", no_argument, 0, 'h'}, {"Node", no_argument, 0, 'N'}, {"format", required_argument, 0, 'o'}, {"Format", required_argument, 0, 'O'}, {"partition", required_argument, 0, 'p'}, {"responding",no_argument, 0, 'r'}, {"list-reasons", no_argument, 0, 'R'}, {"summarize", no_argument, 0, 's'}, {"sort", required_argument, 0, 'S'}, {"states", required_argument, 0, 't'}, {"reservation",no_argument, 0, 'T'}, {"usage", no_argument, 0, OPT_LONG_USAGE}, {"verbose", no_argument, 0, 'v'}, {"version", no_argument, 0, 'V'}, {NULL, 0, 0, 0} }; params.convert_flags = CONVERT_NUM_UNIT_EXACT; if (slurmctld_conf.fed_params && strstr(slurmctld_conf.fed_params, "fed_display")) params.federation_flag = true; if (getenv("SINFO_ALL")) { env_a_set = true; params.all_flag = true; } if (getenv("SINFO_FEDERATION")) params.federation_flag = true; if (getenv("SINFO_LOCAL")) params.local = true; if ( ( env_val = getenv("SINFO_PARTITION") ) ) { env_p_set = true; params.partition = xstrdup(env_val); params.part_list = _build_part_list(env_val); params.all_flag = true; } if (env_a_set && env_p_set) { error("Conflicting options, SINFO_ALL and SINFO_PARTITION, specified. " "Please choose one or the other."); exit(1); } if ( ( env_val = getenv("SINFO_SORT") ) ) params.sort = xstrdup(env_val); if ( ( env_val = getenv("SLURM_CLUSTERS") ) ) { if (!(params.clusters = slurmdb_get_info_cluster(env_val))) { print_db_notok(env_val, 1); exit(1); } working_cluster_rec = list_peek(params.clusters); params.local = true; } while ((opt_char = getopt_long(argc, argv, "abdehi:lM:n:No:O:p:rRsS:t:TvV", long_options, &option_index)) != -1) { switch (opt_char) { case (int)'?': fprintf(stderr, "Try \"sinfo --help\" for more information\n"); exit(1); break; case (int)'a': opt_a_set = true; xfree(params.partition); FREE_NULL_LIST(params.part_list); params.all_flag = true; break; case (int)'b': params.cluster_flags = slurmdb_setup_cluster_flags(); if (params.cluster_flags & CLUSTER_FLAG_BG) params.bg_flag = true; else { error("Must be on a BG system to use --bg " "option, if using --cluster option " "put the --bg option " "after the --cluster option."); exit(1); } break; case (int)'d': params.dead_nodes = true; break; case (int)'e': params.exact_match = true; break; case (int)'h': params.no_header = true; break; case (int) 'i': params.iterate= atoi(optarg); if (params.iterate <= 0) { error ("Error: invalid entry for " "--iterate=%s", optarg); exit(1); } break; case (int) 'l': params.long_output = true; break; case (int) 'M': FREE_NULL_LIST(params.clusters); if (!(params.clusters = slurmdb_get_info_cluster(optarg))) { print_db_notok(optarg, 0); exit(1); } working_cluster_rec = list_peek(params.clusters); params.local = true; break; case OPT_LONG_NOCONVERT: params.convert_flags |= CONVERT_NUM_UNIT_NO; break; case (int) 'n': xfree(params.nodes); params.nodes = xstrdup(optarg); /* * confirm valid nodelist entry */ host_list = hostlist_create(params.nodes); if (!host_list) { error("'%s' invalid entry for --nodes", optarg); exit(1); } if (hostlist_count(host_list) == 1) { params.node_name_single = true; xfree(params.nodes); params.nodes = hostlist_deranged_string_xmalloc(host_list); } else params.node_name_single = false; hostlist_destroy(host_list); break; case (int) 'N': params.node_flag = true; break; case (int) 'o': xfree(params.format); params.format = xstrdup(optarg); break; case (int) 'O': long_form = true; xfree(params.format); params.format = xstrdup(optarg); break; case (int) 'p': opt_p_set = true; xfree(params.partition); FREE_NULL_LIST(params.part_list); params.partition = xstrdup(optarg); params.part_list = _build_part_list(optarg); params.all_flag = true; break; case (int) 'r': params.responding_nodes = true; break; case (int) 'R': params.list_reasons = true; break; case (int) 's': params.summarize = true; break; case (int) 'S': xfree(params.sort); params.sort = xstrdup(optarg); break; case (int) 't': xfree(params.states); params.states = xstrdup(optarg); if (!(params.state_list = _build_state_list(optarg))) { error ("valid states: %s", _node_state_list ()); exit (1); } break; case (int) 'T': params.reservation_flag = true; break; case (int) 'v': params.verbose++; break; case (int) 'V': print_slurm_version (); exit(0); case (int) OPT_LONG_FEDR: params.federation_flag = true; break; case (int) OPT_LONG_HELP: _help(); exit(0); case (int) OPT_LONG_USAGE: _usage(); exit(0); case OPT_LONG_HIDE: params.all_flag = false; break; case OPT_LONG_LOCAL: params.local = true; break; } } if (opt_a_set && opt_p_set) { error("Conflicting options, -a and -p, specified. " "Please choose one or the other."); exit(1); } params.cluster_flags = slurmdb_setup_cluster_flags(); if (params.federation_flag && !params.clusters && !params.local) { void *ptr = NULL; char *cluster_name = slurm_get_cluster_name(); if (slurm_load_federation(&ptr) || !cluster_in_federation(ptr, cluster_name)) { /* Not in federation */ params.local = true; slurm_destroy_federation_rec(ptr); } else { params.fed = (slurmdb_federation_rec_t *) ptr; } xfree(cluster_name); } if ( params.format == NULL ) { if ( params.summarize ) { params.part_field_flag = true; /* compute size later */ if (params.cluster_flags & CLUSTER_FLAG_BG) params.format = "%9P %.5a %.10l %.32F %N"; else params.format = "%9P %.5a %.10l %.16F %N"; } else if ( params.node_flag ) { params.node_field_flag = true; /* compute size later */ params.part_field_flag = true; /* compute size later */ params.format = params.long_output ? "%N %.6D %.9P %.11T %.4c %.8z %.6m %.8d %.6w %.8f %20E" : "%N %.6D %.9P %6t"; } else if (params.list_reasons) { params.format = params.long_output ? "%20E %12U %19H %6t %N" : "%20E %9u %19H %N"; } else if ((env_val = getenv ("SINFO_FORMAT"))) { params.format = xstrdup(env_val); } else if (params.fed) { params.part_field_flag = true; /* compute size later */ params.format = params.long_output ? "%9P %8V %.5a %.10l %.10s %.4r %.8h %.10g %.6D %.11T %N" : "%9P %8V %.5a %.10l %.6D %.6t %N"; } else { params.part_field_flag = true; /* compute size later */ params.format = params.long_output ? "%9P %.5a %.10l %.10s %.4r %.8h %.10g %.6D %.11T %N" : "%9P %.5a %.10l %.6D %.6t %N"; } } if (long_form) _parse_long_format(params.format); else _parse_format(params.format); if (params.list_reasons && (params.state_list == NULL)) { params.states = xstrdup ("down,drain,error"); if (!(params.state_list = _build_state_list (params.states))) fatal ("Unable to build state list for -R!"); } if (params.dead_nodes || params.nodes || params.partition || params.responding_nodes ||params.state_list) params.filtering = true; if (params.verbose) _print_options(); }
int _doprnt(const char* formatString, va_list args, FuncT func, FargT farg) { const char *cp = formatString; FormatT format = { NULL, 0,0,0,0,0, "", "", "", ModFlag_None, kNone, 0, false, false, false, false, false }; int outsize=0; format.args = args; while (*cp != '\0') { if (*cp != '%') { (*func)(farg, *cp++); outsize+=1; } else { cp++; cp = _parse_format(cp, &format); switch (format.fcode) { case 'd': case 'u': case 'i': outsize+=_print_fixed(&format, 5, func, farg); break; case 'o': outsize+=_print_fixed(&format, 4, func, farg); break; case 'p': case 'X': case 'x': outsize+=_print_fixed(&format, 8, func, farg); break; #if defined(__FIXED_POINT_ALLOWED) case 'r': case 'R': #if !defined(__FX_NO_ACCUM) case 'k': case 'K': #endif /* __FX_NO_ACCUM */ #ifdef _ADI_FX_LIBIO outsize+=print_fx(&format, func, farg); #else format.precision = -1; outsize+=_print_fixed(&format, 8, func, farg); #endif /* _ADI_FX_LIBIO */ break; #endif /* __FIXED_POINT_ALLOWED */ case 'A': case 'a': outsize+=_print_a_float(&format, func, farg); break; case 'G': case 'g': case 'e': case 'E': case 'f': case 'F': outsize+=_print_float(&format, func, farg); break; case 'c': { char ch = FETCH((&format), int); if ( format.width>0 ) { char chbuf[2]; chbuf[0] = ch; chbuf[1] = '\0'; format.buffer = chbuf; outsize += _do_output(&format,func,farg); } else { (*func)(farg, ch); outsize+=1; } } break; case 'n': { void* ptr; ptr = FETCH((&format), void*); if (format.modFlag == ModFlag_l) { *((long *) ptr) = outsize; } else #if _LONG_LONG && !defined(__LIBIO_LITE) if (format.modFlag == ModFlag_ll) { *((long long *) ptr) = outsize; } else #endif if (format.modFlag == ModFlag_h) { *((short *) ptr) = outsize; } else { *((int *) ptr) = outsize; } } break; case 's': { char* s; s = FETCH((&format), char*); if (s == NULL) s = "(null)"; format.buffer=s; if ((format.width==0) && (format.precision<0)) { /* Faster route for "%s" */ format.precision = strlen(s); _put_string( func,farg,s,format.precision ); outsize+=format.precision; } else { /* Standard route for * "%[flags][width].[precision]s" */ outsize+=_do_output( &format,func,farg ); } } break; case '\0': /* Premature end of format string */ cp--; break; default: /* case '%': */ (*func)(farg, format.fcode); outsize+=1; break; } } } return outsize; }