本文整理汇总了C++中ARRAY_LENGTH函数的典型用法代码示例。如果您正苦于以下问题:C++ ARRAY_LENGTH函数的具体用法?C++ ARRAY_LENGTH怎么用?C++ ARRAY_LENGTH使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ARRAY_LENGTH函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: output_file
static int output_file(file_type type, int srcrootlen, int dstrootlen, const astring *srcfile, const astring *dstfile, int link_to_file)
{
const char *comment_start, *comment_end, *comment_inline, *token_chars;
const char *comment_start_esc, *comment_end_esc, *comment_inline_esc;
const token_entry *token_table;
const astring *srcfile_subpath;
char srcline[4096], *srcptr;
int in_comment = FALSE;
UINT8 is_token[256];
int color_quotes;
core_file *src;
core_file *dst;
int toknum;
int linenum = 1;
/* extract a normalized subpath */
srcfile_subpath = normalized_subpath(srcfile, srcrootlen + 1);
if (srcfile_subpath == NULL)
return 1;
fprintf(stderr, "Processing %s\n", astring_c(srcfile_subpath));
/* set some defaults */
color_quotes = FALSE;
comment_start = comment_start_esc = "";
comment_end = comment_end_esc = "";
comment_inline = comment_inline_esc = "";
token_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_#";
token_table = dummy_token_table;
/* based on the file type, set the comment info */
switch (type)
{
case FILE_TYPE_C:
color_quotes = TRUE;
comment_start = comment_start_esc = "/*";
comment_end = comment_end_esc = "*/";
comment_inline = comment_inline_esc = "//";
token_table = c_token_table;
break;
case FILE_TYPE_MAKE:
color_quotes = TRUE;
comment_inline = comment_inline_esc = "#";
break;
case FILE_TYPE_XML:
color_quotes = TRUE;
comment_start = "<!--";
comment_start_esc = "<!--";
comment_end = "-->";
comment_end_esc = "-->";
break;
default:
case FILE_TYPE_TEXT:
break;
}
/* make the token lookup table */
memset(is_token, 0, sizeof(is_token));
for (toknum = 0; token_chars[toknum] != 0; toknum++)
is_token[(UINT8)token_chars[toknum]] = TRUE;
/* open the source file */
if (core_fopen(astring_c(srcfile), OPEN_FLAG_READ, &src) != FILERR_NONE)
{
fprintf(stderr, "Unable to read file '%s'\n", astring_c(srcfile));
return 1;
}
/* open the output file */
dst = create_file_and_output_header(dstfile, "MAME Source Code", astring_c(srcfile_subpath));
if (dst == NULL)
{
fprintf(stderr, "Unable to write file '%s'\n", astring_c(dstfile));
core_fclose(src);
return 1;
}
/* output the directory navigation */
core_fprintf(dst, "<h3>Viewing File: ");
output_path_as_links(dst, srcfile_subpath, FALSE, link_to_file);
core_fprintf(dst, "</h3>");
astring_free((astring *)srcfile_subpath);
/* start with some tags */
core_fprintf(dst, "\t<pre style=\"font-family:'Courier New','Courier',monospace; font-size:12px;\">\n");
/* iterate over lines in the source file */
while (core_fgets(srcline, ARRAY_LENGTH(srcline), src) != NULL)
{
char dstline[4096], *dstptr = dstline;
int in_inline_comment = FALSE;
int last_token_was_include = FALSE;
int last_was_token = FALSE;
int quotes_are_linked = FALSE;
char in_quotes = 0;
int curcol = 0;
//.........这里部分代码省略.........
示例2: main
//.........这里部分代码省略.........
fprintf (stderr,
"Can't manage screen backlight on this system.\nPlease disable backlight with config option 'workmode='1' or command line switch '-w 1'.\nIf you believe this is an error, open a bug report: https://github.com/poliva/lightum/issues\n");
exit (1);
} else {
dbus_backend = 2;
}
} else {
dbus_backend = 1;
}
} else {
dbus_backend = 0;
}
}
if (conf.idleoff != 0 || conf.screenidle != 0) {
display = XOpenDisplay (NULL);
if (display == NULL) {
fprintf (stderr, "Failed to open display\n");
exit (1);
}
}
signal_installer ();
if (!conf.ignoresession) {
connection = get_dbus_connection ();
proxy_manager = get_dbus_proxy_manager (connection);
proxy_session = get_dbus_proxy_session (connection, proxy_manager);
}
// initialize the light values array
if (!conf.manualmode) {
light = get_light_sensor_value ();
for (i = 0; i < ARRAY_LENGTH (lightvalues); i++)
lightvalues[i] = light;
countarray[light] = ARRAY_LENGTH (lightvalues);
} else {
for (i = 0; i < ARRAY_LENGTH (lightvalues); i++)
lightvalues[i] = 0;
}
while (1) {
if (reloadconfig) {
conf = config_parse ();
if (verbose)
printf ("lightum: SIGUSR1 received, configuration reloaded\n");
check_config_values (conf);
reloadconfig = 0;
}
if (!conf.ignoresession) {
if (!get_session_active (proxy_session)) {
if (verbose)
printf
("lightum: user session not active, sleeping %d milliseconds.\nIf you believe this is an error, try running lightum with 'ignoresession=1' or '-U' command line switch.\n",
conf.polltime);
usleep (conf.polltime * 1000);
continue;
}
}
if (!conf.manualmode) {
light = get_light_sensor_value ();
if (verbose)
printf ("light_sensor: %d ", light);
示例3: palette_alloc
void laserdisc_device::init_video()
{
// register for VBLANK callbacks
m_screen->register_vblank_callback(vblank_state_delegate(FUNC(laserdisc_device::vblank_state_changed), this));
// allocate palette for applying brightness/contrast/gamma
m_videopalette = palette_alloc(256, 1);
if (m_videopalette == NULL)
throw emu_fatalerror("Out of memory allocating video palette");
for (int index = 0; index < 256; index++)
palette_entry_set_color(m_videopalette, index, MAKE_RGB(index, index, index));
// allocate video frames
for (int index = 0; index < ARRAY_LENGTH(m_frame); index++)
{
// first allocate a YUY16 bitmap at 2x the height
frame_data &frame = m_frame[index];
frame.m_bitmap.allocate(m_width, m_height * 2);
frame.m_bitmap.set_palette(m_videopalette);
fillbitmap_yuy16(frame.m_bitmap, 40, 109, 240);
// make a copy of the bitmap that clips out the VBI and horizontal blanking areas
frame.m_visbitmap.wrap(&frame.m_bitmap.pix16(44, frame.m_bitmap.width() * 8 / 720),
frame.m_bitmap.width() - 2 * frame.m_bitmap.width() * 8 / 720,
frame.m_bitmap.height() - 44,
frame.m_bitmap.rowpixels());
frame.m_visbitmap.set_palette(m_videopalette);
}
// allocate an empty frame of the same size
m_emptyframe.allocate(m_width, m_height * 2);
m_emptyframe.set_palette(m_videopalette);
fillbitmap_yuy16(m_emptyframe, 0, 128, 128);
// allocate texture for rendering
m_videoenable = true;
m_videotex = machine().render().texture_alloc();
if (m_videotex == NULL)
fatalerror("Out of memory allocating video texture\n");
// allocate overlay
m_overenable = overlay_configured();
if (m_overenable)
{
// bind our handlers
m_overupdate_ind16.bind_relative_to(*owner());
m_overupdate_rgb32.bind_relative_to(*owner());
// configure bitmap formats
bitmap_format format = !m_overupdate_ind16.isnull() ? BITMAP_FORMAT_IND16 : BITMAP_FORMAT_RGB32;
texture_format texformat = !m_overupdate_ind16.isnull() ? TEXFORMAT_PALETTEA16 : TEXFORMAT_ARGB32;
// allocate overlay bitmaps
for (int index = 0; index < ARRAY_LENGTH(m_overbitmap); index++)
{
m_overbitmap[index].set_format(format, texformat);
m_overbitmap[index].set_palette(machine().palette);
m_overbitmap[index].resize(m_overwidth, m_overheight);
}
// allocate overlay texture
m_overtex = machine().render().texture_alloc();
if (m_overtex == NULL)
fatalerror("Out of memory allocating overlay texture\n");
}
}
示例4: if
);
if (!p)
moves.nMoves++;
else if (p->whatColor() != color)
moves.nMoves++;
}
}
return;
}
const POSITIONOFFSET kingOffset[] =
{ { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1}, { 0, 1 },
{ 1, -1 }, { 1, 0 }, { 1, 1 } };
const int nKingOffsets = ARRAY_LENGTH(kingOffset);
const POSITIONOFFSET knightOffset[] =
{ { 1, 2 }, { 2, 1}, { -1, 2 }, { 2, -1 }, { 1, -2}, { -2, 1 },
{ -1, -2 }, { -2, -1 } };
const int nKnightOffsets = ARRAY_LENGTH(knightOffset);
void PAWN::promote(PIECETYPE promoteType)
{
switch (promoteType)
{
case TYPEQUEEN:
promotePiece = new QUEEN(whatColor());
break;
case TYPEROOK:
示例5: memset
void jangou_blitter_device::device_reset()
{
memset(m_pen_data, 0, ARRAY_LENGTH(m_pen_data));
m_bltflip = false;
}
示例6: recurse_dir
static int recurse_dir(int srcrootlen, const astring *srcdir)
{
static const osd_dir_entry_type typelist[] = { ENTTYPE_DIR, ENTTYPE_FILE };
int result = 0;
int entindex;
/* iterate first over directories, then over files */
for (entindex = 0; entindex < ARRAY_LENGTH(typelist) && result == 0; entindex++)
{
osd_dir_entry_type entry_type = typelist[entindex];
const osd_directory_entry *entry;
list_entry **listarray = NULL;
list_entry *list = NULL;
list_entry *curlist;
osd_directory *dir;
int found = 0;
/* open the directory and iterate through it */
dir = osd_opendir(astring_c(srcdir));
if (dir == NULL)
{
result = 1;
goto error;
}
/* build up the list of files */
while ((entry = osd_readdir(dir)) != NULL)
if (entry->type == entry_type && entry->name[0] != '.')
{
list_entry *lentry = (list_entry *)malloc(sizeof(*lentry));
lentry->name = astring_dupc(entry->name);
lentry->next = list;
list = lentry;
found++;
}
/* close the directory */
osd_closedir(dir);
/* skip if nothing found */
if (found == 0)
continue;
/* allocate memory for sorting */
listarray = (list_entry **)malloc(sizeof(list_entry *) * found);
found = 0;
for (curlist = list; curlist != NULL; curlist = curlist->next)
listarray[found++] = curlist;
/* sort the list */
qsort(listarray, found, sizeof(listarray[0]), compare_list_entries);
/* rebuild the list */
list = NULL;
while (--found >= 0)
{
listarray[found]->next = list;
list = listarray[found];
}
free(listarray);
/* iterate through each file */
for (curlist = list; curlist != NULL && result == 0; curlist = curlist->next)
{
astring *srcfile;
/* build the source filename */
srcfile = astring_alloc();
astring_printf(srcfile, "%s%c%s", astring_c(srcdir), PATH_SEPARATOR[0], astring_c(curlist->name));
/* if we have a file, output it */
if (entry_type == ENTTYPE_FILE)
{
/* make sure we care, first */
if (core_filename_ends_with(astring_c(curlist->name), ".c"))
{
tagmap *depend_map = tagmap_alloc();
tagmap_entry *map_entry;
file_entry *file;
astring *target;
int taghash;
/* find dependencies */
file = compute_dependencies(srcrootlen, srcfile);
recurse_dependencies(file, depend_map);
/* convert the target from source to object (makes assumptions about rules) */
target = astring_dup(file->name);
astring_replacec(target, 0, "src/", "$(OBJ)/");
astring_replacec(target, 0, ".c", ".o");
printf("\n%s : \\\n", astring_c(target));
/* iterate over the hashed dependencies and output them as well */
for (taghash = 0; taghash < TAGMAP_HASH_SIZE; taghash++)
for (map_entry = depend_map->table[taghash]; map_entry != NULL; map_entry = map_entry->next)
printf("\t%s \\\n", astring_c((astring *)map_entry->object));
astring_free(target);
tagmap_free(depend_map);
}
//.........这里部分代码省略.........
示例7: pr8210_execute
static void pr8210_execute(const device_config *laserdisc, int command)
{
static const UINT8 digits[10] = { 0x01, 0x11, 0x09, 0x19, 0x05, 0x15, 0x0d, 0x1d, 0x03, 0x13 };
switch (command)
{
case CMD_SCAN_REVERSE:
if (pr8210_command_buffer_in == pr8210_command_buffer_out ||
pr8210_command_buffer_in == (pr8210_command_buffer_out + 1) % ARRAY_LENGTH(pr8210_command_buffer))
{
pr8210_add_command(0x1c);
playing = TRUE;
}
break;
case CMD_STEP_REVERSE:
pr8210_add_command(0x12);
playing = FALSE;
break;
case CMD_SLOW_REVERSE:
pr8210_add_command(0x02);
playing = TRUE;
break;
case CMD_FAST_REVERSE:
if (pr8210_command_buffer_in == pr8210_command_buffer_out ||
pr8210_command_buffer_in == (pr8210_command_buffer_out + 1) % ARRAY_LENGTH(pr8210_command_buffer))
{
pr8210_add_command(0x0c);
playing = TRUE;
}
break;
case CMD_SCAN_FORWARD:
if (pr8210_command_buffer_in == pr8210_command_buffer_out ||
pr8210_command_buffer_in == (pr8210_command_buffer_out + 1) % ARRAY_LENGTH(pr8210_command_buffer))
{
pr8210_add_command(0x08);
playing = TRUE;
}
break;
case CMD_STEP_FORWARD:
pr8210_add_command(0x04);
playing = FALSE;
break;
case CMD_SLOW_FORWARD:
pr8210_add_command(0x18);
playing = TRUE;
break;
case CMD_FAST_FORWARD:
if (pr8210_command_buffer_in == pr8210_command_buffer_out ||
pr8210_command_buffer_in == (pr8210_command_buffer_out + 1) % ARRAY_LENGTH(pr8210_command_buffer))
{
pr8210_add_command(0x10);
playing = TRUE;
}
break;
case CMD_PLAY:
pr8210_add_command(0x14);
playing = TRUE;
break;
case CMD_PAUSE:
pr8210_add_command(0x0a);
playing = FALSE;
break;
case CMD_FRAME_TOGGLE:
pr8210_add_command(0x0b);
break;
case CMD_CHAPTER_TOGGLE:
pr8210_add_command(0x06);
break;
case CMD_CH1_TOGGLE:
pr8210_add_command(0x0e);
break;
case CMD_CH2_TOGGLE:
pr8210_add_command(0x16);
break;
case CMD_0:
case CMD_1:
case CMD_2:
case CMD_3:
case CMD_4:
case CMD_5:
case CMD_6:
case CMD_7:
case CMD_8:
case CMD_9:
pr8210_add_command(digits[command - CMD_0]);
break;
//.........这里部分代码省略.........
示例8: PIXGetCounterInfo
//==================================================================================================
// PIXGetCounterInfo
//==================================================================================================
BOOL WINAPI PIXGetCounterInfo( DWORD* pdwReturnCounters, PIXCOUNTERINFO** ppCounterInfoList )
{
*pdwReturnCounters = ARRAY_LENGTH(pixCounterSet);
*ppCounterInfoList = &pixCounterSet[0];
return TRUE;
}
示例9: parse_options
static int parse_options(int argc, char *argv[], options *opts)
{
int pending_base = FALSE;
int pending_arch = FALSE;
int pending_mode = FALSE;
int curarch;
int numrows;
int arg;
memset(opts, 0, sizeof(*opts));
// loop through arguments
for (arg = 1; arg < argc; arg++)
{
char *curarg = argv[arg];
// is it a switch?
if (curarg[0] == '-')
{
if (pending_base || pending_arch || pending_mode)
goto usage;
if (tolower((UINT8)curarg[1]) == 'a')
pending_arch = TRUE;
else if (tolower((UINT8)curarg[1]) == 'b')
pending_base = TRUE;
else if (tolower((UINT8)curarg[1]) == 'f')
opts->flipped = TRUE;
else if (tolower((UINT8)curarg[1]) == 'l')
opts->lower = TRUE;
else if (tolower((UINT8)curarg[1]) == 'm')
pending_mode = TRUE;
else if (tolower((UINT8)curarg[1]) == 'n')
opts->norawbytes = TRUE;
else if (tolower((UINT8)curarg[1]) == 'u')
opts->upper = TRUE;
else
goto usage;
}
// base PC
else if (pending_base)
{
int result;
if (curarg[0] == '0' && curarg[1] == 'x')
result = sscanf(&curarg[2], "%x", &opts->basepc);
else if (curarg[0] == '$')
result = sscanf(&curarg[1], "%x", &opts->basepc);
else
result = sscanf(&curarg[0], "%x", &opts->basepc);
if (result != 1)
goto usage;
pending_base = FALSE;
}
// mode
else if (pending_mode)
{
if (sscanf(curarg, "%d", &opts->mode) != 1)
goto usage;
pending_mode = FALSE;
}
// architecture
else if (pending_arch)
{
for (curarch = 0; curarch < ARRAY_LENGTH(dasm_table); curarch++)
if (core_stricmp(curarg, dasm_table[curarch].name) == 0)
break;
if (curarch == ARRAY_LENGTH(dasm_table))
goto usage;
opts->dasm = &dasm_table[curarch];
pending_arch = FALSE;
}
// filename
else if (opts->filename == NULL)
opts->filename = curarg;
// fail
else
goto usage;
}
// if we have a dangling option, error
if (pending_base || pending_arch || pending_mode)
goto usage;
// if no file or no architecture, fail
if (opts->filename == NULL || opts->dasm == NULL)
goto usage;
return 0;
usage:
printf("Usage: %s <filename> -arch <architecture> [-basepc <pc>] \n", argv[0]);
printf(" [-mode <n>] [-norawbytes] [-flipped] [-upper] [-lower]\n");
printf("\n");
printf("Supported architectures:");
numrows = (ARRAY_LENGTH(dasm_table) + 6) / 7;
for (curarch = 0; curarch < numrows * 7; curarch++)
//.........这里部分代码省略.........
示例10: pr8210_add_command
INLINE void pr8210_add_command(UINT8 command)
{
pr8210_command_buffer[pr8210_command_buffer_in++ % ARRAY_LENGTH(pr8210_command_buffer)] = (command & 0x1f) | 0x20;
pr8210_command_buffer[pr8210_command_buffer_in++ % ARRAY_LENGTH(pr8210_command_buffer)] = 0x00 | 0x20;
}
示例11: ARRAY_LENGTH
#define OP_NOP 0
#define OP_VIBRATE 1
#define OP_SHOW_NOTCONNECTED 2
#define OP_FIND_ME 3
#define OP_UNREAD_MESSAGE_COUNT 4
#define OP_CURRENT_HR 5
static char unread_sms_buffer[4];
static char current_hr_buffer[4];
static char bt_notification_delay = 0;
static const uint32_t const disconnect_segments[] = { 300, 300, 300, 300, 300 };
VibePattern disconnecte_pat = {
.durations = disconnect_segments,
.num_segments = ARRAY_LENGTH(disconnect_segments),
};
static void inbox_received_handler(DictionaryIterator *iterator, void *context) {
// Get the first pair
Tuple *t = dict_read_first(iterator);
// Process all pairs present
while(t != NULL) {
// Process this pair's key
APP_LOG(APP_LOG_LEVEL_INFO, "Got opcode: %d, value: %d", (int)t->key, (int)t->value->int32);
switch(t->key) {
case OP_VIBRATE:
// Trigger vibration
vibes_short_pulse();
示例12: progName
void TestDx::testDxCmdLineArgs()
{
string progName("TestDxCmdLineArgs");
int defaultMainPort(9999);
int defaultRemotePort(5555);
string defaultHost("thisHost");
string defaultSciDataDir("fooDir");
string defaultSciDataPrefix("nss.p10");
bool defaultBroadcast(false);
bool defaultNoUi(false);
bool defaultVaryOutputData(false);
string defaultDxName("dxsim33");
bool defaultRemoteMode(false);
DxCmdLineArgs cmdArgs(progName,
defaultMainPort, defaultRemotePort,
defaultHost,
defaultSciDataDir, defaultSciDataPrefix,
defaultBroadcast,
defaultNoUi,
defaultVaryOutputData,
defaultDxName,
defaultRemoteMode);
// test usage message output
cmdArgs.usage();
cerr << endl;
// check the defaults
cu_assert (cmdArgs.getMainPort() == 9999);
cu_assert (cmdArgs.getRemotePort() == 5555);
cu_assert (cmdArgs.getHostName() == "thisHost");
cu_assert (cmdArgs.getSciDataDir() == "fooDir");
cu_assert (cmdArgs.getSciDataPrefix() == "nss.p10");
cu_assert (! cmdArgs.getBroadcast());
cu_assert (! cmdArgs.getNoUi());
cu_assert (! cmdArgs.getVaryOutputData());
cu_assert (cmdArgs.getDxName() == "dxsim33");
cu_assert (! cmdArgs.getRemoteMode());
// try setting good parameters
const char *argv[] =
{ "ProgName",
"-host", "matrix",
"-mainport", "8888",
"-remport", "9999",
"-sddir", "../scienceData",
"-sdprefix", "nss.p6",
"-broadcast",
"-name", "dxsim127",
"-remote",
"-noui",
"-vary"
};
const int argc = ARRAY_LENGTH(argv);
// verify that everything parses
cu_assert(cmdArgs.parseArgs(argc, const_cast<char **>(argv)));
// check the values
cu_assert (cmdArgs.getHostName() == "matrix");
cu_assert (cmdArgs.getMainPort() == 8888);
cu_assert (cmdArgs.getRemotePort() == 9999);
cu_assert (cmdArgs.getSciDataDir() == "../scienceData");
cu_assert (cmdArgs.getSciDataPrefix() == "nss.p6");
cu_assert (cmdArgs.getBroadcast());
cu_assert (cmdArgs.getDxName() == "dxsim127");
cu_assert (cmdArgs.getRemoteMode());
cu_assert (cmdArgs.getNoUi());
cu_assert (cmdArgs.getVaryOutputData());
cout << "Test a bad port number:" << endl;
const char *argvBadPort[] =
{ "ProgName",
"-host",
"matrix",
"-mainport",
"badportnumber",
};
const int argcBadPort = ARRAY_LENGTH(argvBadPort);
cu_assert(cmdArgs.parseArgs(argcBadPort, const_cast<char **>(argvBadPort)) == false);
}
示例13: core_fgetc
//.........这里部分代码省略.........
else if (bom[0] == 0x00 && bom[1] == 0x00 && bom[2] == 0xfe && bom[3] == 0xff)
{
file->text_type = TFT_UTF32BE;
pos = 4;
}
else if (bom[0] == 0xff && bom[1] == 0xfe && bom[2] == 0x00 && bom[3] == 0x00)
{
file->text_type = TFT_UTF32LE;
pos = 4;
}
else if (bom[0] == 0xfe && bom[1] == 0xff)
{
file->text_type = TFT_UTF16BE;
pos = 2;
}
else if (bom[0] == 0xff && bom[1] == 0xfe)
{
file->text_type = TFT_UTF16LE;
pos = 2;
}
else
{
file->text_type = TFT_OSD;
pos = 0;
}
}
core_fseek(file, pos, SEEK_SET);
}
/* fetch the next character */
switch (file->text_type)
{
default:
case TFT_OSD:
readlen = core_fread(file, default_buffer, sizeof(default_buffer));
if (readlen > 0)
{
charlen = osd_uchar_from_osdchar(&uchar, default_buffer, readlen / sizeof(default_buffer[0]));
core_fseek(file, (INT64) (charlen * sizeof(default_buffer[0])) - readlen, SEEK_CUR);
}
break;
case TFT_UTF8:
readlen = core_fread(file, utf8_buffer, sizeof(utf8_buffer));
if (readlen > 0)
{
charlen = uchar_from_utf8(&uchar, utf8_buffer, readlen / sizeof(utf8_buffer[0]));
core_fseek(file, (INT64) (charlen * sizeof(utf8_buffer[0])) - readlen, SEEK_CUR);
}
break;
case TFT_UTF16BE:
readlen = core_fread(file, utf16_buffer, sizeof(utf16_buffer));
if (readlen > 0)
{
charlen = uchar_from_utf16be(&uchar, utf16_buffer, readlen / sizeof(utf16_buffer[0]));
core_fseek(file, (INT64) (charlen * sizeof(utf16_buffer[0])) - readlen, SEEK_CUR);
}
break;
case TFT_UTF16LE:
readlen = core_fread(file, utf16_buffer, sizeof(utf16_buffer));
if (readlen > 0)
{
charlen = uchar_from_utf16le(&uchar, utf16_buffer, readlen / sizeof(utf16_buffer[0]));
core_fseek(file, (INT64) (charlen * sizeof(utf16_buffer[0])) - readlen, SEEK_CUR);
}
break;
case TFT_UTF32BE:
if (core_fread(file, &uchar, sizeof(uchar)) == sizeof(uchar))
uchar = BIG_ENDIANIZE_INT32(uchar);
break;
case TFT_UTF32LE:
if (core_fread(file, &uchar, sizeof(uchar)) == sizeof(uchar))
uchar = LITTLE_ENDIANIZE_INT32(uchar);
break;
}
if (uchar != ~0)
{
/* place the new character in the ring buffer */
file->back_char_head = 0;
file->back_char_tail = utf8_from_uchar(file->back_chars, ARRAY_LENGTH(file->back_chars), uchar);
/* assert(file->back_char_tail != -1);*/
}
}
/* now read from the ring buffer */
if (file->back_char_head != file->back_char_tail)
{
result = file->back_chars[file->back_char_head++];
file->back_char_head %= ARRAY_LENGTH(file->back_chars);
}
else
result = EOF;
return result;
}
示例14: output_report
static void output_report(astring &dirname, astring &tempheader, astring &tempfooter, summary_file *filelist)
{
summary_file *buckethead[BUCKET_COUNT], **buckettailptr[BUCKET_COUNT];
summary_file *curfile;
astring title("MAME Regressions");
astring tempname;
int listnum, bucknum;
core_file *indexfile;
int count = 0, total;
/* initialize the lists */
for (bucknum = 0; bucknum < BUCKET_COUNT; bucknum++)
{
buckethead[bucknum] = NULL;
buckettailptr[bucknum] = &buckethead[bucknum];
}
/* compute the total number of files */
total = 0;
for (curfile = filelist; curfile != NULL; curfile = curfile->next)
total++;
/* first bucketize the games */
for (curfile = filelist; curfile != NULL; curfile = curfile->next)
{
int statcount[STATUS_COUNT] = { 0 };
int bucket = BUCKET_UNKNOWN;
int unique_codes = 0;
int first_valid;
/* print status */
if (++count % 100 == 0)
fprintf(stderr, "Processing file %d/%d\n", count, total);
/* find the first valid entry */
for (first_valid = 0; curfile->status[first_valid] == STATUS_NOT_PRESENT; first_valid++) ;
/* do we need to output anything? */
for (listnum = first_valid; listnum < list_count; listnum++)
if (statcount[curfile->status[listnum]]++ == 0)
unique_codes++;
/* were we consistent? */
if (unique_codes == 1)
{
/* were we consistently ok? */
if (curfile->status[first_valid] == STATUS_SUCCESS)
bucket = compare_screenshots(curfile);
/* must have been consistently erroring */
else
bucket = BUCKET_CONSISTENT_ERROR;
}
/* ok, we're not consistent; could be a number of things */
else
{
/* were we ok at the start and end but not in the middle? */
if (curfile->status[first_valid] == STATUS_SUCCESS && curfile->status[list_count - 1] == STATUS_SUCCESS)
bucket = BUCKET_GOOD_BUT_CHANGED;
/* did we go from good to bad? */
else if (curfile->status[first_valid] == STATUS_SUCCESS)
bucket = BUCKET_REGRESSED;
/* did we go from bad to good? */
else if (curfile->status[list_count - 1] == STATUS_SUCCESS)
bucket = BUCKET_IMPROVED;
/* must have had multiple errors */
else
bucket = BUCKET_MULTI_ERROR;
}
/* add us to the appropriate list */
*buckettailptr[bucket] = curfile;
buckettailptr[bucket] = &curfile->next;
}
/* terminate all the lists */
for (bucknum = 0; bucknum < BUCKET_COUNT; bucknum++)
*buckettailptr[bucknum] = NULL;
/* output header */
tempname.printf("%s" PATH_SEPARATOR "%s", dirname.cstr(), "index.html");
indexfile = create_file_and_output_header(tempname, tempheader, title);
if (indexfile == NULL)
{
fprintf(stderr, "Error creating file '%s'\n", tempname.cstr());
return;
}
/* iterate over buckets and output them */
for (bucknum = 0; bucknum < ARRAY_LENGTH(bucket_output_order); bucknum++)
{
int curbucket = bucket_output_order[bucknum];
if (buckethead[curbucket] != NULL)
{
fprintf(stderr, "Outputting bucket: %s\n", bucket_name[curbucket]);
//.........这里部分代码省略.........
示例15: core_ungetc
int core_ungetc(int c, core_file *file)
{
file->back_chars[file->back_char_tail++] = (char) c;
file->back_char_tail %= ARRAY_LENGTH(file->back_chars);
return c;
}