static void print_game_bios(FILE* out, const game_driver* game) { const bios_entry *thisbios; if(!game->bios) return; thisbios = game->bios; /* Match against bios short names */ while(!BIOSENTRY_ISEND(thisbios)) { fprintf(out, "\t\t<biosset"); if (thisbios->_name) fprintf(out, " name=\"%s\"", normalize_string(thisbios->_name)); if (thisbios->_description) fprintf(out, " description=\"%s\"", normalize_string(thisbios->_description)); if (thisbios->value == 0) fprintf(out, " default=\"yes\""); fprintf(out, "/>\n"); thisbios++; } }
void print_game_device(FILE* out, const game_driver* game) { const struct IODevice* dev; const char *name; const char *shortname; int id; begin_resource_tracking(); dev = devices_allocate(game); if (dev) { while(dev->type < IO_COUNT) { /* print out device type */ fprintf(out, "\t\t<device type=\"%s\"", normalize_string(device_typename(dev->type))); /* does this device have a tag? */ if (dev->tag) fprintf(out, " tag=\"%s\"", normalize_string(dev->tag)); /* is this device mandatory? */ if (dev->must_be_loaded) fprintf(out, " mandatory=\"1\""); /* close the XML tag */ fprintf(out, ">\n"); for (id = 0; id < dev->count; id++) { name = device_instancename(&dev->devclass, id); shortname = device_briefinstancename(&dev->devclass, id); fprintf(out, "\t\t\t<instance"); fprintf(out, " name=\"%s\"", normalize_string(name)); fprintf(out, " briefname=\"%s\"", normalize_string(shortname)); fprintf(out, "/>\n"); } if (dev->file_extensions) { const char* ext = dev->file_extensions; while (*ext) { fprintf(out, "\t\t\t<extension"); fprintf(out, " name=\"%s\"", normalize_string(ext)); fprintf(out, "/>\n"); ext += strlen(ext) + 1; } } fprintf(out, "\t\t</device>\n"); dev++; } } end_resource_tracking(); }
inline unpacker_t xml_db_file_source::get_unpacker( rapidxml::xml_node<>* node ) { unpacker_t unpacker; rapidxml::xml_attribute<>* attr = node->first_attribute(); if ( std::memcmp( attr->name(), "type", attr->name_size() ) != 0 ) throw std::runtime_error( "invalid db file" ); unpacker.type = normalize_string( attr->value() ); unpacker.file = normalize_string( node->value() ); return unpacker; }
static void print_game_sample(FILE* out, const game_driver* game) { #if (HAS_SAMPLES) machine_config drv; int i; expand_machine_driver(game->drv, &drv); for( i = 0; drv.sound[i].sound_type && i < MAX_SOUND; i++ ) { const char **samplenames = NULL; if( drv.sound[i].sound_type == SOUND_SAMPLES ) samplenames = ((struct Samplesinterface *)drv.sound[i].config)->samplenames; if (samplenames != 0 && samplenames[0] != 0) { int k = 0; if (samplenames[k][0]=='*') { ++k; } while (samplenames[k] != 0) { /* check if is not empty */ if (*samplenames[k]) { /* check if sample is duplicate */ int l = 0; while (l<k && strcmp(samplenames[k],samplenames[l])!=0) ++l; if (l==k) fprintf(out, "\t\t<sample name=\"%s\"/>\n", normalize_string(samplenames[k])); } ++k; } } } #endif }
static void print_game_sampleof(FILE* out, const game_driver* game) { #if (HAS_SAMPLES) machine_config drv; int i; expand_machine_driver(game->drv, &drv); for( i = 0; drv.sound[i].sound_type && i < MAX_SOUND; i++ ) { const char **samplenames = NULL; if( drv.sound[i].sound_type == SOUND_SAMPLES ) samplenames = ((struct Samplesinterface *)drv.sound[i].config)->samplenames; if (samplenames != 0 && samplenames[0] != 0) { int k = 0; if (samplenames[k][0]=='*') { /* output sampleof only if different from game name */ if (strcmp(samplenames[k] + 1, game->name)!=0) fprintf(out, " sampleof=\"%s\"", normalize_string(samplenames[k] + 1)); ++k; } } } #endif }
/* Normalize the encoding and line ending style of the values of properties * in REV_PROPS that "need translation" (according to * svn_prop_needs_translation(), which is currently all svn:* props) so that * they are encoded in UTF-8 and contain only LF (\n) line endings. * * The number of properties that needed line ending normalization is returned in * *NORMALIZED_COUNT. * * No re-encoding is performed if SOURCE_PROP_ENCODING is NULL. */ svn_error_t * svnsync_normalize_revprops(apr_hash_t *rev_props, int *normalized_count, const char *source_prop_encoding, apr_pool_t *pool) { apr_hash_index_t *hi; *normalized_count = 0; for (hi = apr_hash_first(pool, rev_props); hi; hi = apr_hash_next(hi)) { const char *propname = apr_hash_this_key(hi); const svn_string_t *propval = apr_hash_this_val(hi); if (svn_prop_needs_translation(propname)) { svn_boolean_t was_normalized; SVN_ERR(normalize_string(&propval, &was_normalized, source_prop_encoding, pool, pool)); /* Replace the existing prop value. */ svn_hash_sets(rev_props, propname, propval); if (was_normalized) (*normalized_count)++; /* Count it. */ } } return SVN_NO_ERROR; }
static svn_error_t * change_file_prop(void *file_baton, const char *name, const svn_string_t *value, apr_pool_t *pool) { node_baton_t *fb = file_baton; edit_baton_t *eb = fb->edit_baton; /* only regular properties can pass over libsvn_ra */ if (svn_property_kind2(name) != svn_prop_regular_kind) return SVN_NO_ERROR; /* Maybe drop svn:mergeinfo. */ if (eb->strip_mergeinfo && (strcmp(name, SVN_PROP_MERGEINFO) == 0)) { eb->mergeinfo_stripped = TRUE; return SVN_NO_ERROR; } /* Maybe drop (errantly set, as this is a file) svnmerge.py properties. */ if (eb->migrate_svnmerge && (strcmp(name, "svnmerge-integrated") == 0)) { eb->svnmerge_migrated = TRUE; return SVN_NO_ERROR; } /* Remember if we see any svnmerge-blocked properties. (They really shouldn't be here, as this is a file, but whatever...) */ if (eb->migrate_svnmerge && (strcmp(name, "svnmerge-blocked") == 0)) { eb->svnmerge_blocked = TRUE; } /* Normalize svn:* properties as necessary. */ if (svn_prop_needs_translation(name)) { svn_boolean_t was_normalized; svn_boolean_t mergeinfo_tweaked = FALSE; /* Normalize encoding to UTF-8, and EOL style to LF. */ SVN_ERR(normalize_string(&value, &was_normalized, eb->source_prop_encoding, pool, pool)); /* Correct malformed mergeinfo. */ if (value && strcmp(name, SVN_PROP_MERGEINFO) == 0) { SVN_ERR(remove_r0_mergeinfo(&value, &mergeinfo_tweaked, pool, pool)); if (mergeinfo_tweaked) eb->mergeinfo_tweaked = TRUE; } if (was_normalized) (*(eb->normalized_node_props_counter))++; } return eb->wrapped_editor->change_file_prop(fb->wrapped_node_baton, name, value, pool); }
/* Print the resource info */ static void print_resource_info(FILE* out, const game_driver* game) { const char *start; /* No action if not a resource */ if ((game->flags & NOT_A_DRIVER) == 0) return; /* The runnable entry is an hint for frontend authors */ /* to easily know which game can be started. */ /* Games marked as runnable=yes can be started putting */ /* the game name as argument in the program command line, */ /* games marked as runnable=no cannot be started. */ fprintf(out, "\t<" XML_TOP " runnable=\"no\""); fprintf(out, " name=\"%s\"", normalize_string(game->name) ); start = strrchr(game->source_file, '/'); if (!start) start = strrchr(game->source_file, '\\'); if (!start) start = game->source_file - 1; fprintf(out, " sourcefile=\"%s\"", normalize_string(start + 1)); fprintf(out, ">\n"); if (game->description) fprintf(out, "\t\t<description>%s</description>\n", normalize_string(game->description)); /* print the year only if it's a number */ if (game->year && strspn(game->year,"0123456789")==strlen(game->year)) fprintf(out, "\t\t<year>%s</year>\n", normalize_string(game->year) ); if (game->manufacturer) fprintf(out, "\t\t<manufacturer>%s</manufacturer>\n", normalize_string(game->manufacturer)); print_game_bios(out, game); print_game_rom(out, game); print_game_sample(out, game); fprintf(out, "\t</" XML_TOP ">\n"); }
/* Print the MAME info record for a game */ static void print_game_info(FILE* out, const game_driver* game) { const char *start; const game_driver *clone_of; /* No action if not a game */ if (game->flags & NOT_A_DRIVER) return; fprintf(out, "\t<" XML_TOP); fprintf(out, " name=\"%s\"", normalize_string(game->name) ); start = strrchr(game->source_file, '/'); if (!start) start = strrchr(game->source_file, '\\'); if (!start) start = game->source_file - 1; fprintf(out, " sourcefile=\"%s\"", normalize_string(start + 1)); clone_of = driver_get_clone(game); if (clone_of && !(clone_of->flags & NOT_A_DRIVER)) fprintf(out, " cloneof=\"%s\"", normalize_string(clone_of->name)); if (clone_of) fprintf(out, " romof=\"%s\"", normalize_string(clone_of->name)); print_game_sampleof(out, game); fprintf(out, ">\n"); if (game->description) fprintf(out, "\t\t<description>%s</description>\n", normalize_string(game->description)); /* print the year only if is a number */ if (game->year && strspn(game->year,"0123456789")==strlen(game->year)) fprintf(out, "\t\t<year>%s</year>\n", normalize_string(game->year) ); if (game->manufacturer) fprintf(out, "\t\t<manufacturer>%s</manufacturer>\n", normalize_string(game->manufacturer)); print_game_bios(out, game); print_game_rom(out, game); print_game_sample(out, game); print_game_micro(out, game); print_game_video(out, game); print_game_sound(out, game); print_game_input(out, game); print_game_switch(out, game); print_game_driver(out, game); #ifdef MESS print_game_device(out, game); print_game_ramoptions(out, game); #endif fprintf(out, "\t</" XML_TOP ">\n"); }
CSpaceRestrictionManager::CRestrictionPtr CSpaceRestrictionManager::restriction (shared_str out_restrictors, shared_str in_restrictors) { string4096 m_temp; if (!xr_strlen(out_restrictors) && !xr_strlen(in_restrictors)) return (0); out_restrictors = normalize_string(out_restrictors); in_restrictors = normalize_string(in_restrictors); strconcat (sizeof(m_temp),m_temp,*out_restrictors,"\x01",*in_restrictors); shared_str space_restrictions = m_temp; SPACE_RESTRICTIONS::const_iterator I = m_space_restrictions.find(space_restrictions); if (I != m_space_restrictions.end()) return ((*I).second); CSpaceRestriction *client_restriction = xr_new<CSpaceRestriction>(this,out_restrictors,in_restrictors); m_space_restrictions.insert (std::make_pair(space_restrictions,client_restriction)); return (client_restriction); }
static void print_game_switch(FILE* out, const game_driver* game) { const input_port_entry* input; begin_resource_tracking(); input = input_port_allocate(game->construct_ipt, NULL); while (input->type != IPT_END) { if (input->type==IPT_DIPSWITCH_NAME) { int def = input->default_value; fprintf(out, "\t\t<dipswitch"); fprintf(out, " name=\"%s\"", normalize_string(input->name)); ++input; fprintf(out, ">\n"); while (input->type==IPT_DIPSWITCH_SETTING) { fprintf(out, "\t\t\t<dipvalue"); fprintf(out, " name=\"%s\"", normalize_string(input->name)); if (def == input->default_value) fprintf(out, " default=\"yes\""); fprintf(out, "/>\n"); ++input; } fprintf(out, "\t\t</dipswitch>\n"); } else ++input; } end_resource_tracking(); }
inline signature_t xml_db_file_source::get_signature( rapidxml::xml_node<>* node ) { signature_t signature; for ( rapidxml::xml_attribute<>* attr = node->first_attribute(); attr; attr = attr->next_attribute() ) { if ( std::memcmp( attr->name(), "type", attr->name_size() ) == 0 ) signature.type = normalize_string( attr->value() ); else if ( std::memcmp( attr->name(), "start", attr->name_size() ) == 0 ) signature.start = normalize_string( attr->value() ); else if ( std::memcmp( attr->name(), "version", attr->name_size() ) == 0 ) signature.version = normalize_string( attr->value() ); else if ( std::memcmp( attr->name(), "unpacker", attr->name_size() ) == 0 ) signature.unpacker = normalize_string( attr->value() ); else throw std::runtime_error( "invalid db file" ); } signature.signature = node->value(); return signature; }
static void print_game_micro(FILE* out, const game_driver* game) { machine_config driver; const cpu_config* cpu; const sound_config* sound; int j; expand_machine_driver(game->drv, &driver); cpu = driver.cpu; sound = driver.sound; for(j=0;j<MAX_CPU;++j) { if (cpu[j].cpu_type!=0) { fprintf(out, "\t\t<chip"); fprintf(out, " type=\"cpu\""); fprintf(out, " name=\"%s\"", normalize_string(cputype_name(cpu[j].cpu_type))); fprintf(out, " clock=\"%d\"", cpu[j].cpu_clock); fprintf(out, "/>\n"); } } for(j=0;j<MAX_SOUND;++j) if (sound[j].sound_type) { if (sound[j].sound_type) { fprintf(out, "\t\t<chip"); fprintf(out, " type=\"audio\""); fprintf(out, " name=\"%s\"", normalize_string(sndtype_name(sound[j].sound_type))); if (sound[j].clock) fprintf(out, " clock=\"%d\"", sound[j].clock); fprintf(out, "/>\n"); } } }
inline entry_t xml_db_file_source::get_entry( rapidxml::xml_node<>* node ) { entry_t entry; if ( std::memcmp( node->name(), "entry", node->name_size() ) != 0 ) throw std::runtime_error( "invalid db file" ); for ( rapidxml::xml_attribute<>* attr = node->first_attribute(); attr; attr = attr->next_attribute() ) { if ( std::memcmp( attr->name(), "name", attr->name_size() ) == 0 ) entry.name = normalize_string( attr->value() ); else if ( std::memcmp( attr->name(), "url", attr->name_size() ) == 0 ) entry.url = normalize_string( attr->value() ); else if ( std::memcmp( attr->name(), "description", attr->name_size() ) == 0 ) entry.description = normalize_string( attr->value() ); else if ( std::memcmp( attr->name(), "author", attr->name_size() ) == 0 ) entry.author = normalize_string( attr->value() ); else if ( std::memcmp( attr->name(), "priority", attr->name_size() ) == 0 ) entry.priority = normalize_string( attr->value() ); else throw std::runtime_error( "invalid db file" ); } for ( rapidxml::xml_node<>* next_node = node->first_node(); next_node; next_node = next_node->next_sibling() ) { if ( std::memcmp( next_node->name(), "signature", next_node->name_size() ) == 0 ) entry.signatures.push_back( get_signature( next_node ) ); else if ( std::memcmp( next_node->name(), "unpacker", next_node->name_size() ) == 0 ) entry.unpackers.push_back( get_unpacker( next_node ) ); else throw std::runtime_error( "invalid db file" ); } return entry; }
/** * Use visually distinct identifiers * * \note also checks DCL31-C */ bool DCL02_C( const SgNode *node ) { static std::map<const SgScopeStatement *, std::set<std::string> > scopeMap; static std::map<std::string, const SgInitializedName *> strVarMap; const SgScopeStatement *scope = isSgScopeStatement(node); if (!scope) return false; bool violation = false; if (isSgGlobal(scope)) { std::set<std::string> externNames; /** populate scopeMap */ FOREACH_SUBNODE(scope, nodes, i, V_SgInitializedName) { SgInitializedName *var = isSgInitializedName(*i); assert(var); if (isCompilerGeneratedNode(var) || !isSgDeclarationStatement(var->get_parent()) || findParentOfType(var, SgCtorInitializerList) || findParentOfType(var, SgClassDeclaration) // Might be too strong || var->get_name().getString().empty() || (var->get_name().getString().substr(0,2) == "__")) continue; /** Ignore function prototypes */ const SgFunctionDeclaration * fnDecl = findParentOfType(var, SgFunctionDeclaration); if (fnDecl && !fnDecl->get_definition()) continue; if (isExternVar(var)) { if (externNames.find(var->get_name().getString()) != externNames.end()) continue; externNames.insert(var->get_name().getString()); } const SgScopeStatement *varScope = var->get_scope(); std::string str (normalize_string(var->get_name().str(), isExternVar(var))); if (scopeMap[varScope].find(str) != scopeMap[varScope].end()) { DCL02_report_error(var); violation = true; } else { scopeMap[varScope].insert(str); strVarMap[str] = var; } } return false; }
/* * update_input: does varying amount of updating on the input line depending * upon the position of the cursor and the update flag. If the cursor has * move toward one of the edge boundaries on the screen, update_cursor() * flips the input line to the next (previous) line of text. The update flag * may be: * * NO_UPDATE - only do the above bounds checking. * * UPDATE_JUST_CURSOR - do bounds checking and position cursor where is should * be. * * UPDATE_FROM_CURSOR - does all of the above, and makes sure everything from * the cursor to the right edge of the screen is current (by redrawing it). * * UPDATE_ALL - redraws the entire line */ void update_input (int update) { int old_zone; char *ptr, *ptr_free; int len, free_it = 0, max; char *prompt; int do_echo = 1; Screen *os = last_input_screen; Screen *ns; Window *saved_current_window = current_window; /* * No input line in dumb or bg mode. */ if (dumb_mode || !foreground) return; for (ns = screen_list; ns; ns = ns->next) { if (!ns->alive) continue; /* It's dead, Jim! */ last_input_screen = ns; current_window = ns->current_window; /* * Make sure the client thinks the cursor is on the input line. */ cursor_to_input(); /* * See if we're in a add_wait_prompt() call. If we are, grab that * current prompt, otherwise use the default input prompt. */ if (last_input_screen->promptlist) prompt = last_input_screen->promptlist->prompt; else prompt = input_prompt; /* * * GET THE INPUT PROMPT * */ /* * If we have a prompt, and we're supposed to update the input * prompt, then we do need to expand the prompt. */ if (prompt && update != NO_UPDATE) { int af; /* * If the current window is query'ing an exec'd process, * then we just get the current prompt for that process. * Note that it is not malloced. */ if (is_valid_process(get_target_by_refnum(0)) != -1) ptr = get_prompt_by_refnum(0); /* * Otherwise, we just expand the prompt as normal. */ else { ptr = expand_alias(prompt, empty_string, &af, NULL); free_it = 1; } /* * If we're in an add_wait_prompt(), we see whether or not * this is an "invisible" prompt. If it is, we turn off the * echo so what the user types doesnt show up. */ if (last_input_screen->promptlist) term_echo(last_input_screen->promptlist->echo); /* * Mangle out any ansi chars or so forth. */ ptr_free = ptr; ptr = normalize_string(ptr, 0); /* This should be ok */ if (free_it) new_free(&ptr_free); free_it = 1; /* * If the prompt has changed, or if there is no prompt... */ if ( (ptr && !INPUT_PROMPT) || (!ptr && INPUT_PROMPT) || strcmp(ptr, INPUT_PROMPT) ) { if (last_input_screen->input_prompt_malloc) new_free(&INPUT_PROMPT); last_input_screen->input_prompt_malloc = free_it; INPUT_PROMPT = ptr; INPUT_PROMPT_LEN = output_with_count(INPUT_PROMPT, 0, 0); update = UPDATE_ALL; } /* * Prompt didnt change, so clean up our mess */ else { if (free_it) new_free(&ptr); } } /* * * HAS THE SCREEN CHANGED SIZE SINCE THE LAST TIME? * */ /* * If the screen has resized, then we need to re-compute the * side-to-side scrolling effect. */ if ((last_input_screen->li != last_input_screen->old_li) || (last_input_screen->co != last_input_screen->old_co)) { /* * The input line is always the bottom line */ INPUT_LINE = last_input_screen->li - 1; /* * The "zone" is the range in which when you type, the * input line does not scroll. It is WIDTH chars in from * either side of the display. */ ZONE = last_input_screen->co - (WIDTH * 2); if (ZONE < 10) ZONE = 10; /* Take that! */ START_ZONE = WIDTH; END_ZONE = last_input_screen->co - WIDTH; last_input_screen->old_co = last_input_screen->co; last_input_screen->old_li = last_input_screen->li; } /* * About zones: * The input line is divided into "zones". A "zone" is set above, * and is the width of the screen minus 20 (by default). The input * line, as displayed, is therefore composed of the current "zone", * plus 10 characters from the previous zone, plus 10 characters * from the next zone. When the cursor moves to an adjacent zone, * (by going into column 9 from the right or left of the edge), the * input line is redrawn. There is one catch. The first "zone" * includes the first ten characters of the input line. */ old_zone = START_ZONE; /* * The BEGINNING of the current "zone" is a calculated value: * The number of characters since the origin of the input buffer * is the number of printable chars in the input prompt plus the * current position in the input buffer. We subtract from that * the WIDTH delta to take off the first delta, which doesnt * count towards the width of the zone. Then we divide that by * the size of the zone, to get an integer, then we multiply it * back. This gives us the first character on the screen. We * add WIDTH to the result in order to get the start of the zone * itself. * The END of the current "zone" is just the beginning plus the width. * If we have moved to an different "zone" since last time, we want to * completely redraw the input line. */ START_ZONE = ((INPUT_PROMPT_LEN + THIS_POS - WIDTH) / ZONE) * ZONE + WIDTH; END_ZONE = START_ZONE + ZONE; if (old_zone != START_ZONE) update = UPDATE_ALL; /* * Now that we know where the "zone" is in the input buffer, we can * easily calculate where where we want to start displaying stuff * from the INPUT_BUFFER. If we're in the first "zone", then we will * output from the beginning of the buffer. If we're not in the first * "zone", then we will begin to output from 10 characters to the * left of the zone, after adjusting for the length of the prompt. */ if (START_ZONE == WIDTH) INPUT_ONSCREEN = 0; else { if ((INPUT_ONSCREEN = START_ZONE - WIDTH - INPUT_PROMPT_LEN) < 0) INPUT_ONSCREEN = 0; } /* * And the cursor is simply how many characters away THIS_POS is * from the first column on the screen. */ if (INPUT_ONSCREEN == 0) INPUT_CURSOR = INPUT_PROMPT_LEN + THIS_POS; else INPUT_CURSOR = THIS_POS - INPUT_ONSCREEN; /* * If the cursor moved, or if we're supposed to do a full update, * then redraw the entire input line. */ if (update == UPDATE_ALL) { /* * Move the cursor to the start of the input line */ term_move_cursor(0, INPUT_LINE); /* * If the input line is NOT empty, and we're starting the * display at the beginning of the input buffer, then we * output the prompt first. */ if (INPUT_ONSCREEN == 0 && INPUT_PROMPT && *INPUT_PROMPT) { /* * Forcibly turn on echo. */ do_echo = term_echo(1); /* * Crop back the input prompt so it does not extend * past the end of the zone. */ if (INPUT_PROMPT_LEN > (last_input_screen->co - WIDTH)) INPUT_PROMPT_LEN = last_input_screen->co - WIDTH - 1; /* * Output the prompt. */ output_with_count(INPUT_PROMPT, 0, 1); /* * Turn the echo back to what it was before, * and output the rest of the input buffer. */ term_echo(do_echo); safe_puts(INPUT_BUFFER, last_input_screen->co - INPUT_PROMPT_LEN, do_echo); } /* * Otherwise we just output whatever we have. */ else if (do_echo) safe_puts(&(INPUT_VISIBLE), last_input_screen->co, do_echo); /* * Clear the rest of the input line and reset the cursor * to the current input position. */ term_clear_to_eol(); term_move_cursor(INPUT_CURSOR, INPUT_LINE); cursor_not_in_display(last_input_screen); } /* * If we're just supposed to refresh whats to the right of the * current logical position... */ else if (update == UPDATE_FROM_CURSOR) { /* * Move the cursor to where its supposed to be, * Figure out how much we can output from here, * and then output it. */ term_move_cursor(INPUT_CURSOR, INPUT_LINE); max = last_input_screen->co - (THIS_POS - INPUT_ONSCREEN); if (INPUT_ONSCREEN == 0 && INPUT_PROMPT && *INPUT_PROMPT) max -= INPUT_PROMPT_LEN; if ((len = strlen(&(THIS_CHAR))) > max) len = max; safe_puts(&(THIS_CHAR), len, do_echo); term_clear_to_eol(); term_move_cursor(INPUT_CURSOR, INPUT_LINE); cursor_not_in_display(last_input_screen); } /* * If we're just supposed to move the cursor back to the input * line, then go ahead and do that. */ else if (update == UPDATE_JUST_CURSOR) { term_move_cursor(INPUT_CURSOR, INPUT_LINE); cursor_not_in_display(last_input_screen); } /* * Turn the terminal echo back on, and flush all of the output * we may have done here. */ term_echo(1); term_flush(); } last_input_screen = os; current_window = saved_current_window; }
/* check_rc_trojans: * Read the file pointer specified (rootkit_trojans) * and check if the any trojan entry is on the configured files */ void check_rc_trojans(char *basedir, FILE *fp) { int i = 0, _errors = 0, _total = 0; char buf[OS_SIZE_1024 +1]; char file_path[OS_SIZE_1024 +1]; char *file; char *string_to_look; #ifndef WIN32 char *(all_paths[]) = {"bin","sbin","usr/bin","usr/sbin", NULL}; #else char *(all_paths[]) = {"C:\\Windows\\", "D:\\Windows\\", NULL}; #endif debug1("%s: DEBUG: Starting on check_rc_trojans", ARGV0); while(fgets(buf, OS_SIZE_1024, fp) != NULL) { char *nbuf; char *message = NULL; i = 0; /* Removing end of line */ nbuf = strchr(buf, '\n'); if(nbuf) { *nbuf = '\0'; } /* Normalizing line */ nbuf = normalize_string(buf); if(*nbuf == '\0' || *nbuf == '#') { continue; } /* File now may be valid */ file = nbuf; string_to_look = strchr(file, '!'); if(!string_to_look) { continue; } *string_to_look = '\0'; string_to_look++; message = strchr(string_to_look, '!'); if(!message) { continue; } *message = '\0'; message++; string_to_look = normalize_string(string_to_look); file = normalize_string(file); message = normalize_string(message); if(*file == '\0' || *string_to_look == '\0') { continue; } _total++; /* Trying with all possible paths */ while(all_paths[i] != NULL) { if(*file != '/') { snprintf(file_path, OS_SIZE_1024, "%s/%s/%s",basedir, all_paths[i], file); } else { strncpy(file_path, file, OS_SIZE_1024); file_path[OS_SIZE_1024 -1] = '\0'; } /* Checking if entry is found */ if(is_file(file_path) && os_string(file_path, string_to_look)) { char op_msg[OS_SIZE_1024 +1]; _errors = 1; snprintf(op_msg, OS_SIZE_1024, "Trojaned version of file " "'%s' detected. Signature used: '%s' (%s).", file_path, string_to_look, *message == '\0'? "Generic":message); notify_rk(ALERT_ROOTKIT_FOUND, op_msg); } if(*file == '/') { break; } i++; } continue; } if(_errors == 0) { char op_msg[OS_SIZE_1024 +1]; snprintf(op_msg,OS_SIZE_1024, "No binaries with any trojan detected. " "Analyzed %d files.", _total); notify_rk(ALERT_OK, op_msg); } }
static svn_error_t * change_dir_prop(void *dir_baton, const char *name, const svn_string_t *value, apr_pool_t *pool) { node_baton_t *db = dir_baton; edit_baton_t *eb = db->edit_baton; /* Only regular properties can pass over libsvn_ra */ if (svn_property_kind2(name) != svn_prop_regular_kind) return SVN_NO_ERROR; /* Maybe drop svn:mergeinfo. */ if (eb->strip_mergeinfo && (strcmp(name, SVN_PROP_MERGEINFO) == 0)) { eb->mergeinfo_stripped = TRUE; return SVN_NO_ERROR; } /* Maybe convert svnmerge-integrated data into svn:mergeinfo. (We ignore svnmerge-blocked for now.) */ /* ### FIXME: Consult the mirror repository's HEAD prop values and ### merge svn:mergeinfo, svnmerge-integrated, and svnmerge-blocked. */ if (eb->migrate_svnmerge && (strcmp(name, "svnmerge-integrated") == 0)) { if (value) { /* svnmerge-integrated differs from svn:mergeinfo in a pair of ways. First, it can use tabs, newlines, or spaces to delimit source information. Secondly, the source paths are relative URLs, whereas svn:mergeinfo uses relative paths (not URI-encoded). */ svn_error_t *err; svn_stringbuf_t *mergeinfo_buf = svn_stringbuf_create_empty(pool); svn_mergeinfo_t mergeinfo; int i; apr_array_header_t *sources = svn_cstring_split(value->data, " \t\n", TRUE, pool); svn_string_t *new_value; for (i = 0; i < sources->nelts; i++) { const char *rel_path; apr_array_header_t *path_revs = svn_cstring_split(APR_ARRAY_IDX(sources, i, const char *), ":", TRUE, pool); /* ### TODO: Warn? */ if (path_revs->nelts != 2) continue; /* Append this source's mergeinfo data. */ rel_path = APR_ARRAY_IDX(path_revs, 0, const char *); rel_path = svn_path_uri_decode(rel_path, pool); svn_stringbuf_appendcstr(mergeinfo_buf, rel_path); svn_stringbuf_appendcstr(mergeinfo_buf, ":"); svn_stringbuf_appendcstr(mergeinfo_buf, APR_ARRAY_IDX(path_revs, 1, const char *)); svn_stringbuf_appendcstr(mergeinfo_buf, "\n"); } /* Try to parse the mergeinfo string we've created, just to check for bogosity. If all goes well, we'll unparse it again and use that as our property value. */ err = svn_mergeinfo_parse(&mergeinfo, mergeinfo_buf->data, pool); if (err) { svn_error_clear(err); return SVN_NO_ERROR; } SVN_ERR(svn_mergeinfo_to_string(&new_value, mergeinfo, pool)); value = new_value; } name = SVN_PROP_MERGEINFO; eb->svnmerge_migrated = TRUE; } /* Remember if we see any svnmerge-blocked properties. */ if (eb->migrate_svnmerge && (strcmp(name, "svnmerge-blocked") == 0)) { eb->svnmerge_blocked = TRUE; } /* Normalize svn:* properties as necessary. */ if (svn_prop_needs_translation(name)) { svn_boolean_t was_normalized; svn_boolean_t mergeinfo_tweaked = FALSE; /* Normalize encoding to UTF-8, and EOL style to LF. */ SVN_ERR(normalize_string(&value, &was_normalized, eb->source_prop_encoding, pool, pool)); /* Maybe adjust svn:mergeinfo. */ if (value && strcmp(name, SVN_PROP_MERGEINFO) == 0) { SVN_ERR(remove_r0_mergeinfo(&value, &mergeinfo_tweaked, pool, pool)); if (mergeinfo_tweaked) eb->mergeinfo_tweaked = TRUE; } if (was_normalized) (*(eb->normalized_node_props_counter))++; } return eb->wrapped_editor->change_dir_prop(db->wrapped_node_baton, name, value, pool); }
/* * This just sucked beyond words. I was always planning on rewriting this, * but the crecendo of complaints with regards to this just got to be too * irritating, so i fixed it early. */ int make_status (Window *window, int must_redraw) { int status_line; u_char buffer [BIG_BUFFER_SIZE + 1]; u_char lhs_buffer [BIG_BUFFER_SIZE + 1]; u_char rhs_buffer [BIG_BUFFER_SIZE + 1]; Char *func_value [MAX_FUNCTIONS]; u_char *ptr; size_t save_size; /* We do NOT redraw status bars for hidden windows */ if (!window->screen || !status_updates_permitted) return -1; for (status_line = 0; status_line < window->status.double_status + 1; status_line++) { u_char lhs_fillchar[6], rhs_fillchar[6], *fillchar = lhs_fillchar, *lhp = lhs_buffer, *rhp = rhs_buffer, *cp, *start_rhs = 0, *str; int in_rhs = 0, pr_lhs = 0, pr_rhs = 0, line, *prc = &pr_lhs, i; fillchar[0] = fillchar[1] = 0; /* * If status line gets to one, then that means that * window->double_status is not zero. That means that * the status line we're working on is STATUS2. */ if (status_line) line = 2; /* * If status_line is zero, and window->double_status is * not zero (double status line is on) then we're working * on STATUS1. */ else if (window->status.double_status) line = 1; /* * So status_line is zero and window->double_status is zero. * So we're working on STATUS (0). */ else line = 0; /* * Sanity check: If the status format doesnt exist, dont do * anything for it. */ if (!window->status.line[line].format) continue; /* * Run each of the status-generating functions from the the * status list. Note that the retval of the functions is no * longer malloc()ed. This saves 40-some odd malloc/free sets * each time the status bar is updated, which is non-trivial. */ for (i = 0; i < MAX_FUNCTIONS; i++) { if (window->screen == NULL) return -1; if (window->status.line[line].func[i] == NULL) panic("status callback null. Window [%d], line [%d], function [%d]", window->refnum, line, i); func_value[i] = window->status.line[line].func[i] (window, window->status.line[line].map[i], window->status.line[line].key[i]); } /* * If the REVERSE_STATUS_LINE var is on, then put a reverse * character in the first position (itll get translated to * the tcap code in the output code. */ if (get_int_var(REVERSE_STATUS_LINE_VAR)) *buffer = REV_TOG , str = buffer + 1; else str = buffer; /* * Now press the status line into "buffer". The magic about * setting status_format is handled elsewhere. */ snprintf(str, BIG_BUFFER_SIZE - 1, window->status.line[line].format, func_value[0], func_value[1], func_value[2], func_value[3], func_value[4], func_value[5], func_value[6], func_value[7], func_value[8], func_value[9], func_value[10], func_value[11], func_value[12], func_value[13], func_value[14], func_value[15], func_value[16], func_value[17], func_value[18], func_value[19], func_value[20], func_value[21], func_value[22], func_value[23], func_value[24], func_value[25], func_value[26], func_value[27], func_value[28], func_value[29], func_value[30], func_value[31], func_value[32], func_value[33], func_value[34], func_value[35], func_value[36], func_value[37], func_value[38], func_value[39]); /* * If the user wants us to, pass the status bar through the * expander to pick any variables/function calls. * This is horribly expensive, but what do i care if you * want to waste cpu cycles? ;-) */ if (get_int_var(STATUS_DOES_EXPANDOS_VAR)) { int af = 0; int old_fs = from_server; Window *old = current_window; int owd = window_display; current_window = window; from_server = current_window->server; window_display = 0; str = expand_alias(buffer, empty_string, &af, NULL); window_display = owd; from_server = old_fs; current_window = old; strlcpy(buffer, str, sizeof buffer); new_free(&str); } /* * This converts away any ansi codes in the status line * in accordance with the currenet settings. This leaves us * with nothing but logical characters, which are then easy * to count. :-) */ str = normalize_string(buffer, 3); /* * Count out the characters. * Walk the entire string, looking for nonprintable * characters. We count all the printable characters * on both sides of the %> tag. */ ptr = str; cp = lhp; lhs_buffer[0] = rhs_buffer[0] = 0; while (*ptr) { /* * The FIRST such %> tag is used. * Using multiple %>s is bogus. */ if (*ptr == '\f' && start_rhs == NULL) { ptr++; start_rhs = ptr; fillchar = rhs_fillchar; in_rhs = 1; *cp = 0; cp = rhp; prc = &pr_rhs; } /* * Skip over attribute changes, not useful. */ else if (*ptr == '\006') { /* Copy the next 5 values */ *cp++ = *ptr++; *cp++ = *ptr++; *cp++ = *ptr++; *cp++ = *ptr++; *cp++ = *ptr++; } /* * XXXXX This is a bletcherous hack. * If i knew what was good for me id not do this. */ else if (*ptr == 9) /* TAB */ { fillchar[0] = ' '; fillchar[1] = 0; do *cp++ = ' '; while (++(*prc) % 8); ptr++; } /* * So it is a printable character. */ else { *prc += 1; fillchar[0] = *cp++ = *ptr++; fillchar[1] = 0; } /* * Dont allow more than CO printable characters */ if (pr_lhs + pr_rhs >= window->screen->co) { *cp = 0; break; } } *cp = 0; /* What will we be filling with? */ if (get_int_var(STATUS_NO_REPEAT_VAR)) { lhs_fillchar[0] = ' '; lhs_fillchar[1] = 0; rhs_fillchar[0] = ' '; rhs_fillchar[1] = 0; } /* * Now if we have a rhs, then we have to adjust it. */ if (start_rhs) { int numf = 0; numf = window->screen->co - pr_lhs - pr_rhs -1; while (numf-- >= 0) strlcat(lhs_buffer, lhs_fillchar, sizeof lhs_buffer); } /* * No rhs? If the user wants us to pad it out, do so. */ else if (get_int_var(FULL_STATUS_LINE_VAR)) { int chars = window->screen->co - pr_lhs - 1; while (chars-- >= 0) strlcat(lhs_buffer, lhs_fillchar, sizeof lhs_buffer); } save_size = strlen(all_off()); strlcpy(buffer, lhs_buffer, sizeof buffer - save_size); strlcat(buffer, rhs_buffer, sizeof buffer - save_size); strlcat(buffer, all_off(), sizeof buffer); new_free(&str); /* * Ends up that BitchX always throws this hook and * people seem to like having this thrown in standard * mode, so i'll go along with that. */ do_hook(STATUS_UPDATE_LIST, "%d %d %s", window->refnum, status_line, buffer); if (dumb_mode || !foreground) continue; /* * Update the status line on the screen. * First check to see if it has changed * Remember this is only done in full screen mode. */ if (must_redraw || !window->status.line[status_line].result || strcmp(buffer, window->status.line[status_line].result)) { /* * Roll the new back onto the old */ malloc_strcpy(&window->status.line[status_line].result, buffer); /* * Output the status line to the screen */ output_screen = window->screen; term_move_cursor(0, window->bottom + status_line); output_with_count(buffer, 1, 1); cursor_in_display(window); } } cursor_to_input(); return 0; }
int /* O - Exit code */ main(int argc, /* I - Number of command-line args */ char *argv[]) /* I - Command-line arguments */ { int i; /* Looping var */ const char *pofile, /* .po filename */ *stringsfile; /* .strings filename */ cups_file_t *po, /* .po file */ *strings; /* .strings file */ char s[4096], /* String buffer */ *ptr, /* Pointer into buffer */ *temp, /* New string */ *msgid, /* msgid string */ *msgstr, /* msgstr string */ normalized[8192];/* Normalized msgid string */ size_t length; /* Length of combined strings */ int use_msgid; /* Use msgid strings for msgstr? */ /* * Process command-line arguments... */ pofile = NULL; stringsfile = NULL; use_msgid = 0; for (i = 1; i < argc; i ++) { if (!strcmp(argv[i], "-m")) use_msgid = 1; else if (argv[i][0] == '-') { puts("Usage: po2strings [-m] filename.po filename.strings"); return (1); } else if (!pofile) pofile = argv[i]; else if (!stringsfile) stringsfile = argv[i]; else { puts("Usage: po2strings [-m] filename.po filename.strings"); return (1); } } if (!pofile || !stringsfile) { puts("Usage: po2strings [-m] filename.po filename.strings"); return (1); } /* * Read strings from the .po file and write to the .strings file... */ if ((po = cupsFileOpen(pofile, "r")) == NULL) { perror(pofile); return (1); } if ((strings = cupsFileOpen(stringsfile, "w")) == NULL) { perror(stringsfile); cupsFileClose(po); return (1); } msgid = msgstr = NULL; while (cupsFileGets(po, s, sizeof(s)) != NULL) { if (s[0] == '#' && s[1] == '.') { /* * Copy comment string... */ if (msgid && msgstr) { /* * First output the last localization string... */ if (*msgid) cupsFilePrintf(strings, "\"%s\" = \"%s\";\n", msgid, (use_msgid || !*msgstr) ? msgid : msgstr); free(msgid); free(msgstr); msgid = msgstr = NULL; } cupsFilePrintf(strings, "//%s\n", s + 2); } else if (s[0] == '#' || !s[0]) { /* * Skip blank and file comment lines... */ continue; } else { /* * Strip the trailing quote... */ if ((ptr = strrchr(s, '\"')) == NULL) continue; *ptr = '\0'; /* * Find start of value... */ if ((ptr = strchr(s, '\"')) == NULL) continue; ptr ++; /* * Create or add to a message... */ if (!strncmp(s, "msgid", 5)) { /* * Output previous message as needed... */ if (msgid && msgstr) { if (*msgid) cupsFilePrintf(strings, "\"%s\" = \"%s\";\n", msgid, normalize_string((use_msgid || !*msgstr) ? msgid : msgstr, normalized, sizeof(normalized))); } if (msgid) free(msgid); if (msgstr) free(msgstr); msgid = strdup(ptr); msgstr = NULL; } else if (s[0] == '\"' && (msgid || msgstr)) { /* * Append to current string... */ size_t ptrlen = strlen(ptr); /* Length of string */ length = strlen(msgstr ? msgstr : msgid); if ((temp = realloc(msgstr ? msgstr : msgid, length + ptrlen + 1)) == NULL) { free(msgid); if (msgstr) free(msgstr); perror("Unable to allocate string"); return (1); } if (msgstr) { /* * Copy the new portion to the end of the msgstr string - safe * to use strcpy because the buffer is allocated to the correct * size... */ msgstr = temp; memcpy(msgstr + length, ptr, ptrlen + 1); } else { /* * Copy the new portion to the end of the msgid string - safe * to use strcpy because the buffer is allocated to the correct * size... */ msgid = temp; memcpy(msgid + length, ptr, ptrlen + 1); } } else if (!strncmp(s, "msgstr", 6) && msgid) { /* * Set the string... */ if (msgstr) free(msgstr); if ((msgstr = strdup(ptr)) == NULL) { free(msgid); perror("Unable to allocate msgstr"); return (1); } } } } if (msgid && msgstr) { if (*msgid) cupsFilePrintf(strings, "\"%s\" = \"%s\";\n", msgid, normalize_string((use_msgid || !*msgstr) ? msgid : msgstr, normalized, sizeof(normalized))); } if (msgid) free(msgid); if (msgstr) free(msgstr); cupsFileClose(po); cupsFileClose(strings); return (0); }
/* Print the MAME database in XML format */ void print_mame_xml(FILE* out, const game_driver* const games[]) { fprintf(out, "<?xml version=\"1.0\"?>\n" "<!DOCTYPE " XML_ROOT " [\n" "<!ELEMENT " XML_ROOT " (" XML_TOP "+)>\n" "\t<!ATTLIST " XML_ROOT " build CDATA #IMPLIED>\n" #ifdef MESS "\t<!ELEMENT " XML_TOP " (description, year?, manufacturer, history?, biosset*, rom*, disk*, sample*, chip*, video?, sound?, input?, dipswitch*, driver?, device*, ramoption*)>\n" #else "\t<!ELEMENT " XML_TOP " (description, year?, manufacturer, history?, biosset*, rom*, disk*, sample*, chip*, video?, sound?, input?, dipswitch*, driver?)>\n" #endif "\t\t<!ATTLIST " XML_TOP " name CDATA #REQUIRED>\n" "\t\t<!ATTLIST " XML_TOP " sourcefile CDATA #IMPLIED>\n" "\t\t<!ATTLIST " XML_TOP " runnable (yes|no) \"yes\">\n" "\t\t<!ATTLIST " XML_TOP " cloneof CDATA #IMPLIED>\n" "\t\t<!ATTLIST " XML_TOP " romof CDATA #IMPLIED>\n" "\t\t<!ATTLIST " XML_TOP " sampleof CDATA #IMPLIED>\n" "\t\t<!ELEMENT description (#PCDATA)>\n" "\t\t<!ELEMENT year (#PCDATA)>\n" "\t\t<!ELEMENT manufacturer (#PCDATA)>\n" "\t\t<!ELEMENT history (#PCDATA)>\n" "\t\t<!ELEMENT biosset EMPTY>\n" "\t\t\t<!ATTLIST biosset name CDATA #REQUIRED>\n" "\t\t\t<!ATTLIST biosset description CDATA #REQUIRED>\n" "\t\t\t<!ATTLIST biosset default (yes|no) \"no\">\n" "\t\t<!ELEMENT rom EMPTY>\n" "\t\t\t<!ATTLIST rom name CDATA #REQUIRED>\n" "\t\t\t<!ATTLIST rom bios CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST rom size CDATA #REQUIRED>\n" "\t\t\t<!ATTLIST rom crc CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST rom md5 CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST rom sha1 CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST rom merge CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST rom region CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST rom offset CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST rom status (baddump|nodump|good) \"good\">\n" "\t\t\t<!ATTLIST rom dispose (yes|no) \"no\">\n" "\t\t<!ELEMENT disk EMPTY>\n" "\t\t\t<!ATTLIST disk name CDATA #REQUIRED>\n" "\t\t\t<!ATTLIST disk md5 CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST disk sha1 CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST disk merge CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST disk region CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST disk index CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST disk status (baddump|nodump|good) \"good\">\n" "\t\t<!ELEMENT sample EMPTY>\n" "\t\t\t<!ATTLIST sample name CDATA #REQUIRED>\n" "\t\t<!ELEMENT chip EMPTY>\n" "\t\t\t<!ATTLIST chip name CDATA #REQUIRED>\n" "\t\t\t<!ATTLIST chip type (cpu|audio) #REQUIRED>\n" "\t\t\t<!ATTLIST chip clock CDATA #IMPLIED>\n" "\t\t<!ELEMENT video EMPTY>\n" "\t\t\t<!ATTLIST video screen (raster|vector) #REQUIRED>\n" "\t\t\t<!ATTLIST video orientation (vertical|horizontal) #REQUIRED>\n" "\t\t\t<!ATTLIST video width CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST video height CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST video aspectx CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST video aspecty CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST video refresh CDATA #REQUIRED>\n" "\t\t<!ELEMENT sound EMPTY>\n" "\t\t\t<!ATTLIST sound channels CDATA #REQUIRED>\n" "\t\t<!ELEMENT input EMPTY>\n" "\t\t\t<!ATTLIST input service (yes|no) \"no\">\n" "\t\t\t<!ATTLIST input tilt (yes|no) \"no\">\n" "\t\t\t<!ATTLIST input players CDATA #REQUIRED>\n" "\t\t\t<!ATTLIST input control CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST input buttons CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST input coins CDATA #IMPLIED>\n" "\t\t<!ELEMENT dipswitch (dipvalue*)>\n" "\t\t\t<!ATTLIST dipswitch name CDATA #REQUIRED>\n" "\t\t\t<!ELEMENT dipvalue EMPTY>\n" "\t\t\t\t<!ATTLIST dipvalue name CDATA #REQUIRED>\n" "\t\t\t\t<!ATTLIST dipvalue default (yes|no) \"no\">\n" "\t\t<!ELEMENT driver EMPTY>\n" "\t\t\t<!ATTLIST driver status (good|imperfect|preliminary) #REQUIRED>\n" "\t\t\t<!ATTLIST driver emulation (good|imperfect|preliminary) #REQUIRED>\n" "\t\t\t<!ATTLIST driver color (good|imperfect|preliminary) #REQUIRED>\n" "\t\t\t<!ATTLIST driver sound (good|imperfect|preliminary) #REQUIRED>\n" "\t\t\t<!ATTLIST driver graphic (good|imperfect|preliminary) #REQUIRED>\n" "\t\t\t<!ATTLIST driver cocktail (good|imperfect|preliminary) #IMPLIED>\n" "\t\t\t<!ATTLIST driver protection (good|imperfect|preliminary) #IMPLIED>\n" "\t\t\t<!ATTLIST driver savestate (supported|unsupported) #REQUIRED>\n" "\t\t\t<!ATTLIST driver palettesize CDATA #REQUIRED>\n" #ifdef MESS "\t\t<!ELEMENT device (instance*, extension*)>\n" "\t\t\t<!ATTLIST device type CDATA #REQUIRED>\n" "\t\t\t<!ATTLIST device tag CDATA #IMPLIED>\n" "\t\t\t<!ATTLIST device mandatory CDATA #IMPLIED>\n" "\t\t\t<!ELEMENT instance EMPTY>\n" "\t\t\t\t<!ATTLIST instance name CDATA #REQUIRED>\n" "\t\t\t\t<!ATTLIST instance briefname CDATA #REQUIRED>\n" "\t\t\t<!ELEMENT extension EMPTY>\n" "\t\t\t\t<!ATTLIST extension name CDATA #REQUIRED>\n" "\t\t<!ELEMENT ramoption (#PCDATA)>\n" #endif "]>\n\n" "<" XML_ROOT " build=\"%s\">\n", normalize_string(build_version) ); print_mame_data(out, games); fprintf(out, "</" XML_ROOT ">\n"); }
static void print_game_input(FILE* out, const game_driver* game) { const input_port_entry* input; int nplayer = 0; const char* control = 0; int nbutton = 0; int ncoin = 0; const char* service = 0; const char* tilt = 0; begin_resource_tracking(); input = input_port_allocate(game->construct_ipt, NULL); while (input->type != IPT_END) { if (nplayer < input->player+1) nplayer = input->player+1; switch (input->type) { case IPT_JOYSTICK_LEFT: case IPT_JOYSTICK_RIGHT: /* if control not defined, start it off as horizontal 2-way */ if (!control) control = "joy2way"; else if (strcmp(control,"joy2way") == 0) ; /* if already defined as vertical, make it 4 or 8 way */ else if (strcmp(control,"vjoy2way") == 0) { if (input->four_way) control = "joy4way"; else control = "joy8way"; } break; case IPT_JOYSTICK_UP: case IPT_JOYSTICK_DOWN: /* if control not defined, start it off as vertical 2-way */ if (!control) control= "vjoy2way"; else if (strcmp(control,"vjoy2way") == 0) ; /* if already defined as horiz, make it 4 or 8way */ else if (strcmp(control,"joy2way")==0) { if (input->four_way) control = "joy4way"; else control = "joy8way"; } break; case IPT_JOYSTICKRIGHT_UP: case IPT_JOYSTICKRIGHT_DOWN: case IPT_JOYSTICKLEFT_UP: case IPT_JOYSTICKLEFT_DOWN: /* if control not defined, start it off as vertical 2way */ if (!control) control= "vdoublejoy2way"; else if (strcmp(control,"vdoublejoy2way") == 0) ; /* if already defined as horiz, make it 4 or 8 way */ else if (strcmp(control,"doublejoy2way") == 0) { if (input->four_way) control = "doublejoy4way"; else control = "doublejoy8way"; } break; case IPT_JOYSTICKRIGHT_LEFT: case IPT_JOYSTICKRIGHT_RIGHT: case IPT_JOYSTICKLEFT_LEFT: case IPT_JOYSTICKLEFT_RIGHT: /* if control not defined, start it off as horiz 2-way */ if (!control) control="doublejoy2way"; else if (strcmp(control,"doublejoy2way") == 0) ; /* if already defined as vertical, make it 4 or 8 way */ else if (strcmp(control,"vdoublejoy2way") == 0) { if (input->four_way) control = "doublejoy4way"; else control = "doublejoy8way"; } break; case IPT_BUTTON1: if (nbutton<1) nbutton = 1; break; case IPT_BUTTON2: if (nbutton<2) nbutton = 2; break; case IPT_BUTTON3: if (nbutton<3) nbutton = 3; break; case IPT_BUTTON4: if (nbutton<4) nbutton = 4; break; case IPT_BUTTON5: if (nbutton<5) nbutton = 5; break; case IPT_BUTTON6: if (nbutton<6) nbutton = 6; break; case IPT_BUTTON7: if (nbutton<7) nbutton = 7; break; case IPT_BUTTON8: if (nbutton<8) nbutton = 8; break; case IPT_BUTTON9: if (nbutton<9) nbutton = 9; break; case IPT_BUTTON10: if (nbutton<10) nbutton = 10; break; case IPT_PADDLE: control = "paddle"; break; case IPT_DIAL: control = "dial"; break; case IPT_TRACKBALL_X: case IPT_TRACKBALL_Y: control = "trackball"; break; case IPT_AD_STICK_X: case IPT_AD_STICK_Y: control = "stick"; break; case IPT_LIGHTGUN_X: case IPT_LIGHTGUN_Y: control = "lightgun"; break; case IPT_COIN1: if (ncoin < 1) ncoin = 1; break; case IPT_COIN2: if (ncoin < 2) ncoin = 2; break; case IPT_COIN3: if (ncoin < 3) ncoin = 3; break; case IPT_COIN4: if (ncoin < 4) ncoin = 4; break; case IPT_COIN5: if (ncoin < 5) ncoin = 5; break; case IPT_COIN6: if (ncoin < 6) ncoin = 6; break; case IPT_COIN7: if (ncoin < 7) ncoin = 7; break; case IPT_COIN8: if (ncoin < 8) ncoin = 8; break; case IPT_SERVICE : service = "yes"; break; case IPT_TILT : tilt = "yes"; break; } ++input; } fprintf(out, "\t\t<input"); fprintf(out, " players=\"%d\"", nplayer ); if (control) fprintf(out, " control=\"%s\"", normalize_string(control) ); if (nbutton) fprintf(out, " buttons=\"%d\"", nbutton ); if (ncoin) fprintf(out, " coins=\"%d\"", ncoin ); if (service) fprintf(out, " service=\"%s\"", normalize_string(service) ); if (tilt) fprintf(out, " tilt=\"%s\"", normalize_string(tilt) ); fprintf(out, "/>\n"); end_resource_tracking(); }
static void print_game_rom(FILE* out, const game_driver* game) { const rom_entry *region, *rom, *chunk; const rom_entry *pregion, *prom, *fprom=NULL; const game_driver *clone_of; if (!game->rom) return; clone_of = driver_get_clone(game); for (region = rom_first_region(game); region; region = rom_next_region(region)) for (rom = rom_first_file(region); rom; rom = rom_next_file(rom)) { int offset, length, in_parent, is_disk, is_bios, found_bios, i; char name[100], bios_name[100]; strcpy(name,ROM_GETNAME(rom)); offset = ROM_GETOFFSET(rom); is_disk = ROMREGION_ISDISKDATA(region); is_bios = ROM_GETBIOSFLAGS(rom); in_parent = 0; length = 0; for (chunk = rom_first_chunk(rom); chunk; chunk = rom_next_chunk(chunk)) length += ROM_GETLENGTH(chunk); if (!ROM_NOGOODDUMP(rom) && clone_of) { fprom=NULL; for (pregion = rom_first_region(clone_of); pregion; pregion = rom_next_region(pregion)) for (prom = rom_first_file(pregion); prom; prom = rom_next_file(prom)) if (hash_data_is_equal(ROM_GETHASHDATA(rom), ROM_GETHASHDATA(prom), 0)) { if (!fprom || !strcmp(ROM_GETNAME(prom), name)) fprom=prom; in_parent = 1; } } found_bios = 0; if(!is_disk && is_bios && game->bios) { const bios_entry *thisbios = game->bios; /* Match against bios short names */ while(!found_bios && !BIOSENTRY_ISEND(thisbios) ) { if((is_bios-1) == thisbios->value) /* Note '-1' */ { strcpy(bios_name,thisbios->_name); found_bios = 1; } thisbios++; } } if (!is_disk) fprintf(out, "\t\t<rom"); else fprintf(out, "\t\t<disk"); if (*name) fprintf(out, " name=\"%s\"", normalize_string(name)); if (in_parent) fprintf(out, " merge=\"%s\"", normalize_string(ROM_GETNAME(fprom))); if (!is_disk && found_bios) fprintf(out, " bios=\"%s\"", normalize_string(bios_name)); if (!is_disk) fprintf(out, " size=\"%d\"", length); /* dump checksum information only if there is a known dump */ if (!hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_NO_DUMP)) { for (i=0;i<HASH_NUM_FUNCTIONS;i++) { int func = 1<<i; const char* func_name = hash_function_name(func); char checksum[1000]; if (hash_data_extract_printable_checksum(ROM_GETHASHDATA(rom), func, checksum)) { fprintf(out, " %s=\"%s\"", func_name, checksum); } } } switch (ROMREGION_GETTYPE(region)) { case REGION_CPU1: fprintf(out, " region=\"cpu1\""); break; case REGION_CPU2: fprintf(out, " region=\"cpu2\""); break; case REGION_CPU3: fprintf(out, " region=\"cpu3\""); break; case REGION_CPU4: fprintf(out, " region=\"cpu4\""); break; case REGION_CPU5: fprintf(out, " region=\"cpu5\""); break; case REGION_CPU6: fprintf(out, " region=\"cpu6\""); break; case REGION_CPU7: fprintf(out, " region=\"cpu7\""); break; case REGION_CPU8: fprintf(out, " region=\"cpu8\""); break; case REGION_GFX1: fprintf(out, " region=\"gfx1\""); break; case REGION_GFX2: fprintf(out, " region=\"gfx2\""); break; case REGION_GFX3: fprintf(out, " region=\"gfx3\""); break; case REGION_GFX4: fprintf(out, " region=\"gfx4\""); break; case REGION_GFX5: fprintf(out, " region=\"gfx5\""); break; case REGION_GFX6: fprintf(out, " region=\"gfx6\""); break; case REGION_GFX7: fprintf(out, " region=\"gfx7\""); break; case REGION_GFX8: fprintf(out, " region=\"gfx8\""); break; case REGION_PROMS: fprintf(out, " region=\"proms\""); break; case REGION_SOUND1: fprintf(out, " region=\"sound1\""); break; case REGION_SOUND2: fprintf(out, " region=\"sound2\""); break; case REGION_SOUND3: fprintf(out, " region=\"sound3\""); break; case REGION_SOUND4: fprintf(out, " region=\"sound4\""); break; case REGION_SOUND5: fprintf(out, " region=\"sound5\""); break; case REGION_SOUND6: fprintf(out, " region=\"sound6\""); break; case REGION_SOUND7: fprintf(out, " region=\"sound7\""); break; case REGION_SOUND8: fprintf(out, " region=\"sound8\""); break; case REGION_USER1: fprintf(out, " region=\"user1\""); break; case REGION_USER2: fprintf(out, " region=\"user2\""); break; case REGION_USER3: fprintf(out, " region=\"user3\""); break; case REGION_USER4: fprintf(out, " region=\"user4\""); break; case REGION_USER5: fprintf(out, " region=\"user5\""); break; case REGION_USER6: fprintf(out, " region=\"user6\""); break; case REGION_USER7: fprintf(out, " region=\"user7\""); break; case REGION_USER8: fprintf(out, " region=\"user8\""); break; case REGION_DISKS: fprintf(out, " region=\"disks\""); break; default: fprintf(out, " region=\"0x%x\"", ROMREGION_GETTYPE(region)); } if (hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_NO_DUMP)) fprintf(out, " status=\"nodump\""); if (hash_data_has_info(ROM_GETHASHDATA(rom), HASH_INFO_BAD_DUMP)) fprintf(out, " status=\"baddump\""); if (!is_disk) { if (ROMREGION_GETFLAGS(region) & ROMREGION_DISPOSE) fprintf(out, " dispose=\"yes\""); fprintf(out, " offset=\"%x\"", offset); fprintf(out, "/>\n"); } else { fprintf(out, " index=\"%x\"", DISK_GETINDEX(rom)); fprintf(out, "/>\n"); } } }