本文整理汇总了C++中sizeof_array函数的典型用法代码示例。如果您正苦于以下问题:C++ sizeof_array函数的具体用法?C++ sizeof_array怎么用?C++ sizeof_array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sizeof_array函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hooked_fwrite
//------------------------------------------------------------------------------
int hooked_fwrite(const void* data, int size, int count, void* unused)
{
wchar_t buf[2048];
size_t characters;
DWORD written;
size *= count;
characters = MultiByteToWideChar(
CP_UTF8, 0,
(const char*)data, size,
buf, sizeof_array(buf)
);
characters = characters ? characters : sizeof_array(buf) - 1;
buf[characters] = L'\0';
if (g_alt_fwrite_hook)
{
g_alt_fwrite_hook(buf);
}
else
{
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
WriteConsoleW(handle, buf, (DWORD)wcslen(buf), &written, NULL);
}
return size;
}
示例2: hooked_stat
//------------------------------------------------------------------------------
int hooked_stat(const char* path, struct hooked_stat* out)
{
int ret = -1;
WIN32_FILE_ATTRIBUTE_DATA fad;
wchar_t buf[2048];
size_t characters;
// Utf8 to wchars.
characters = MultiByteToWideChar(
CP_UTF8, 0,
path, -1,
buf, sizeof_array(buf)
);
characters = characters ? characters : sizeof_array(buf) - 1;
buf[characters] = L'\0';
// Get properties.
out->st_size = 0;
out->st_mode = 0;
if (GetFileAttributesExW(buf, GetFileExInfoStandard, &fad) != 0)
{
unsigned dir_bit;
dir_bit = (fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? _S_IFDIR : 0;
out->st_size = fad.nFileSizeLow;
out->st_mode |= dir_bit;
ret = 0;
}
else
errno = ENOENT;
return ret;
}
示例3: main
int main()
{
int i;
if (!rocket_init("data/sync"))
return -1;
for (i = 0; i < sizeof_array(s_trackNames); ++i)
s_tracks[i] = sync_get_track(device, s_trackNames[i]);
for (;;)
{
float row_f;
rocket_update();
row_f = ms_to_row_f(curtime_ms, rps);
printf("current time %d\n", curtime_ms);
for (i = 0; i < sizeof_array(s_trackNames); ++i)
printf("%s %f\n", s_trackNames[i], sync_get_val(s_tracks[i], row_f));
#if defined(WIN32)
Sleep(16);
#else
usleep(16000);
#endif
}
}
示例4: print_keys
//------------------------------------------------------------------------------
static int print_keys()
{
int i, n;
const setting_decl_t* decl;
decl = settings_get_decls(g_settings);
if (decl == NULL)
{
puts("ERROR: Failed to find settings decl.");
return 1;
}
puts("Available options:\n");
for (i = 0, n = settings_get_decl_count(g_settings); i < n; ++i)
{
static const char dots[] = ".......................... ";
const char* name = decl->name;
int dot_count;
printf("%s ", name);
dot_count = sizeof_array(dots) - (int)strlen(name);
if (dot_count > 0)
{
printf("%s", dots + sizeof_array(dots) - dot_count);
}
printf("%-6s %s\n", settings_get_str(g_settings, name), decl->friendly_name);
++decl;
}
printf("\nSettings path: %s\n", g_settings_path);
return 0;
}
示例5: TEST_START
TEST_END
TEST_START(parses_ssl_options_require_cert_and_key)
{
opt options;
clax_options_init(&options);
char *argv[] = {"clax", "-r", "."};
int ret = clax_parse_options(&options, sizeof_array(argv), argv);
ASSERT_EQ(ret, -1)
clax_options_free(&options);
clax_options_init(&options);
char *argv2[] = {"clax", "-r", ".", "-t", "ssl/server.crt"};
int ret2 = clax_parse_options(&options, sizeof_array(argv2), argv2);
ASSERT_EQ(ret2, -1)
clax_options_free(&options);
clax_options_init(&options);
char *argv3[] = {"clax", "-r", ".", "-p", "ssl/server.key"};
int ret3 = clax_parse_options(&options, sizeof_array(argv3), argv3);
ASSERT_EQ(ret3, -1)
clax_options_free(&options);
}
示例6: settings_get_str
//------------------------------------------------------------------------------
const char* settings_get_str(settings_t* s, const char* name)
{
int i;
// Check for an environment variable override.
{
static char buffer[256];
strcpy(buffer, "clink.");
str_cat(buffer, name, sizeof_array(buffer));
if (GetEnvironmentVariableA(buffer, buffer, sizeof_array(buffer)))
{
return buffer;
}
}
i = get_decl_index(s, name);
if (i != -1)
{
return s->values[i];
}
return "";
}
示例7: load_lua_scripts
//------------------------------------------------------------------------------
static void load_lua_scripts(const char* path)
{
int i;
char path_buf[1024];
HANDLE find;
WIN32_FIND_DATA fd;
str_cpy(path_buf, path, sizeof_array(path_buf));
str_cat(path_buf, "\\", sizeof_array(path_buf));
i = strlen(path_buf);
str_cat(path_buf, "*.lua", sizeof_array(path_buf));
find = FindFirstFile(path_buf, &fd);
path_buf[i] = '\0';
while (find != INVALID_HANDLE_VALUE)
{
if (_stricmp(fd.cFileName, "clink.lua") != 0)
{
str_cat(path_buf, fd.cFileName, sizeof_array(path_buf));
load_lua_script(path_buf);
path_buf[i] = '\0';
}
if (FindNextFile(find, &fd) == FALSE)
{
FindClose(find);
break;
}
}
}
示例8: set
//------------------------------------------------------------------------------
int set(int argc, char** argv)
{
int ret;
// Check we're running from a Clink session.
extern int g_in_clink_context;
if (!g_in_clink_context)
{
puts("ERROR: The 'set' verb must be run from a process with Clink present");
return 1;
}
// Get the path where Clink's storing its settings.
get_config_dir(g_settings_path, sizeof_array(g_settings_path));
str_cat(g_settings_path, "/settings", sizeof_array(g_settings_path));
// Load Clink's settings.
g_settings = initialise_clink_settings();
if (g_settings == NULL)
{
printf("ERROR: Failed to load Clink's settings from '%s'.", g_settings_path);
return 1;
}
// List or set Clink's settings.
ret = 0;
switch (argc)
{
case 0:
case 1:
ret = print_keys();
break;
case 2:
if (_stricmp(argv[1], "--help") == 0 ||
_stricmp(argv[1], "-h") == 0)
{
ret = 1;
print_usage();
}
else
{
ret = print_value(argv[1]);
}
break;
default:
ret = set_value(argv[1], argv[2]);
if (!ret)
{
settings_save(g_settings, g_settings_path);
}
break;
}
settings_shutdown(g_settings);
return ret;
}
示例9: vasm_rv32f_table_load
int vasm_rv32f_table_load(vasm_ctx_t* ctx)
{
// link in static symbols above into symtab
symbol_table_install_array(&ctx->symtab, &sym_reg_fabi[0],
sizeof_array(sym_reg_fabi));
symbol_table_install_array(&ctx->symtab, &sym_reg_fi[0],
sizeof_array(sym_reg_fi));
symbol_table_install_array(&ctx->symtab, &sym_instr_rv32f[0],
sizeof_array(sym_instr_rv32f));
return 0;
}
示例10: hooked_fprintf
//------------------------------------------------------------------------------
void hooked_fprintf(const void* unused, const char* format, ...)
{
char buffer[2048];
va_list v;
va_start(v, format);
vsnprintf(buffer, sizeof_array(buffer), format, v);
va_end(v);
buffer[sizeof_array(buffer) - 1] = '\0';
hooked_fwrite(buffer, (int)strlen(buffer), 1, NULL);
}
示例11: initialise_clink_settings
//------------------------------------------------------------------------------
void* initialise_clink_settings()
{
char settings_file[MAX_PATH];
get_settings_file(settings_file, sizeof_array(settings_file));
g_settings = settings_init(g_settings_decl, sizeof_array(g_settings_decl));
if (!settings_load(g_settings, settings_file))
{
settings_save(g_settings, settings_file);
}
return g_settings;
}
示例12: _ftdi_port_control
static usbh_urbstatus_t _ftdi_port_control(USBHFTDIPortDriver *ftdipp,
uint8_t bRequest, uint8_t wValue, uint8_t bHIndex, uint16_t wLength,
uint8_t *buff) {
static const uint8_t bmRequestType[] = {
USBH_REQTYPE_VENDOR | USBH_REQTYPE_OUT | USBH_REQTYPE_DEVICE, //0 FTDI_COMMAND_RESET
USBH_REQTYPE_VENDOR | USBH_REQTYPE_OUT | USBH_REQTYPE_DEVICE, //1 FTDI_COMMAND_MODEMCTRL
USBH_REQTYPE_VENDOR | USBH_REQTYPE_OUT | USBH_REQTYPE_DEVICE, //2 FTDI_COMMAND_SETFLOW
USBH_REQTYPE_VENDOR | USBH_REQTYPE_OUT | USBH_REQTYPE_DEVICE, //3 FTDI_COMMAND_SETBAUD
USBH_REQTYPE_VENDOR | USBH_REQTYPE_OUT | USBH_REQTYPE_DEVICE, //4 FTDI_COMMAND_SETDATA
};
osalDbgCheck(bRequest < sizeof_array(bmRequestType));
osalDbgCheck(bRequest != 1);
const USBH_DEFINE_BUFFER(usbh_control_request_t, req) = {
bmRequestType[bRequest],
bRequest,
wValue,
(bHIndex << 8) | (ftdipp->ifnum + 1),
wLength
};
return usbhControlRequestExtended(ftdipp->ftdip->dev, &req, buff, NULL, MS2ST(1000));
}
示例13: UIRender_init
bool UIRender_init() {
s_tex = bgfx::createUniform("s_tex", bgfx::UniformType::Int1);
for (int i = 0; i < (int)sizeof_array(s_programs); ++i) {
ProgramInfo* program = &s_programs[i];
program->handle = loadProgram(program->vsName, program->fsName);
if (!isValid(program->handle))
return false;
const ProgramAttribs* attribs = program->attribs;
bgfx::VertexDecl& decl = program->vertexDecl;
decl.begin();
while (attribs->attrib != bgfx::Attrib::Count) {
decl = decl.add(attribs->attrib, attribs->num, attribs->type, attribs->norm);
attribs++;
}
decl.end();
}
return true;
}
示例14: StandardWidget
GuiSettingsWidget::GuiSettingsWidget(Device *device, QWidget *parent)
: StandardWidget(device, parent),
ui(new Ui::GuiSettingsWidget())
{
ui->setupUi(this);
performStandardSetup(tr("GUI Settings"));
connect(ui->colors, SIGNAL(currentIndexChanged(int)), SLOT(colorChanged(int)));
connect(ui->fullscreen, SIGNAL(stateChanged(int)), SLOT(fullscreenChanged(int)));
SettingsProvider *settings = device->settingsProvider();
if(!settings) {
ui->colors->setEnabled(false);
ui->fullscreen->setEnabled(false);
return;
}
QColor currentColor = settings->value(GUI_COLOR_KEY, guiColors[0]).value<QColor>();
quint16 current = 0;
for(quint16 i = 0; i < sizeof_array(guiColors); ++i) {
if(currentColor == guiColors[i]) {
current = i;
break;
}
}
ui->colors->setCurrentIndex(current);
const bool currentFullscreen = settings->value(FULLSCREEN_KEY, true).toBool();
ui->fullscreen->setChecked(currentFullscreen);
}
示例15: unitfy_data_size
struct size_of_data unitfy_data_size(unsigned int sizeInBytes)
{
struct size_of_data retVal;
int i;
/* Feel free to add more - just append items to the array :) */
const char* units[] = {
"B",
"KB",
"MB",
"GB",
"TB",
"PB",
"EB",
"ZB",
"YB" /* We'll never get past a yottabyte of anything... right? */
};
retVal.quantity = sizeInBytes;
retVal.unit = units[0];
for(i = 1; (retVal.quantity >= 1024) && (i < sizeof_array(units)); ++i)
{
retVal.quantity /= 1024;
retVal.unit = units[i];
}
return retVal;
}