当前位置: 首页>>代码示例>>C++>>正文


C++ SDL_strlen函数代码示例

本文整理汇总了C++中SDL_strlen函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_strlen函数的具体用法?C++ SDL_strlen怎么用?C++ SDL_strlen使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SDL_strlen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetMMerror

static void SetMMerror(char *function, MMRESULT code)
{
    int len;
    char errbuf[MAXERRORLENGTH];

    SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function);
    len = SDL_strlen(errbuf);
    waveOutGetErrorText(code, errbuf+len, MAXERRORLENGTH-len);
    SDL_SetError("%s",errbuf);
}
开发者ID:0omega,项目名称:platform_external_qemu,代码行数:10,代码来源:SDL_mmeaudio.c

示例2: LogOutput

void LogOutput( void* userData, int category, SDL_LogPriority priority, const char* message )
{
	size_t strLen = SDL_strlen( message );
	SDL_RWwrite( logFile, message, 1, strLen );
#ifdef WIN32
	SDL_RWwrite( logFile, "\r\n", 1, 2 );
#else
	#warning "NO END OF LINE DEFINED FOR THIS PLATFORM!"
#endif
}
开发者ID:JesseRahikainen,项目名称:LD33_Oszmot,代码行数:10,代码来源:main.c

示例3: SDL_SYS_CDInit

int  SDL_SYS_CDInit(void)
{
	/* checklist: /dev/cdrom,/dev/cd?c /dev/acd?c
			/dev/matcd?c /dev/mcd?c /dev/scd?c */
	static char *checklist[] = {
	"cdrom", "?0 cd?", "?0 acd?", "?0 matcd?", "?0 mcd?", "?0 scd?",NULL
	};
	char *SDLcdrom;
	int i, j, exists;
	char drive[32];
	struct stat stbuf;

	/* Fill in our driver capabilities */
	SDL_CDcaps.Name = SDL_SYS_CDName;
	SDL_CDcaps.Open = SDL_SYS_CDOpen;
	SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
	SDL_CDcaps.Status = SDL_SYS_CDStatus;
	SDL_CDcaps.Play = SDL_SYS_CDPlay;
	SDL_CDcaps.Pause = SDL_SYS_CDPause;
	SDL_CDcaps.Resume = SDL_SYS_CDResume;
	SDL_CDcaps.Stop = SDL_SYS_CDStop;
	SDL_CDcaps.Eject = SDL_SYS_CDEject;
	SDL_CDcaps.Close = SDL_SYS_CDClose;

	/* Look in the environment for our CD-ROM drive list */
	SDLcdrom = SDL_getenv("SDL_CDROM");	/* ':' separated list of devices */
	if ( SDLcdrom != NULL ) {
		char *cdpath, *delim;
		size_t len = SDL_strlen(SDLcdrom)+1;
		cdpath = SDL_stack_alloc(char, len);
		if ( cdpath != NULL ) {
			SDL_strlcpy(cdpath, SDLcdrom, len);
			SDLcdrom = cdpath;
			do {
				delim = SDL_strchr(SDLcdrom, ':');
				if ( delim ) {
					*delim++ = '\0';
				}
				if ( CheckDrive(SDLcdrom, &stbuf) > 0 ) {
					AddDrive(SDLcdrom, &stbuf);
				}
				if ( delim ) {
					SDLcdrom = delim;
				} else {
					SDLcdrom = NULL;
				}
			} while ( SDLcdrom );
			SDL_stack_free(cdpath);
		}

		/* If we found our drives, there's nothing left to do */
		if ( SDL_numcds > 0 ) {
			return(0);
		}
	}
开发者ID:0omega,项目名称:platform_external_qemu,代码行数:55,代码来源:SDL_syscdrom.c

示例4: SDL_strlen

bool SDLFileHandler::writeString(std::stringstream text)
{
	std::string sText = text.str();
	size_t len = SDL_strlen(sText.c_str());
	if (SDL_RWwrite(file, &sText, sizeof(text), len) != len)
	{
		std::cout << "[ERROR]: text couldn't be written" << std::endl;
		return false;
	}
	return true;
}
开发者ID:Fishandchips321,项目名称:my-SDL-game,代码行数:11,代码来源:SDLFileHandler.cpp

示例5: SDL_strlen

char *SDL_strstr(const char *haystack, const char *needle)
{
    size_t length = SDL_strlen(needle);
    while ( *haystack ) {
        if ( SDL_strncmp(haystack, needle, length) == 0 ) {
            return (char *)haystack;
        }
	++haystack;
    }
    return NULL;
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:11,代码来源:SDL_string.c

示例6: SDL_SYS_CDInit

int  SDL_SYS_CDInit(void)
{
	
	static char *checklist[] = {
	"?0 rsr?", NULL
	};
	char *SDLcdrom;
	int i, j, exists;
	char drive[32];
	struct stat stbuf;

	
	SDL_CDcaps.Name = SDL_SYS_CDName;
	SDL_CDcaps.Open = SDL_SYS_CDOpen;
	SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
	SDL_CDcaps.Status = SDL_SYS_CDStatus;
	SDL_CDcaps.Play = SDL_SYS_CDPlay;
	SDL_CDcaps.Pause = SDL_SYS_CDPause;
	SDL_CDcaps.Resume = SDL_SYS_CDResume;
	SDL_CDcaps.Stop = SDL_SYS_CDStop;
	SDL_CDcaps.Eject = SDL_SYS_CDEject;
	SDL_CDcaps.Close = SDL_SYS_CDClose;

	
	SDLcdrom = SDL_getenv("SDL_CDROM");	
	if ( SDLcdrom != NULL ) {
		char *cdpath, *delim;
		size_t len = SDL_strlen(SDLcdrom)+1;
		cdpath = SDL_stack_alloc(char, len);
		if ( cdpath != NULL ) {
			SDL_strlcpy(cdpath, SDLcdrom, len);
			SDLcdrom = cdpath;
			do {
				delim = SDL_strchr(SDLcdrom, ':');
				if ( delim ) {
					*delim++ = '\0';
				}
				if ( CheckDrive(SDLcdrom, &stbuf) > 0 ) {
					AddDrive(SDLcdrom, &stbuf);
				}
				if ( delim ) {
					SDLcdrom = delim;
				} else {
					SDLcdrom = NULL;
				}
			} while ( SDLcdrom );
			SDL_stack_free(cdpath);
		}

		
		if ( SDL_numcds > 0 ) {
			return(0);
		}
	}
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:54,代码来源:SDL_syscdrom.c

示例7: SDL_strlcpy

size_t
SDL_strlcpy(char *dst, const char *src, size_t maxlen)
{
    size_t srclen = SDL_strlen(src);
    if (maxlen > 0) {
        size_t len = SDL_min(srclen, maxlen - 1);
        SDL_memcpy(dst, src, len);
        dst[len] = '\0';
    }
    return srclen;
}
开发者ID:BoonsNaibot,项目名称:kivy-ios,代码行数:11,代码来源:SDL_string.c

示例8: SDL_GameControllerMappingForGUID

/*
 * Get the mapping string for this GUID
 */
char *
SDL_GameControllerMappingForGUID(SDL_JoystickGUID guid)
{
    char *pMappingString = NULL;
    ControllerMapping_t *mapping = SDL_PrivateGetControllerMappingForGUID(&guid);
    if (mapping) {
        char pchGUID[33];
        size_t needed;
        SDL_JoystickGetGUIDString(guid, pchGUID, sizeof(pchGUID));
        /* allocate enough memory for GUID + ',' + name + ',' + mapping + \0 */
        needed = SDL_strlen(pchGUID) + 1 + SDL_strlen(mapping->name) + 1 + SDL_strlen(mapping->mapping) + 1;
        pMappingString = SDL_malloc(needed);
        if (!pMappingString) {
            SDL_OutOfMemory();
            return NULL;
        }
        SDL_snprintf(pMappingString, needed, "%s,%s,%s", pchGUID, mapping->name, mapping->mapping);
    }
    return pMappingString;
}
开发者ID:antkillerfarm,项目名称:SDL,代码行数:23,代码来源:SDL_gamecontroller.c

示例9: DIB_CreateWindow

int DIB_CreateWindow(_THIS)
{
	char *windowid;

	SDL_RegisterApp(NULL, 0, 0);

	windowid = SDL_getenv("SDL_WINDOWID");
	SDL_windowid = (windowid != NULL);
	if ( SDL_windowid ) {
#if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
		
		wchar_t *windowid_t = SDL_malloc((SDL_strlen(windowid) + 1) * sizeof(wchar_t));
		MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, windowid, -1, windowid_t, SDL_strlen(windowid) + 1);
		SDL_Window = (HWND)wcstol(windowid_t, NULL, 0);
		SDL_free(windowid_t);
#else
		SDL_Window = (HWND)((size_t)SDL_strtoull(windowid, NULL, 0));
#endif
		if ( SDL_Window == NULL ) {
			SDL_SetError("Couldn't get user specified window");
			return(-1);
		}

		userWindowProc = (WNDPROCTYPE)GetWindowLongPtr(SDL_Window, GWLP_WNDPROC);
		SetWindowLongPtr(SDL_Window, GWLP_WNDPROC, (LONG_PTR)WinMessage);
	} else {
		SDL_Window = CreateWindow(SDL_Appname, SDL_Appname,
                        (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX),
                        CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL, SDL_Instance, NULL);
		if ( SDL_Window == NULL ) {
			SDL_SetError("Couldn't create window");
			return(-1);
		}
		ShowWindow(SDL_Window, SW_HIDE);
	}

	WIN_FlushMessageQueue();

	return(0);
}
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:40,代码来源:SDL_dibevents.c

示例10: SDL_AddTouch

int
SDL_AddTouch(const SDL_Touch * touch, char *name)
{
    SDL_Touch **touchPads;
    int index;
    size_t length;

    if (SDL_GetTouchIndexId(touch->id) != -1) {
        SDL_SetError("Touch ID already in use");
    }

    /* Add the touch to the list of touch */
    touchPads = (SDL_Touch **) SDL_realloc(SDL_touchPads,
                                      (SDL_num_touch + 1) * sizeof(*touch));
    if (!touchPads) {
        SDL_OutOfMemory();
        return -1;
    }

    SDL_touchPads = touchPads;
    index = SDL_num_touch++;

    SDL_touchPads[index] = (SDL_Touch *) SDL_malloc(sizeof(*SDL_touchPads[index]));
    if (!SDL_touchPads[index]) {
        SDL_OutOfMemory();
        return -1;
    }
    SDL_memcpy(SDL_touchPads[index], touch, sizeof(*touch));

    /* we're setting the touch properties */
    length = 0;
    length = SDL_strlen(name);
    SDL_touchPads[index]->focus = 0;
    SDL_touchPads[index]->name = SDL_malloc((length + 2) * sizeof(char));
    SDL_strlcpy(SDL_touchPads[index]->name, name, length + 1);   

    SDL_touchPads[index]->num_fingers = 0;
    SDL_touchPads[index]->max_fingers = 1;
    SDL_touchPads[index]->fingers = (SDL_Finger **) SDL_malloc(sizeof(SDL_Finger*));
    SDL_touchPads[index]->fingers[0] = NULL;
    SDL_touchPads[index]->buttonstate = 0;
    SDL_touchPads[index]->relative_mode = SDL_FALSE;
    SDL_touchPads[index]->flush_motion = SDL_FALSE;
    
    SDL_touchPads[index]->xres = (1<<(16-1));
    SDL_touchPads[index]->yres = (1<<(16-1));
    SDL_touchPads[index]->pressureres = (1<<(16-1));
    //Do I want this here? Probably
    SDL_GestureAddTouch(SDL_touchPads[index]);

    return index;
}
开发者ID:DarkWolk,项目名称:libsdl,代码行数:52,代码来源:SDL_touch.c

示例11: RWopsSetUp

void
RWopsSetUp(void *arg)
{
    int fileLen;
    FILE *handle;
    int writtenLen;
    int result;

    /* Clean up from previous runs (if any); ignore errors */
    remove(RWopsReadTestFilename);
    remove(RWopsWriteTestFilename);
    remove(RWopsAlphabetFilename);

    /* Create a test file */
    handle = fopen(RWopsReadTestFilename, "w");
    SDLTest_AssertCheck(handle != NULL, "Verify creation of file '%s' returned non NULL handle", RWopsReadTestFilename);
        if (handle == NULL) return;

    /* Write some known text into it */
    fileLen = SDL_strlen(RWopsHelloWorldTestString);
    writtenLen = (int)fwrite(RWopsHelloWorldTestString, 1, fileLen, handle);
    SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", fileLen, writtenLen);
    result = fclose(handle);
    SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result);

    /* Create a second test file */
    handle = fopen(RWopsAlphabetFilename, "w");
    SDLTest_AssertCheck(handle != NULL, "Verify creation of file '%s' returned non NULL handle", RWopsAlphabetFilename);
        if (handle == NULL) return;

    /* Write alphabet text into it */
    fileLen = SDL_strlen(RWopsAlphabetString);
    writtenLen = (int)fwrite(RWopsAlphabetString, 1, fileLen, handle);
    SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", fileLen, writtenLen);
    result = fclose(handle);
    SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result);

    SDLTest_AssertPass("Creation of test file completed");
}
开发者ID:AaronPerl,项目名称:OpenHand,代码行数:39,代码来源:testautomation_rwops.c

示例12: inputhandleText

/*!
 * Handle text events (if we were to use SDL2)
*/
void inputhandleText(SDL_TextInputEvent *Tevent)
{
	size_t *newtextsize = NULL;
	int size = 	SDL_strlen(Tevent->text);
	if (size)
	{
		if (utf8Buf)
		{
			// clean up memory from last use.
			free(utf8Buf);
			utf8Buf = NULL;
		}
		utf8Buf = UTF8toUTF32(Tevent->text, newtextsize);
		debug(LOG_INPUT, "Keyboard: text input \"%s\"", Tevent->text);
		inputAddBuffer(CurrentKey, *utf8Buf);
		if (SDL_strlen(text) + SDL_strlen(Tevent->text) < sizeof(text))
		{
			SDL_strlcat(text, Tevent->text, sizeof(text));
		}
		debug(LOG_INPUT, "adding text inputed: %s, to string [%s]", Tevent->text, text);
	}
}
开发者ID:ilario,项目名称:warzone2100,代码行数:25,代码来源:main_sdl.cpp

示例13: PrintText

static void
PrintText(char *text)
{
    unsigned char *spot, expanded[1024];

    expanded[0] = '\0';
    for ( spot = text; *spot; ++spot )
    {
        size_t length = SDL_strlen(expanded);
        SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", *spot);
    }
    SDL_Log("Text (%s): \"%s%s\"\n", expanded, *text == '"' ? "\\" : "", text);
}
开发者ID:Chenhx,项目名称:moai-dev,代码行数:13,代码来源:checkkeys.c

示例14: SDL_strdup

char *
SDL_strdup(const char *string)
{
#if defined(HAVE_STRDUP)
    return strdup(string);
#else
    size_t len = SDL_strlen(string) + 1;
    char *newstr = SDL_malloc(len);
    if (newstr) {
        SDL_strlcpy(newstr, string, len);
    }
    return newstr;
#endif /* HAVE_STRDUP */
}
开发者ID:phossy,项目名称:bloq,代码行数:14,代码来源:SDL_string.c

示例15: cfg_SaveFile

// Saves out the file.
int cfg_SaveFile( void* cfgFile )
{
	assert( cfgFile != NULL );
	int success = 0;

	CFGFile* file = (CFGFile*)cfgFile;
	char* outBuffer = NULL;
	SDL_RWops* rwopsFile = NULL;

	char strVal[32];

	int writeNewLine = 0;
	int count = sb_Count( file->sbAttributes );
	for( int i = 0; i < count; ++i ) {
		char* c = NULL;
		if( writeNewLine ) {
			c = sb_Add( outBuffer, 1 );
			(*c) = '\n';
		}
		writeNewLine = 1;

		// write out attribute name
		size_t attrLen = SDL_strlen( file->sbAttributes[i].fileName );
		c = sb_Add( outBuffer, attrLen );
		SDL_memcpy( c, file->sbAttributes[i].fileName, attrLen );

		// write out separator
		c = sb_Add( outBuffer, 3 );
		SDL_memcpy( c, " = ", 3 );

		// write out value
		int pl = SDL_snprintf( strVal, sizeof( strVal ), "%i", file->sbAttributes[i].value );
		if( pl >= ARRAY_SIZE( strVal ) ) {
			llog( LOG_ERROR, "Problem writing out configuration file value, value to long. File: %s   Name: %s", file->filePath, file->sbAttributes[i].fileName );
			goto clean_up;
		} else {
			c = sb_Add( outBuffer, pl );
			SDL_memcpy( c, strVal, pl );
		}
	}

	rwopsFile = SDL_RWFromFile( file->filePath, "w" );
	SDL_RWwrite( rwopsFile, outBuffer, sizeof( char ), sb_Count( outBuffer ) );

clean_up:
	SDL_RWclose( rwopsFile );
	sb_Release( outBuffer );
	return success;
}
开发者ID:JesseRahikainen,项目名称:Xturos,代码行数:50,代码来源:cfgFile.c


注:本文中的SDL_strlen函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。