Example #1
0
//------------------------------------------------------------------------------
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;
}
Example #2
0
//------------------------------------------------------------------------------
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;
}
Example #3
0
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
	}
}
Example #4
0
//------------------------------------------------------------------------------
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;
}
Example #5
0
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);
}
Example #6
0
//------------------------------------------------------------------------------
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 "";
}
Example #7
0
File: lua.c Project: genba/clink
//------------------------------------------------------------------------------
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;
        }
    }
}
Example #8
0
//------------------------------------------------------------------------------
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;
}
Example #9
0
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;
}
Example #10
0
//------------------------------------------------------------------------------
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);
}
Example #11
0
//------------------------------------------------------------------------------
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;
}
Example #12
0
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));
}
Example #13
0
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;
}
Example #14
0
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);
}
Example #15
0
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;
}
Example #16
0
File: lua.c Project: genba/clink
//------------------------------------------------------------------------------
static int find_files_impl(lua_State* state, int dirs_only)
{
    DIR* dir;
    struct dirent* entry;
    char buffer[512];
    const char* mask;
    int i;
    int case_map;

    // Check arguments.
    i = lua_gettop(state);
    if (i == 0 || lua_isnil(state, 1))
    {
        return 0;
    }

    mask = lua_tostring(state, 1);

    // Should the mask be adjusted for -/_ case mapping?
    if (_rl_completion_case_map && i > 1 && lua_toboolean(state, 2))
    {
        char* slash;

        str_cpy(buffer, mask, sizeof_array(buffer));
        mask = buffer;

        slash = strrchr(buffer, '\\');
        slash = slash ? slash : strrchr(buffer, '/');
        slash = slash ? slash + 1 : buffer;

        while (*slash)
        {
            char c = *slash;
            if (c == '_' || c == '-')
            {
                *slash = '?';
            }

            ++slash;
        }
    }
    
    lua_createtable(state, 0, 0);

    i = 1;
    dir = opendir(mask);
    while (entry = readdir(dir))
    {
        if (dirs_only && !(entry->attrib & _A_SUBDIR))
        {
            continue;
        }

        lua_pushstring(state, entry->d_name);
        lua_rawseti(state, -2, i++);
    }
    closedir(dir);

    return 1;
}
Example #17
0
bool parse_items( player_t* p, js_node_t* items )
{
  if ( !items ) return true;

  static const char* const slot_map[] = {
    "head",
    "neck",
    "shoulder",
    "shirt",
    "chest",
    "waist",
    "legs",
    "feet",
    "wrist",
    "hands",
    "finger1",
    "finger2",
    "trinket1",
    "trinket2",
    "back",
    "mainHand",
    "offHand",
    "ranged",
    "tabard"
  };

  assert( sizeof_array( slot_map ) == SLOT_MAX );

  for ( unsigned i = 0; i < SLOT_MAX; ++i )
  {
    js_node_t* item = js_t::get_child( items, slot_map[ i ] );
    if ( ! item ) continue;

    std::string item_id;
    if ( ! js_t::get_value( item_id, item, "id" ) ) continue;

    std::string gem_ids[3];
    js_t::get_value( gem_ids[0], item, "tooltipParams/gem0" );
    js_t::get_value( gem_ids[1], item, "tooltipParams/gem1" );
    js_t::get_value( gem_ids[2], item, "tooltipParams/gem2" );

    std::string enchant_id;
    js_t::get_value( enchant_id, item, "tooltipParams/enchant" );

    std::string reforge_id;
    js_t::get_value( reforge_id, item, "tooltipParams/reforge" );

    std::string tinker_id;
    js_t::get_value( tinker_id, item, "tooltipParams/tinker" );

    std::string suffix_id;
    js_t::get_value( suffix_id, item, "tooltipParams/suffix" );

    if ( ! item_t::download_slot( p -> items[ i ], item_id, enchant_id, tinker_id, reforge_id, suffix_id, gem_ids ) )
      return false;
  }

  return true;
}
Example #18
0
File: select.c Project: ezc/elinks
/* Maps the content of a scanner token to a pseudo-class or -element ID. */
static enum dom_select_pseudo
get_dom_select_pseudo(struct dom_scanner_token *token)
{
	static struct {
		struct dom_string string;
		enum dom_select_pseudo pseudo;
	} pseudo_info[] = {

#define INIT_DOM_SELECT_PSEUDO_STRING(str, type) \
	{ STATIC_DOM_STRING(str), DOM_SELECT_PSEUDO_##type }

	INIT_DOM_SELECT_PSEUDO_STRING("first-line",	FIRST_LINE),
	INIT_DOM_SELECT_PSEUDO_STRING("first-letter",	FIRST_LETTER),
	INIT_DOM_SELECT_PSEUDO_STRING("selection",	SELECTION),
	INIT_DOM_SELECT_PSEUDO_STRING("after",		AFTER),
	INIT_DOM_SELECT_PSEUDO_STRING("before",		BEFORE),
	INIT_DOM_SELECT_PSEUDO_STRING("link",		LINK),
	INIT_DOM_SELECT_PSEUDO_STRING("visited",	VISITED),
	INIT_DOM_SELECT_PSEUDO_STRING("active",		ACTIVE),
	INIT_DOM_SELECT_PSEUDO_STRING("hover",		HOVER),
	INIT_DOM_SELECT_PSEUDO_STRING("focus",		FOCUS),
	INIT_DOM_SELECT_PSEUDO_STRING("target",		TARGET),
	INIT_DOM_SELECT_PSEUDO_STRING("enabled",	ENABLED),
	INIT_DOM_SELECT_PSEUDO_STRING("disabled",	DISABLED),
	INIT_DOM_SELECT_PSEUDO_STRING("checked",	CHECKED),
	INIT_DOM_SELECT_PSEUDO_STRING("indeterminate",	INDETERMINATE),

	/* Content pseudo-classes: */

	INIT_DOM_SELECT_PSEUDO_STRING("contains",	CONTAINS),

	/* Structural pseudo-classes: */

	INIT_DOM_SELECT_PSEUDO_STRING("nth-child",	NTH_CHILD),
	INIT_DOM_SELECT_PSEUDO_STRING("nth-last-child",	NTH_LAST_CHILD),
	INIT_DOM_SELECT_PSEUDO_STRING("first-child",	FIRST_CHILD),
	INIT_DOM_SELECT_PSEUDO_STRING("last-child",	LAST_CHILD),
	INIT_DOM_SELECT_PSEUDO_STRING("only-child",	ONLY_CHILD),

	INIT_DOM_SELECT_PSEUDO_STRING("nth-of-type",	NTH_TYPE),
	INIT_DOM_SELECT_PSEUDO_STRING("nth-last-of-type",NTH_LAST_TYPE),
	INIT_DOM_SELECT_PSEUDO_STRING("first-of-type",	FIRST_TYPE),
	INIT_DOM_SELECT_PSEUDO_STRING("last-of-type",	LAST_TYPE),
	INIT_DOM_SELECT_PSEUDO_STRING("only-of-type",	ONLY_TYPE),

	INIT_DOM_SELECT_PSEUDO_STRING("root",		ROOT),
	INIT_DOM_SELECT_PSEUDO_STRING("empty",		EMPTY),

#undef INIT_DOM_SELECT_PSEUDO_STRING

	};
	int i;

	for (i = 0; i < sizeof_array(pseudo_info); i++)
		if (!dom_string_casecmp(&pseudo_info[i].string, &token->string))
			return pseudo_info[i].pseudo;

	return DOM_SELECT_PSEUDO_UNKNOWN;
}
Example #19
0
struct r_hash_link *r_hash_lookup(struct r_hash_table *ht, const char *id)
{
	struct r_id rid;
	R_PRE(strlen(id) < sizeof_array(rid.id_name));

	strcpy(rid.id_name, id);
	return r_hash_lookup_id(ht, &rid);
}
Example #20
0
  bool class_flag( unsigned flag ) const
  {
    unsigned index = flag / 32;
    unsigned bit = flag % 32;

    assert( index < sizeof_array( _class_flags ) );
    return ( _class_flags[ index ] & ( 1u << bit ) ) != 0;
  }
Example #21
0
File: lua.c Project: genba/clink
//------------------------------------------------------------------------------
static int get_cwd(lua_State* state)
{
    char path[MAX_PATH];

    GetCurrentDirectory(sizeof_array(path), path);
    lua_pushstring(state, path);
    return 1; 
}
Example #22
0
OSStatus	InstallNSP( const char *inName, const char *inGUID, const char *inPath )
{
	OSStatus		err;
	size_t			size;
	WSADATA			wsd;
	WCHAR			name[ 256 ];
	GUID			guid;
	WCHAR			path[ MAX_PATH ];
	
	require_action( inName && ( *inName != '\0' ), exit, err = kParamErr );
	require_action( inGUID && ( *inGUID != '\0' ), exit, err = kParamErr );
	require_action( inPath && ( *inPath != '\0' ), exit, err = kParamErr );
	
	size = strlen( inName );
	require_action( size < sizeof_array( name ), exit, err = kSizeErr );
	CharToWCharString( inName, name );
	
	err = StringToGUID( inGUID, &guid );
	require_noerr( err, exit );
	
	size = strlen( inPath );
	require_action( size < sizeof_array( path ), exit, err = kSizeErr );
	CharToWCharString( inPath, path );
	
	err = WSAStartup( MAKEWORD( 2, 2 ), &wsd );
	err = translate_errno( err == 0, errno_compat(), WSAEINVAL );
	require_noerr( err, exit );
	
	err = WSCInstallNameSpace( name, path, NS_DNS, 1, &guid );
	err = translate_errno( err == 0, errno_compat(), WSAEINVAL );
	WSACleanup();
	require_noerr( err, exit );
	
	if (!gToolQuietMode)
	{
		fprintf( stderr, "Installed NSP \"%s\" (%s) at %s\n", inName, inGUID, inPath );
	}
	
exit:
	if( err != kNoErr )
	{
		fprintf( stderr, "### FAILED (%d) to install \"%s\" (%s) Name Space Provider at %s\n", err, inName, inGUID, inPath );
	}
	return( err );
}
Example #23
0
int ObjFileLoader::getMtlType(const QString &line)
{
    for(quint32 i = 0; i < sizeof_array(mtlEntryTypes); ++i)
    {
        if(mtlEntryTypes[i] == line)
            return i;
    }
    return -1;
}
void test_c64_vice_callstack(void**)
{
	uint32_t event;
    PDReaderIterator it;

	uint16_t refCallstack[] =
	{
		0xe112 + 2, // (2) e112
		0xa562 + 4, // (4) a562
		0xa483 + 6, // (6) a483
		0xa677 + 8, // (8) a677
		0xe39a + 10, // (10) e39a
	};

    PDWriter* writer = s_session->currentWriter;

    PDWrite_eventBegin(writer, PDEventType_getCallstack);
    PDWrite_eventEnd(writer);
    PDBinaryWriter_finalize(writer);

    Session_update(s_session);

	PDReader* reader = s_session->reader;

	PDBinaryReader_initStream(reader, PDBinaryWriter_getData(s_session->currentWriter), PDBinaryWriter_getSize(s_session->currentWriter));

    while ((event = PDRead_getEvent(reader)) != 0)
    {
        switch (event)
        {
            case PDEventType_setCallstack:
            {
				if (PDRead_findArray(reader, &it, "callstack", 0) == PDReadStatus_notFound)
					return;

				int callstackSize = sizeof_array(refCallstack);
				int count = 0;

				while (PDRead_getNextEntry(reader, &it))
				{
					uint16_t address;

        			PDRead_findU16(reader, &address, "address", it);

        			assert_true(count < callstackSize);
        			assert_int_equal(refCallstack[count], address);

					count++;
				}

				return;
            }
        }
    }

    fail();
}
Example #25
0
//------------------------------------------------------------------------------
int hooked_fwrite(const void* data, int size, int count, void* unused)
{
    wchar_t buf[2048];
    size_t characters;
    DWORD written;

    size *= count;

#if 0
    if (*(char*)data == '\n')
    {
        static int i = 0;
        static const char b[] = "!@#$%^&*()_+|";
        hooked_fwrite(b + (i % sizeof_array(b)), 1, 1, 0);
        ++i;
    }
#endif
    
    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
    {
        WriteConsoleW(
            GetStdHandle(STD_OUTPUT_HANDLE),
            buf,
            (DWORD)wcslen(buf),
            &written,
            NULL
        );
    }

    return size;
}
void
CCPApp::Register( LPCTSTR inClsidString, LPCTSTR inName, LPCTSTR inCanonicalName, LPCTSTR inCategory, LPCTSTR inLocalizedName, LPCTSTR inInfoTip, LPCTSTR inIconPath, LPCTSTR inExePath )
{
    typedef struct	RegistryBuilder		RegistryBuilder;

    struct	RegistryBuilder
    {
        HKEY		rootKey;
        LPCTSTR		subKey;
        LPCTSTR		valueName;
        DWORD		valueType;
        LPCTSTR		data;
    };

    OSStatus			err;
    size_t				n;
    size_t				i;
    HKEY				key;
    TCHAR				keyName[ MAX_PATH ];
    RegistryBuilder		entries[] =
    {
        { HKEY_LOCAL_MACHINE,	TEXT( "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace\\%s" ),	NULL,									REG_SZ,		inName },
        { HKEY_CLASSES_ROOT,	TEXT( "CLSID\\%s" ),																			NULL,									NULL,		NULL },
        { HKEY_CLASSES_ROOT,	TEXT( "CLSID\\%s" ),																			TEXT( "System.ApplicationName" ),		REG_SZ,		inCanonicalName },
        { HKEY_CLASSES_ROOT,	TEXT( "CLSID\\%s" ),																			TEXT( "System.ControlPanel.Category" ),	REG_SZ,		inCategory },
        { HKEY_CLASSES_ROOT,	TEXT( "CLSID\\%s" ),																			TEXT( "LocalizedString" ),				REG_SZ,		inLocalizedName },
        { HKEY_CLASSES_ROOT,	TEXT( "CLSID\\%s" ),																			TEXT( "InfoTip" ),						REG_SZ,		inInfoTip },
        { HKEY_CLASSES_ROOT,	TEXT( "CLSID\\%s\\DefaultIcon" ),																NULL,									REG_SZ,		inIconPath },
        { HKEY_CLASSES_ROOT,	TEXT( "CLSID\\%s\\Shell" ),																		NULL,									NULL,		NULL },
        { HKEY_CLASSES_ROOT,	TEXT( "CLSID\\%s\\Shell\\Open" ),																NULL,									NULL,		NULL },
        { HKEY_CLASSES_ROOT,	TEXT( "CLSID\\%s\\Shell\\Open\\Command" ),														NULL,									REG_SZ,		inExePath }
    };
    DWORD				size;

    // Register the registry entries.

    n = sizeof_array( entries );
    for( i = 0; i < n; ++i )
    {
        wsprintf( keyName, entries[ i ].subKey, inClsidString );
        err = RegCreateKeyEx( entries[ i ].rootKey, keyName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &key, NULL );
        require_noerr( err, exit );

        if ( entries[ i ].data )
        {
            size = (DWORD)( ( lstrlen( entries[ i ].data ) + 1 ) * sizeof( TCHAR ) );
            err = RegSetValueEx( key, entries[ i ].valueName, 0, entries[ i ].valueType, (LPBYTE) entries[ i ].data, size );
            require_noerr( err, exit );
        }

        RegCloseKey( key );
    }

exit:
    return;
}
Example #27
0
Config::Config()
{
    // Check defaults
    Q_ASSERT(sizeof_array(keys_quint32)   == CFG_QUINT32_NUM);
    Q_ASSERT(sizeof_array(def_quint32)    == CFG_QUINT32_NUM);
    Q_ASSERT(sizeof_array(keys_string)    == CFG_STRING_NUM);
    Q_ASSERT(sizeof_array(def_string)     == CFG_STRING_NUM);
    Q_ASSERT(sizeof_array(keys_bool)      == CFG_BOOL_NUM);
    Q_ASSERT(sizeof_array(def_bool)       == CFG_BOOL_NUM);
    Q_ASSERT(sizeof_array(keys_variant)   == CFG_VARIANT_NUM);
    Q_ASSERT(sizeof_array(def_float)      == CFG_FLOAT_NUM);
    Q_ASSERT(sizeof_array(keys_float)     == CFG_FLOAT_NUM);

    openSettings();
}
Example #28
0
talent_t::~talent_t()
{
  for ( size_t i = 0; i < sizeof_array( t_rank_spells ); i++ )
  {
    if ( t_rank_spells[ i ] != this && t_rank_spells[ i ] != t_default_rank )
      delete t_rank_spells[ i ];
  }

  delete t_default_rank;
}
Example #29
0
ay::ay()
{
    for(unsigned long i = 0; i < sizeof_array(ay::levels_ay); i++)
    {
        ay::levels_ay[i] = (ay::init_levels_ay[i / 2]) / 6;
        ay::levels_ym[i] = (ay::init_levels_ym[i]) / 6;
    }
    songinfo = 0;
    ayReset();
}
Example #30
0
MotorTestWizardPage::MotorTestWizardPage(QWidget *parent)
    : OnOffWizardPage(parent),
      m_timer(new QTimer(this)),
      m_theta(0.0)
{
    memset(m_on, false, sizeof_array(m_on) * sizeof(bool));
    setTitle(tr("Motor Test"));
    connect(this, SIGNAL(on(quint16)), SLOT(motorOn(quint16)));
    connect(this, SIGNAL(off(quint16)), SLOT(motorOff(quint16)));
}