// funcion auxiliar de validate, tambien implementada en assembly void write_error(int tipo_de_error, char* tag1, char* tag2, int nro_linea, char** errmsg) { size_t size = ERRMSG + calcular_largo(tag1) + calcular_largo(tag2); (*errmsg) = (char*)malloc(sizeof(char)*size); (*errmsg)[size-1]='\0'; switch (tipo_de_error) { case 1: sprintf(*errmsg, "es tag sin abrir - nro de linea: %d - tag: ", nro_linea); print_tag(tag2, errmsg); break; case 2: sprintf(*errmsg, "es tag mal anidado - nro de linea: %d - tags: ", nro_linea); print_tag(tag1, errmsg); int tam = strlen(*errmsg); (*errmsg)[tam] = ' '; (*errmsg)[tam+1] = 'y'; (*errmsg)[tam+2] = ' '; (*errmsg)[tam+3] = '\0'; print_tag(tag2, errmsg); break; case 3: sprintf(*errmsg, "hay tags sin cerrar - nro de linea: %d - tag: ", nro_linea); print_tag(tag1, errmsg); break; default: break; } }
void test_tags() { struct tag t; char test[2048]; strcpy(test,"<tag type=tab col=30>"); (void) read_tag(test, &t); print_tag(stdout, &t); printf("\ntype=%s\n", get_key_value(&t,"type")); strcpy(test,"<tag type=name name=\"Hebekiah the Jesuit\">"); (void) read_tag(test, &t); print_tag(stdout, &t); printf("\nname=%s\n", get_key_value(&t,"name")); };
int main(int argc, char **argv) { const char *decoder_name, *path; const struct decoder_plugin *plugin; struct tag *tag; bool empty; if (argc != 3) { g_printerr("Usage: read_tags DECODER FILE\n"); return 1; } decoder_name = argv[1]; path = argv[2]; input_stream_global_init(); decoder_plugin_init_all(); plugin = decoder_plugin_from_name(decoder_name); if (plugin == NULL) { g_printerr("No such decoder: %s\n", decoder_name); return 1; } tag = decoder_plugin_tag_dup(plugin, path); decoder_plugin_deinit_all(); input_stream_global_finish(); if (tag == NULL) { g_printerr("Failed to read tags\n"); return 1; } print_tag(tag); empty = tag_is_empty(tag); tag_free(tag); if (empty) { tag = tag_ape_load(path); if (tag == NULL) tag = tag_id3_load(path); if (tag != NULL) { print_tag(tag); tag_free(tag); } } return 0; }
void main() { int tag; //stores the RFID ID tag number float dist; int ovf = 0; int count = 0; store(); if (init()) pm2_pstr("System Checksum Successful!\r\n"); startup_message(); //rfid read printf_fast("Present RFID Tag"); pm2_pstr("Please Present Allowable RFID Tag\r\n"); tag = check_RFID(); pm2_pint16u(tag); pm2_pstr(" = "); print_tag(tag); //prints the name of the tag, which is matched to the number being sent pm2_pstr(" RFID tag was detected\r\nNow Starting Central Operational Loop\r\n"); lcd_home(); lcd_clear(); gps_to_xbee(1); //Enable GPS->Xbee //Central Operational loop CCL while(1) { dist = getdist_Maxbot(); inchtolcd(dist); //printf("hello\r\n"); pm2_pint16u(dist); pm2_pstr("\"\r\n"); if(((int)dist) < 26) { EMICinit(7, 4, 0); EMICspeak('S'); EMICspeak('t'); EMICspeak('o'); EMICspeak('p'); EMICnull(); } } }
void print_gsub_gpos_info (OTF *otf, char *table) { int i, j; if (OTF_get_table (otf, table) == 0) { OTF_ScriptList *scripts; OTF_FeatureList *features; if (! strcmp (table, "GSUB")) scripts = &otf->gsub->ScriptList, features = &otf->gsub->FeatureList; else scripts = &otf->gpos->ScriptList, features = &otf->gpos->FeatureList; printf (" %s scripts: ", table); for (i = 0; i < scripts->ScriptCount; i++) { OTF_Script *script = scripts->Script + i; if (i > 0) printf (", "); print_tag (script->ScriptTag); if (script->LangSysCount > 0) { printf (" ("); for (j = 0; j < script->LangSysCount; j++) { if (j > 0) printf (", "); print_tag (script->LangSysRecord[j].LangSysTag); } printf (")"); } } printf ("\n"); printf (" %s features: ", table); for (i = 0; i < features->FeatureCount; i++) { if (i > 0) printf (","); print_tag (features->Feature[i].FeatureTag); } printf ("\n"); } }
static void logger_write_stderr(LOG_PROPERTIES_T *pLogProperties, int sev, const char *msg, va_list *pvlist) { struct tm *ptm = NULL; //const char *tag = NULL; char strtmp[64]; time_t tmNow; if(!(pLogProperties->g_log_flags & LOG_FLAG_USESTDERR) || sev == 0 || (sev > 0 && sev > pLogProperties->g_log_level_stderr) || (sev < 0 && sev < (-1 * pLogProperties->g_log_level_stderr))) { return; } if((pLogProperties->g_log_flags & LOG_OUTPUT_PRINT_DATE_STDERR)) { tmNow = time(NULL); if((ptm = (struct tm *) localtime(&tmNow)) != NULL) { strftime(strtmp, sizeof(strtmp) -1, "%b %d %H:%M:%S ", ptm); strtmp[sizeof(strtmp) - 1] = '\0'; fprintf(stderr, "%s ", strtmp); } } // // If we're also printing to a file, don't also show the thread-id / thread-tag info to stderr // if(!(pLogProperties->g_log_flags & LOG_FLAG_USEFILEOUTPUT)) { strtmp[0] = '\0'; print_tag(pLogProperties, strtmp, sizeof(strtmp)); if(strtmp[0] != '\0') { fprintf(stderr, "%s ", strtmp); } } if((pLogProperties->g_log_flags & LOG_OUTPUT_PRINT_SEV) || ((pLogProperties->g_log_flags & LOG_OUTPUT_PRINT_SEV_ERROR) && sev <= S_ERROR)) { fprintf(stderr, "%s ", logger_getSeverityStr((unsigned short) sev)); } // Log to stderr vfprintf(stderr, msg, *pvlist); // flush output if(pLogProperties->g_log_flags & LOG_FLAG_FLUSHOUTPUT) { fflush(stderr); } return; }
static void print_fields(record_t *record) { int offset; symbol_t *symbol; printf(" { "); for (offset = 0; offset < record->count; offset++) { symbol = record->vector[offset]; print_tag(symbol->tag, symbol->name); printf(" ; "); } putchar('}'); }
/* * Print menu item */ static void print_item(WINDOW *win, char **items, int choice, int selected) { int n; int my_width = menu_width; int my_x = item_x; int my_y = ItemToRow(choice); chtype attr = A_NORMAL; if (items == 0) return; /* Clear 'residue' of last item and mark current current item */ if (dialog_vars.input_menu) { wattrset(win, selected ? item_selected_attr : item_attr); for (n = my_y - 1; n < my_y + INPUT_ROWS - 1; n++) { wmove(win, n, 0); wprintw(win, "%*s", my_width, " "); } } else { wattrset(win, menubox_attr); wmove(win, my_y, 0); wprintw(win, "%*s", my_width, " "); } print_tag(win, items, choice, selected); /* Draw the input field box (only for inputmenu) */ (void) wmove(win, my_y, my_x); if (dialog_vars.input_menu) { my_width -= 1; draw_box(win, my_y - 1, my_x, INPUT_ROWS, my_width - my_x - tag_x, selected ? item_selected_attr : item_attr, selected ? item_selected_attr : item_attr); my_width -= 1; ++my_x; } /* print actual item */ wmove(win, my_y, my_x); wattrset(win, selected ? item_selected_attr : item_attr); dlg_print_text(win, ItemText(0), my_width - my_x, &attr); if (selected) { dlg_item_help(ItemHelp(0)); } }
static void print_directory(GHashTable *dir) { int count = g_hash_table_size(dir); struct hash_key_helper h = { 0, g_new(int, count) }; g_hash_table_foreach(dir, save_key, &h); qsort(h.tags, count, sizeof (int), int_compare); for (int i = 0; i < count; i++) { int tag = h.tags[i]; print_tag(tag, (struct _openslide_tiffdump_item *) g_hash_table_lookup(dir, &tag)); } g_free(h.tags); printf("\n"); }
static char * input_menu_edit(WINDOW *win, char **items, int choice) { char *result; int offset = 0; int key = 0, fkey; int first = TRUE; /* see above */ int y = ItemToRow(choice); result = malloc(dialog_vars.max_input); assert_ptr(result, "input_menu_edit"); dialog_vars.max_input = dialog_vars.max_input; /* original item is used to initialize the input string. */ result[0] = '\0'; strcpy(result, ItemText(0)); print_tag(win, items, choice, TRUE); /* taken out of inputbox.c - but somewhat modified */ while (key != '\n' && key != '\r') { if (!first) key = mouse_wgetch(win, &fkey); if (dlg_edit_string(result, &offset, key, fkey, first)) { /* * menu_width - 2 ..... it's the actual number of maximal * possible characters could be written * to the screen. * * item_x - tag_x - 2 . same as "name_width" * ( see in dialog_menu() ) */ dlg_show_string(win, result, offset, item_selected_attr, y, item_x + 1, menu_width - item_x - 3, FALSE, first); first = FALSE; } } return result; }
int com_print(char* arg) { char* a = strtok(arg, " "); if (a && strtok(NULL, " ") != (char*)NULL) { printf("Too many arguments\n"); return -1; } mf_size_t size = parse_size_default(a, MF_1K); if (size == MF_INVALID_SIZE) { printf("Unknown argument: %s\n", a); return -1; } print_tag(size); return 0; }
/** Tag listing: Lookup tags based on ref name and dispatch to print */ static int each_tag(const char *name, tag_state *state) { git_repository *repo = state->repo; git_object *obj; check_lg2(git_revparse_single(&obj, repo, name), "Failed to lookup rev", name); switch (git_object_type(obj)) { case GIT_OBJ_TAG: print_tag((git_tag *) obj, state); break; case GIT_OBJ_COMMIT: print_commit((git_commit *) obj, name, state); break; default: print_name(name); } git_object_free(obj); return 0; }
void cgit_print_tags(int maxcount) { struct reflist list; int i; header = 0; list.refs = NULL; list.alloc = list.count = 0; for_each_tag_ref(cgit_refs_cb, &list); if (list.count == 0) return; qsort(list.refs, list.count, sizeof(*list.refs), cmp_tag_age); if (!maxcount) maxcount = list.count; else if (maxcount > list.count) maxcount = list.count; print_tag_header(); for(i=0; i<maxcount; i++) print_tag(list.refs[i]); if (maxcount < list.count) print_refs_link("tags"); }
int main(int argc, char ** argv) { struct mpd_connection *conn; conn = mpd_connection_new(NULL, 0, 30000); if (mpd_connection_get_error(conn) != MPD_ERROR_SUCCESS) return handle_error(conn); { int i; for(i=0;i<3;i++) { printf("version[%i]: %i\n",i, mpd_connection_get_server_version(conn)[i]); } } if(argc==1) { struct mpd_status * status; struct mpd_song *song; const struct mpd_audio_format *audio_format; mpd_command_list_begin(conn, true); mpd_send_status(conn); mpd_send_current_song(conn); mpd_command_list_end(conn); status = mpd_recv_status(conn); if (status == NULL) return handle_error(conn); printf("volume: %i\n", mpd_status_get_volume(status)); printf("repeat: %i\n", mpd_status_get_repeat(status)); printf("queue version: %u\n", mpd_status_get_queue_version(status)); printf("queue length: %i\n", mpd_status_get_queue_length(status)); if (mpd_status_get_error(status) != NULL) printf("error: %s\n", mpd_status_get_error(status)); if (mpd_status_get_state(status) == MPD_STATE_PLAY || mpd_status_get_state(status) == MPD_STATE_PAUSE) { printf("song: %i\n", mpd_status_get_song_pos(status)); printf("elaspedTime: %i\n",mpd_status_get_elapsed_time(status)); printf("elasped_ms: %u\n", mpd_status_get_elapsed_ms(status)); printf("totalTime: %i\n", mpd_status_get_total_time(status)); printf("bitRate: %i\n", mpd_status_get_kbit_rate(status)); } audio_format = mpd_status_get_audio_format(status); if (audio_format != NULL) { printf("sampleRate: %i\n", audio_format->sample_rate); printf("bits: %i\n", audio_format->bits); printf("channels: %i\n", audio_format->channels); } mpd_status_free(status); if (mpd_connection_get_error(conn) != MPD_ERROR_SUCCESS) return handle_error(conn); mpd_response_next(conn); while ((song = mpd_recv_song(conn)) != NULL) { printf("uri: %s\n", mpd_song_get_uri(song)); print_tag(song, MPD_TAG_ARTIST, "artist"); print_tag(song, MPD_TAG_ALBUM, "album"); print_tag(song, MPD_TAG_TITLE, "title"); print_tag(song, MPD_TAG_TRACK, "track"); print_tag(song, MPD_TAG_NAME, "name"); print_tag(song, MPD_TAG_DATE, "date"); if (mpd_song_get_duration(song) > 0) { printf("time: %u\n", mpd_song_get_duration(song)); } printf("pos: %u\n", mpd_song_get_pos(song)); mpd_song_free(song); } if (mpd_connection_get_error(conn) != MPD_ERROR_SUCCESS || !mpd_response_finish(conn)) return handle_error(conn); } else if(argc==3 && strcmp(argv[1],"lsinfo")==0) { struct mpd_entity * entity; if (!mpd_send_list_meta(conn, argv[2])) return handle_error(conn); while ((entity = mpd_recv_entity(conn)) != NULL) { const struct mpd_song *song; const struct mpd_directory *dir; const struct mpd_playlist *pl; switch (mpd_entity_get_type(entity)) { case MPD_ENTITY_TYPE_UNKNOWN: break; case MPD_ENTITY_TYPE_SONG: song = mpd_entity_get_song(entity); printf("uri: %s\n", mpd_song_get_uri(song)); print_tag(song, MPD_TAG_ARTIST, "artist"); print_tag(song, MPD_TAG_ALBUM, "album"); print_tag(song, MPD_TAG_TITLE, "title"); print_tag(song, MPD_TAG_TRACK, "track"); break; case MPD_ENTITY_TYPE_DIRECTORY: dir = mpd_entity_get_directory(entity); printf("directory: %s\n", mpd_directory_get_path(dir)); break; case MPD_ENTITY_TYPE_PLAYLIST: pl = mpd_entity_get_playlist(entity); printf("playlist: %s\n", mpd_playlist_get_path(pl)); break; } mpd_entity_free(entity); } if (mpd_connection_get_error(conn) != MPD_ERROR_SUCCESS || !mpd_response_finish(conn)) return handle_error(conn); } else if(argc==2 && strcmp(argv[1],"artists")==0) { struct mpd_pair *pair; if (!mpd_search_db_tags(conn, MPD_TAG_ARTIST) || !mpd_search_commit(conn)) return handle_error(conn); while ((pair = mpd_recv_pair_tag(conn, MPD_TAG_ARTIST)) != NULL) { printf("%s\n", pair->value); mpd_return_pair(conn, pair); } if (mpd_connection_get_error(conn) != MPD_ERROR_SUCCESS || !mpd_response_finish(conn)) return handle_error(conn); } else if (argc == 2 && strcmp(argv[1], "playlists") == 0) { if (!mpd_send_list_playlists(conn)) return handle_error(conn); struct mpd_playlist *playlist; while ((playlist = mpd_recv_playlist(conn)) != NULL) { printf("%s\n", mpd_playlist_get_path(playlist)); mpd_playlist_free(playlist); } if (mpd_connection_get_error(conn) != MPD_ERROR_SUCCESS || !mpd_response_finish(conn)) return handle_error(conn); } else if (argc == 2 && strcmp(argv[1], "idle") == 0) { enum mpd_idle idle = mpd_run_idle(conn); if (idle == 0 && mpd_connection_get_error(conn) != MPD_ERROR_SUCCESS) return handle_error(conn); for (unsigned j = 0;; ++j) { enum mpd_idle i = 1 << j; const char *name = mpd_idle_name(i); if (name == NULL) break; if (idle & i) printf("%s\n", name); } } else if (argc == 3 && strcmp(argv[1], "subscribe") == 0) { /* subscribe to a channel and print all messages */ if (!mpd_run_subscribe(conn, argv[2])) return handle_error(conn); while (mpd_run_idle_mask(conn, MPD_IDLE_MESSAGE) != 0) { if (!mpd_send_read_messages(conn)) return handle_error(conn); struct mpd_message *msg; while ((msg = mpd_recv_message(conn)) != NULL) { printf("%s\n", mpd_message_get_text(msg)); mpd_message_free(msg); } if (mpd_connection_get_error(conn) != MPD_ERROR_SUCCESS || !mpd_response_finish(conn)) return handle_error(conn); } return handle_error(conn); } else if (argc == 2 && strcmp(argv[1], "channels") == 0) { /* print a list of channels */ if (!mpd_send_channels(conn)) return handle_error(conn); struct mpd_pair *pair; while ((pair = mpd_recv_channel_pair(conn)) != NULL) { printf("%s\n", pair->value); mpd_return_pair(conn, pair); } if (mpd_connection_get_error(conn) != MPD_ERROR_SUCCESS || !mpd_response_finish(conn)) return handle_error(conn); } else if (argc == 4 && strcmp(argv[1], "message") == 0) { /* send a message to a channel */ if (!mpd_run_send_message(conn, argv[2], argv[3])) return handle_error(conn); } mpd_connection_free(conn); return 0; }
int main(int argc, char **argv) { GError *error = NULL; const char *decoder_name, *path; const struct decoder_plugin *plugin; struct tag *tag; bool empty; #ifdef HAVE_LOCALE_H /* initialize locale */ setlocale(LC_CTYPE,""); #endif if (argc != 3) { g_printerr("Usage: read_tags DECODER FILE\n"); return 1; } decoder_name = argv[1]; path = argv[2]; tag_pool_init(); if (!input_stream_global_init(&error)) { g_warning("%s", error->message); g_error_free(error); return 2; } decoder_plugin_init_all(); plugin = decoder_plugin_from_name(decoder_name); if (plugin == NULL) { g_printerr("No such decoder: %s\n", decoder_name); return 1; } tag = decoder_plugin_tag_dup(plugin, path); if (tag == NULL && plugin->stream_tag != NULL) { struct input_stream *is = input_stream_open(path, &error); if (is == NULL) { g_printerr("Failed to open %s: %s\n", path, error->message); g_error_free(error); return 1; } tag = decoder_plugin_stream_tag(plugin, is); input_stream_close(is); } decoder_plugin_deinit_all(); input_stream_global_finish(); if (tag == NULL) { g_printerr("Failed to read tags\n"); return 1; } print_tag(tag); empty = tag_is_empty(tag); tag_free(tag); if (empty) { tag = tag_ape_load(path); if (tag == NULL) tag = tag_id3_load(path); if (tag != NULL) { print_tag(tag); tag_free(tag); } } tag_pool_deinit(); return 0; }
static void logger_write_file(LOG_PROPERTIES_T *pLogProperties, int sev, const char *msg, va_list *pvlist) { struct tm *ptm = NULL; char strtime[64]; char strpid[64]; char strsev[30]; char strspace[2]; const TIME_VAL tmNowUs = timer_GetTime(); const time_t tmNow = tmNowUs / TIME_VAL_US; //const time_t tmNow = time(NULL); if(!pLogProperties->g_fp || !(pLogProperties->g_log_flags & LOG_FLAG_USEFILEOUTPUT) || sev == 0 || (sev > 0 && sev > pLogProperties->g_log_level) || (sev < 0 && sev < (-1 * pLogProperties->g_log_level))) { return; } if((pLogProperties->g_log_flags & LOG_OUTPUT_PRINT_DATE) && (ptm = (struct tm *) localtime(&tmNow)) != NULL) { strftime(strtime, sizeof(strtime) -1, "%b %d %H:%M:%S", ptm); strtime[sizeof(strtime) - 1] = '\0'; } else { strtime[0] = '\0'; } strpid[0] = '\0'; print_tag(pLogProperties, strpid, sizeof(strpid)); if(pLogProperties->g_log_flags & LOG_OUTPUT_PRINT_SEV) { snprintf(strsev, sizeof(strsev) - 1, "%s ", logger_getSeverityStr((unsigned short) sev)); strsev[sizeof(strsev) - 1] = '\0'; } else { strsev[0] = '\0'; } if(strtime[0] != '\0' || (strpid[0] != '\0' && strsev[0] != '\0')) { strspace[0] = ' '; strspace[1] = '\0'; } else { strspace[0] = '\0'; } // Log to output file fprintf(pLogProperties->g_fp, "%s.%.3llu %s%s%s", strtime, tmNowUs/TIME_VAL_MS%TIME_VAL_MS, strsev, strpid, strspace); vfprintf(pLogProperties->g_fp, msg, *pvlist); // flush output if(pLogProperties->g_log_flags & LOG_FLAG_FLUSHOUTPUT) { if(pLogProperties->g_fp != NULL && (pLogProperties->g_log_flags & LOG_FLAG_USEFILEOUTPUT)) { fflush(pLogProperties->g_fp); } } return; }
int main(int argc, char ** argv) { /* Pointer to file */ FILE *file; char data[10000000]; int num; /*used as an index to cycle through each agent*/ int num_start; int total_households = 400; int households_region_1 = 0.5*total_households; int households_region_2 = 0.5*total_households; //int num_1 = 0.1*total_households; //int num_2 = 0.2*total_households; //int num_3 = 0.4*total_households; //int num_4 = 0.2*total_households; //int num_5 = 0.1*total_households; int num_1_region_1 = 0.05*households_region_1; int num_2_region_1 = 0.05*households_region_1; int num_3_region_1 = 0.8*households_region_1; int num_4_region_1 = 0.05*households_region_1; int num_5_region_1 = 0.05*households_region_1; int num_1_region_2 = 0.05*households_region_2; int num_2_region_2 = 0.05*households_region_2; int num_3_region_2 = 0.8*households_region_2; int num_4_region_2 = 0.05*households_region_2; int num_5_region_2 = 0.05*households_region_2; int total_IGfirms = 1; int total_malls = 2; int total_firms = 10; int num_app = 0.5*total_firms; int g_skill; /* Set changing seed */ srand(time(NULL)); file = fopen("0.xml", "w"); fputs("<states>\n", file); fputs("<itno>0</itno>\n", file); /* Firms */ num_start = 1; int region; for(num=num_start; num<total_firms+num_start; num++) { if(num%2 == 0) { region = 1; } else { region = 2; } double wage_offer = random_double(1,1); fputs("<xagent>\n", file); fputs("<name>Firm</name>\n", file); sprintf(data, "%d", num); print_tag("id", data, file); sprintf(data, "%d",region); print_tag("region_id", data, file); sprintf(data, "{}"); print_tag("employees", data, file); sprintf(data, "%f",wage_offer); print_tag("wage_offer", data, file); sprintf(data, "%f", 1.0); print_tag("technology", data, file); sprintf(data, "%d", 0); print_tag("no_employees", data, file); sprintf(data, "%d", 0); print_tag("vacancies", data, file); sprintf(data, "%f", 0.0); print_tag("needed_capital_stock", data, file); sprintf(data, "%f", 1.0); print_tag("out_of_stock_costs", data, file); sprintf(data, "%d", 0); print_tag("employees_needed", data, file); int i= total_firms + total_households; double estimated_demand = wage_offer*total_households/(total_firms*total_malls); sprintf(data, "{{%d,%f, 0.0}{%d, %f, 0.0}}",i+1,0.5*estimated_demand,i+2,0.5*estimated_demand); print_tag("current_mall_stocks", data, file); int qual = random_int(1,10); double qu = (double) qual; sprintf(data, "%f", 1.0); print_tag("quality", data, file); sprintf(data, "%f", 2.0); print_tag("price", data, file); sprintf(data, "%f", 2.0); print_tag("price_last_month", data, file); double k = 20.0; sprintf(data, "{{%d,1, %f}{%d,2, %f}{%d,3, %f}{%d,4, %f}{%d,5, %f}{%d,6, %f}{%d,7, %f}{%d,8,%f}{%d,9, %f}{%d,10,%f}{%d,1, %f}{%d,2, %f}{%d,3, %f}{%d,4, %f}{%d,5, %f}{%d,6, %f}{%d,7, %f}{%d,8, %f}{%d,9, %f}{%d,10, %f}}",i+1,k,i+1,k,i+1,k,i+1,k,i+1,k,i+1,k,i+1,k,i+1,k,i+1,k,i+1,k,i+2,k,i+2,k,i+2,k,i+2,k,i+2,k,i+2,k,i+2,k,i+2,k,i+2,k,i+2,k); print_tag("malls_sales_statistics", data, file); sprintf(data, "%f", 0.0); print_tag("production_quantity", data, file); sprintf(data, "%f", 0.0); print_tag("planned_production_quantity", data, file); sprintf(data, "%f", wage_offer); print_tag("mean_wage", data, file); sprintf(data, "%f", 1.0); print_tag("mean_specific_skills", data, file); sprintf(data, "%f", 0.0); print_tag("capital_stock", data, file); sprintf(data, "%f", 0.0); print_tag("unit_costs", data, file); sprintf(data, "%f", 0.0); print_tag("costs", data, file); sprintf(data, "%f", 0.0); print_tag("net_profit", data, file); sprintf(data, "%f", 0.0); print_tag("revenue", data, file); sprintf(data, "%f", 0.0); print_tag("cum_revenue", data, file); sprintf(data, "%f", 0.0); print_tag("out_of_stock_costs", data, file); sprintf(data, "%f", 0.0); print_tag("earnings", data, file); sprintf(data, "%f", 0.0); print_tag("account", data, file); sprintf(data, "{%f,%f,%f,%f,%f}", 2*k,2*k,2*k,2*k,2*k); print_tag("last_planned_production_quantities", data, file); sprintf(data, "{{%d, 0.0 ,0 , 0.0}{%d, 0.0, 0, 0.0}}",i+1,i+2); print_tag("sold_quantities", data, file); sprintf(data, "%f", 0.0); print_tag("total_sold_quantity", data, file); sprintf(data, "%f", 0.0); print_tag("cum_total_sold_quantity", data, file); sprintf(data, "{{%d, 0.0, 1.0,1.0}{%d, 0.0,1.0,1.0}}",i+1,i+2); print_tag("delivery_volume", data, file); sprintf(data, "{{%d, 0.0, 1.0,1.0}{%d, 0.0,1.0,1.0}}",i+1,i+2); print_tag("planned_delivery_volume", data, file); //sprintf(data, "%d", 1); print_tag("day_of_month_to_act", data, file); sprintf(data, "%d", 1); print_tag("day_of_month_to_act", data, file); sprintf(data, "%f", 0.0); print_tag("posx", data, file); sprintf(data, "%f", 0.0); print_tag("posy", data, file); fputs("</xagent>\n", file); } num_start = num; for(num=num_start; num<total_households+num_start; num++) { if(num < households_region_1+num_start) { region = 1; /*Skill Group 1: general_skill = 1*/ if(num<num_start+num_1_region_1) { g_skill = 1; } /*Skill Group 2: general_skill = 2*/ if(num_start+num_1_region_1<=num && num<num_start+num_1_region_1+num_2_region_1) { g_skill =2; } /*Skill Group 3: general_skill = 3*/ if(num_start+num_1_region_1+num_2_region_1<=num && num<num_start+num_1_region_1+num_2_region_1+num_3_region_1) { g_skill =3; } /*Skill Group 4: general_skill = 4*/ if(num_start+num_1_region_1+num_2_region_1+num_3_region_1<=num && num<num_start+num_1_region_1+num_2_region_1+num_3_region_1+num_4_region_1) { g_skill =4; } /*Skill Group 5: general_skill = 5*/ if(num_start+num_1_region_1+num_2_region_1+num_3_region_1+num_4_region_1<=num && num<num_start+num_1_region_1+num_2_region_1+num_3_region_1+num_4_region_1+num_5_region_1) { g_skill =5; } } else { region = 2; /*Skill Group 1: general_skill = 1*/ if(num<(num_start+households_region_1+num_1_region_2)) { g_skill =1; } /*Skill Group 2: general_skill = 2*/ if(num_start+households_region_1+num_1_region_2<=num && num<num_start+households_region_1+num_1_region_2+num_2_region_2) { g_skill =2; } /*Skill Group 3: general_skill = 3*/ if(num_start+households_region_1+num_1_region_2+num_2_region_2<=num && num<num_start+households_region_1+num_1_region_2+num_2_region_2+num_3_region_2) { g_skill =3; } /*Skill Group 4: general_skill = 4*/ if(num_start+households_region_1+num_1_region_2+num_2_region_2+num_3_region_2<=num && num<num_start+households_region_1+num_1_region_2+num_2_region_2+num_3_region_2+num_4_region_2) { g_skill =4; } /*Skill Group 5: general_skill = 5*/ if(num_start+households_region_1+num_1_region_2+num_2_region_2+num_3_region_2+num_4_region_2<=num && num<num_start+households_region_1+num_1_region_2+num_2_region_2+num_3_region_2+num_4_region_2+num_5_region_2) { g_skill =5; } } fputs("<xagent>\n", file); fputs("<name>Household</name>\n", file); sprintf(data, "%d", num); print_tag("id", data, file); sprintf(data, "%d",region); print_tag("region_id", data, file); sprintf(data, "%f", 0); print_tag("wage", data, file); sprintf(data, "%f", 1.0); print_tag("wage_reservation", data, file); sprintf(data, "%d", -1); print_tag("employee_firm_id", data, file); sprintf(data, "%d", g_skill); print_tag("general_skill", data, file); sprintf(data, "%f", 1.0); print_tag("specific_skill", data, file); sprintf(data, "%d", 0); print_tag("on_the_job_search", data, file); sprintf(data, "%d", num_app); print_tag("number_applications", data, file); sprintf(data, "%d", 0); print_tag("rationed", data, file); sprintf(data, "%f", 0.0); print_tag("budget", data, file); sprintf(data, "%f", 0.0); print_tag("weekly_budget", data, file); sprintf(data, "%f", 0.0); print_tag("savings", data, file); sprintf(data, "{%f,%f,%f,%f}", 2.0,2.0,2.0,2.0); print_tag("last_income", data, file); sprintf(data, "{{%d, %f, %f}{%d, %f, %f}}", 0, 0.0, 0.0,0,0.0,0.0); print_tag("order_quantity", data, file); sprintf(data, "{{%d, %f}{%d, %f}}", 0, 0.0,0,0.0); print_tag("received_quantity", data, file); sprintf(data, "%d", random_int(0,4)); print_tag("day_of_week_to_act", data, file); sprintf(data, "%d", 4); print_tag("week_of_month", data, file); sprintf(data, "%d", 1); print_tag("day_of_month_to_act", data, file); sprintf(data, "%f", 0.0); print_tag("posx", data, file); sprintf(data, "%f", 0.0); print_tag("posy", data, file); fputs("</xagent>\n", file); } /* Mall */ char data2[10000]; char data1[10000]; int j=1; num_start = num; for(num=num_start; num<total_malls+num_start; num++) { fputs("<xagent>\n", file); fputs("<name>Mall</name>\n", file); sprintf(data, "%d", num); print_tag("id", data, file); sprintf(data, "%d",j); print_tag("region_id", data, file); j++; int i; for( i=1; i<=total_firms;i++) { if(i==1) { sprintf(data2, "{%d , %f, %f, %f}",i, 0.0,0.0,0.0); //printf("HAlll"); } else { sprintf(data1, "%s{ %d , %f, %f, %f }",data2,i, 0.0,0.0,0.0); sprintf(data2,"%s",data1); printf("data2: %s\n",data2); //printf("data1: %s\n",data1); } } sprintf(data, "{%s}",data1); print_tag("current_stock", data, file); for( i=1; i<=total_firms;i++) { if(i==1) sprintf(data2, "{%d , %f}",i, 0.0); else { sprintf(data1, "%s{ %d , %f}",data2,i, 0.0); sprintf(data2,"%s",data1); } } sprintf(data, "{%s}",data1); print_tag("firm_revenues", data, file); sprintf(data, "%f", 0.0); print_tag("posx", data, file); sprintf(data, "%f", 0.0); print_tag("posy", data, file); fputs("</xagent>\n", file); } /* IGFirm */ num_start = num; for(num=num_start; num<total_IGfirms+num_start; num++) { fputs("<xagent>\n", file); fputs("<name>IGFirm</name>\n", file); sprintf(data, "%d", num); print_tag("id", data, file); sprintf(data, "%d",random_int(1,2)); print_tag("region_id", data, file); sprintf(data, "%f",1.0); print_tag("productivity", data, file); sprintf(data, "%d",10); print_tag("innovation_probability", data, file); sprintf(data, "%f",0.05); print_tag("productivity_progress", data, file); sprintf(data, "%f", 1.0); print_tag("capital_good_price", data, file); sprintf(data, "%d", 1); print_tag("day_of_month_to_act", data, file); sprintf(data, "%f", 0.0); print_tag("posx", data, file); sprintf(data, "%f", 0.0); print_tag("posy", data, file); fputs("</xagent>\n", file); } fputs("</states>\n", file); /* Close the file */ fclose(file); /* Exit successfully by returning zero to Operating System */ return 0; }
static void print_expr(expr_t *expr) { if (expr == NULL) return; switch (expr->token) { case tok_int: printf("%ld", expr->data._unary.i); break; case tok_float: printf("%f", expr->data._unary.d); break; case tok_string: printf("\"%s\"", expr->data._unary.cp); break; case tok_symbol: printf("%s", expr->data._unary.cp); break; case tok_type: print_tag(expr->data._unary.vp, NULL); break; case tok_declexpr: print_expr(expr->data._binary.lvalue); putchar(' '); print_expr(expr->data._binary.rvalue); break; case tok_decl: print_expr(expr->data._binary.lvalue); putchar(' '); print_comma_list(expr->data._binary.rvalue); printf(" ;"); break; case tok_oparen: putchar('('); break; case tok_cparen: putchar(')'); break; case tok_obrack: putchar('['); break; case tok_cbrack: putchar(']'); break; case tok_obrace: putchar('{'); break; case tok_cbrace: putchar('}'); break; case tok_collon: putchar(':'); break; case tok_semicollon: putchar(';'); break; case tok_comma: putchar(','); break; case tok_dot: print_binary(".", expr); break; case tok_arrow: print_binary("->", expr); break; case tok_ellipsis: printf("..."); break; case tok_set: print_binary("=", expr); break; case tok_andset: print_binary("&=", expr); break; case tok_orset: print_binary("|=", expr); break; case tok_xorset: print_binary("^=", expr); break; case tok_lshset: print_binary("<<=", expr); break; case tok_rshset: print_binary(">>=", expr); break; case tok_addset: print_binary("+=", expr); break; case tok_subset: print_binary("-=", expr); break; case tok_mulset: print_binary("*=", expr); break; case tok_divset: print_binary("/=", expr); break; case tok_remset: print_binary("%=", expr); break; case tok_andand: print_binary("&&", expr); break; case tok_oror: print_binary("||", expr); break; case tok_lt: print_binary("<", expr); break; case tok_le: print_binary("<=", expr); break; case tok_eq: print_binary("==", expr); break; case tok_ge: print_binary(">=", expr); break; case tok_gt: print_binary(">", expr); break; case tok_ne: print_binary("!=", expr); break; case tok_and: print_binary("&", expr); break; case tok_or: print_binary("|", expr); break; case tok_xor: print_binary("^", expr); break; case tok_lsh: print_binary("<<", expr); break; case tok_rsh: print_binary(">>", expr); break; case tok_add: print_binary("+", expr); break; case tok_sub: print_binary("-", expr); break; case tok_mul: print_binary("*", expr); break; case tok_div: print_binary("/", expr); break; case tok_rem: print_binary("%", expr); break; case tok_inc: print_unary("++", expr); break; case tok_dec: print_unary("--", expr); break; case tok_postinc: print_expr(expr->data._unary.expr); printf(" ++"); break; case tok_postdec: print_expr(expr->data._unary.expr); printf(" --"); break; case tok_plus: print_unary("+", expr); break; case tok_neg: print_unary("-", expr); break; case tok_not: print_unary("!", expr); break; case tok_com: print_unary("~", expr); break; case tok_pointer: print_unary("*", expr); break; case tok_address: print_unary("&", expr); break; case tok_sizeof: printf("sizeof ( "); print(expr->data._unary.expr); printf(" )"); break; case tok_goto: print_unary("goto", expr); printf(" ;"); break; case tok_question: print_expr(expr->data._if.test); printf(" ? "); print_expr(expr->data._if.tcode); printf(" : "); print_expr(expr->data._if.fcode); break; case tok_return: print_unary("return", expr); printf(" ;"); break; case tok_break: printf("break ;"); break; case tok_continue: printf("continue ;"); break; case tok_struct: printf("struct"); break; case tok_union: printf("union"); break; case tok_typedef: printf("typedef"); break; case tok_list: print_paren_comma_list(expr->data._unary.expr); break; case tok_vector: print_expr(expr->data._binary.lvalue); printf(" [ "); if (expr->data._binary.rvalue) { print_expr(expr->data._binary.rvalue); printf(" ]"); } else putchar(']'); break; case tok_stat: print_comma_list(expr->data._unary.expr); printf(" ;"); break; case tok_call: print_expr(expr->data._binary.lvalue); putchar(' '); print_paren_comma_list(expr->data._binary.rvalue); break; case tok_code: if (expr->data._unary.expr) { printf("{ "); print(expr->data._unary.expr); printf(" }"); } else printf("{ }"); break; case tok_data: if (expr->data._unary.expr) { printf("{ "); print_comma_list(expr->data._unary.expr); printf(" }"); } else printf("{ }"); break; case tok_if: printf("if "); print_paren_comma_list(expr->data._if.test); putchar(' '); print_expr(expr->data._if.tcode); if (expr->data._if.fcode) { printf(" else "); print_expr(expr->data._if.fcode); } break; case tok_while: printf("while "); print_paren_comma_list(expr->data._while.test); putchar(' '); print_expr(expr->data._while.code); break; case tok_for: printf("for ( "); print_comma_list(expr->data._for.init); printf(" ; "); print_comma_list(expr->data._for.test); printf(" ; "); print_comma_list(expr->data._for.incr); printf(" ) "); print_expr(expr->data._for.code); break; case tok_do: printf("do "); print_expr(expr->data._do.code); printf(" while "); print_paren_comma_list(expr->data._do.test); printf(" ;"); break; case tok_label: print_expr(expr->data._unary.expr); printf(" :"); break; case tok_switch: printf("switch "); print_paren_comma_list(expr->data._switch.test); putchar(' '); print_expr(expr->data._switch.code); break; case tok_case: printf("case %ld :", expr->data._unary.i); break; case tok_default: printf("default :"); break; case tok_elemref: printf("[ "); print(expr->data._unary.expr); printf(" ]"); break; case tok_fieldref: printf(". "); print(expr->data._unary.expr); break; case tok_function: print_expr(expr->data._function.type); putchar(' '); print_expr(expr->data._function.call); putchar(' '); print_expr(expr->data._function.body); break; default: warn(expr, "cannot print %d\n", expr->token); break; } }
/* * Set up bus common stuff, then loop over devices & functions. * If we find something, call pci_do_device_query()). */ static int probe_bus(pciconf_bus_t *pb) { int device, maxdevs; #ifdef __PCI_BUS_DEVORDER char devs[32]; int i; #endif maxdevs = pci_bus_maxdevs(pb->pc, pb->busno); pb->ndevs = 0; pb->niowin = 0; pb->nmemwin = 0; pb->freq_66 = 1; pb->fast_b2b = 1; pb->prefetch = 1; pb->max_mingnt = 0; /* we are looking for the maximum */ pb->min_maxlat = 0x100; /* we are looking for the minimum */ pb->bandwidth_used = 0; #ifdef __PCI_BUS_DEVORDER pci_bus_devorder(pb->pc, pb->busno, devs); for (i=0; (device=devs[i]) < 32 && device >= 0; i++) { #else for (device=0; device < maxdevs; device++) { #endif pcitag_t tag; pcireg_t id, bhlcr; int function, nfunction; int confmode; tag = pci_make_tag(pb->pc, pb->busno, device, 0); if (pci_conf_debug) { print_tag(pb->pc, tag); } id = pci_conf_read(pb->pc, tag, PCI_ID_REG); if (pci_conf_debug) { printf("id=%x: Vendor=%x, Product=%x\n", id, PCI_VENDOR(id),PCI_PRODUCT(id)); } /* Invalid vendor ID value? */ if (PCI_VENDOR(id) == PCI_VENDOR_INVALID) continue; bhlcr = pci_conf_read(pb->pc, tag, PCI_BHLC_REG); nfunction = PCI_HDRTYPE_MULTIFN(bhlcr) ? 8 : 1; for (function = 0 ; function < nfunction ; function++) { tag = pci_make_tag(pb->pc, pb->busno, device, function); id = pci_conf_read(pb->pc, tag, PCI_ID_REG); if (PCI_VENDOR(id) == PCI_VENDOR_INVALID) continue; if (pb->ndevs+1 < MAX_CONF_DEV) { if (pci_conf_debug) { print_tag(pb->pc, tag); printf("Found dev 0x%04x 0x%04x -- " "really probing.\n", PCI_VENDOR(id), PCI_PRODUCT(id)); } #ifdef __HAVE_PCI_CONF_HOOK confmode = pci_conf_hook(pb->pc, pb->busno, device, function, id); if (confmode == 0) continue; #else /* * Don't enable expansion ROMS -- some cards * share address decoders between the EXPROM * and PCI memory space, and enabling the ROM * when not needed will cause all sorts of * lossage. */ confmode = PCI_CONF_ALL & ~PCI_CONF_MAP_ROM; #endif if (pci_do_device_query(pb, tag, device, function, confmode)) return -1; pb->ndevs++; } } } return 0; } static void alloc_busno(pciconf_bus_t *parent, pciconf_bus_t *pb) { pb->busno = parent->next_busno; if (parent->next_busno + parent->busno_spacing > parent->last_busno) panic("Too many PCI busses on bus %d", parent->busno); parent->next_busno = parent->next_busno + parent->busno_spacing; pb->next_busno = pb->busno+1; pb->busno_spacing = parent->busno_spacing >> 1; if (!pb->busno_spacing) panic("PCI busses nested too deep."); pb->last_busno = parent->next_busno - 1; }
void main() { int tag; //stores the RFID ID tag number float dist; int deg; int ovf = 0; int count = 0; store(); if (init()) pm2_pstr("System Checksum Successful!\r\n"); //rfid read pm2_pstr("Please Present Allowable RFID Tag\r\n"); tag = check_RFID(); pm2_pint16u(tag); pm2_pstr(" = "); print_tag(tag); //prints the name of the tag, which is matched to the number being sent pm2_pstr(" RFID tag was detected\r\nNow Starting Central Operational Loop\r\n"); EMICinit(7, 4, 0); EMICspeak('L'); EMICspeak('a'); EMICspeak('u'); EMICspeak('n'); EMICspeak('c'); EMICspeak('h'); EMICspeak('i'); EMICspeak('n'); EMICspeak('f'); EMICspeak(' '); EMICspeak('C'); EMICspeak(' '); //Central Control Loop EMICspeak('C'); EMICspeak(' '); EMICspeak('L'); EMICnull(); gps_to_xbee(1); //Enable GPS->Xbee //Central Operational loop CCL while(1) { dist = getdist_Maxbot(); inchtolcd(dist); //printf("hello\r\n"); pm2_pint16u(dist); pm2_pstr("\"\t\t"); deg = getdegrees_compass(); pm2_pint16u(deg); pm2_pstr("Degrees \r\n"); if(((int)dist) < 26) { EMICinit(7, 4, 0); EMICspeak('S'); EMICspeak('t'); EMICspeak('o'); EMICspeak('p'); EMICnull(); } } }
void main() { int tag; //stores the RFID ID tag number char i; float dist; xdata char a[70]; int b = 7; int c = 0; int count = 0; a[1] = '$'; //stored to be sent out later in the data transmission a[2] = 'G'; a[3] = 'P'; a[4] = 'R'; a[5] = 'M'; a[6] = 'C'; store(); if (init()) pm2_pstr("System Checksum Successful!\r\n"); //rfid read tag = check_RFID(); pm2_pint16u(tag); pm2_pstr(" = "); print_tag(tag); //prints the name of the tag, which is matched to the number being sent pm2_pstr(" RFID tag was detected\r\nNow Starting Central Operational Loop\r\n"); //Central Operational loop while(1) { dist = getdist_Maxbot(); pm2_pint16u(dist); pm2_pstr("\"\r\n"); if(((int)dist) < 30) { EMICinit(7, 4, 0); EMICspeak('S'); EMICspeak('t'); EMICspeak('o'); EMICspeak('p'); EMICnull(); } if(count > 15) { switch_to_gps(); do { i = pm2_cin(); }while ( i != '$'); do { i = pm2_cin(); }while ( i != 'G'); do { i = pm2_cin(); }while ( i != 'P'); do { i = pm2_cin(); }while ( i != 'R'); do { i = pm2_cin(); }while ( i != 'M'); do { i = pm2_cin(); }while ( i != 'C'); b = 7; //7th element is the next clear element after gprmc do //record until an enter character { a[b] = pm2_cin(); b = b + 1; }while (a[b-1] != 0x0D); //while the last recorded char which is a[b-1] isnt == 0x0D or the rtn char c = b; //stores the value of b in c switch_to_xbee(); b = 1; //resets b to 1 do //output all of the array a { pm2_cout(a[b]); b = b + 1; }while (b != c); pm2_pstr("\r\n"); switch_to_main_port(); b = 1; //resets b to 1 do //output all of the array a { pm2_cout(a[b]); b = b + 1; }while (b != c); pm2_pstr("\r\n"); count = 0; } count ++; } }
int main(int argc, char *argv[]) { const char *field = NULL; const char *kernel = NULL; char sep = '\n'; int opt, ret = 0; char *basedir = ""; logging = 0; /* send messages to stderr */ if (native_endianness() == 0) abort(); while ((opt = getopt_long(argc,argv,"adlpVhn0F:k:b:",options,NULL)) >= 0) { switch (opt) { case 'a': field = "author"; break; case 'd': field = "description"; break; case 'l': field = "license"; break; case 'p': field = "parm"; break; case 'n': field = "filename"; break; case 'V': printf(PACKAGE " version " VERSION "\n"); exit(0); case 'F': field = optarg; break; case '0': sep = '\0'; break; case 'k': kernel = optarg; break; case 'b': basedir = optarg; break; case 'h': usage(argv[0]); exit(0); break; default: usage(argv[0]); exit(1); } } if (argc < optind + 1) { usage(argv[0]); exit(1); } for (opt = optind; opt < argc; opt++) { struct string_table *tags; struct elf_file *mod; mod = grab_module(argv[opt], kernel, basedir); if (!mod) { ret = 1; continue; } tags = mod->ops->load_strings(mod, ".modinfo", NULL, error); if (!tags) { release_elf_file(mod); continue; } if (field) print_tag(field, tags, mod->pathname, sep); else print_all(tags, mod->pathname, sep); strtbl_free(tags); release_elf_file(mod); } return ret; }