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


C++ SDL_strlcpy函数代码示例

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


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

示例1: WinMain

/* This is where execution begins [windowed apps] */
int WINAPI
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPTSTR szCmdLine, int sw)
{
    char **argv;
    int argc;
    char *cmdline;
    char *bufp;
    size_t nLen;

    /* Grab the command line */
    bufp = GetCommandLine();
    nLen = SDL_strlen(bufp) + 1;
    cmdline = SDL_stack_alloc(char, nLen);
    if (cmdline == NULL) {
        return OutOfMemory();
    }
    SDL_strlcpy(cmdline, bufp, nLen);

    /* Parse it into argv and argc */
    argc = ParseCommandLine(cmdline, NULL);
    argv = SDL_stack_alloc(char *, argc + 1);
    if (argv == NULL) {
        return OutOfMemory();
    }
    ParseCommandLine(cmdline, argv);

    /* Run the main program */
    console_main(argc, argv);

    /* Hush little compiler, don't you cry... */
    return 0;
}
开发者ID:boyxuper,项目名称:kivy-ios,代码行数:33,代码来源:SDL_windows_main.c

示例2: SDL_strlcpy

Entities::Entities(int grandezza,bool solido,SDL_Texture* texture,SDL_Renderer* renderizzatore,SDL_Rect* tile, int frame, char* tipo,char* contenuto) {
	Entities::dimensione = grandezza;
	Entities::texture = texture;
	Entities::renderizzatore = renderizzatore;
	Entities::tile = tile;
	Entities::solido = solido;
	Entities::frame = frame;
	Entities::frame_attuale = 0;
	Entities::tipo = (char*)SDL_malloc(SDL_strlen(tipo));
	SDL_strlcpy(Entities::tipo,tipo,sizeof(char)*(SDL_strlen(tipo)+1));
	Entities::contenuto = (char*)SDL_malloc(SDL_strlen(contenuto));
	SDL_strlcpy(Entities::contenuto,contenuto,sizeof(char*)*(SDL_strlen(contenuto)+1));
}
开发者ID:barba-anto,项目名称:PC-Game4D1,代码行数:13,代码来源:Entities.cpp

示例3: string_cat

char * string_cat(const char * s1, const char * s2) {
	int len = SDL_strlen(s1) + SDL_strlen(s2) + 1;
	char * buf = malloc(len);
	SDL_strlcpy(buf, s1, len);
	SDL_strlcat(buf, s2, len);
	return buf;
}
开发者ID:cbhuber,项目名称:Games,代码行数:7,代码来源:global.c

示例4: SDL_putenv

/* Put a variable of the form "name=value" into the environment */
int SDL_putenv(const char *variable)
{
	size_t bufferlen;
	char *value;
	const char *sep;

	sep = SDL_strchr(variable, '=');
	if ( sep == NULL ) {
		return -1;
	}
	bufferlen = SDL_strlen(variable)+1;
	if ( bufferlen > SDL_envmemlen ) {
		char *newmem = (char *)SDL_realloc(SDL_envmem, bufferlen);
		if ( newmem == NULL ) {
			return -1;
		}
		SDL_envmem = newmem;
		SDL_envmemlen = bufferlen;
	}
	SDL_strlcpy(SDL_envmem, variable, bufferlen);
	value = SDL_envmem + (sep - variable);
	*value++ = '\0';
	if ( !SetEnvironmentVariable(SDL_envmem, *value ? value : NULL) ) {
		return -1;
	}
	return 0;
}
开发者ID:ahpho,项目名称:wowmapviewer,代码行数:28,代码来源:SDL_getenv.c

示例5: PND_gl_loadlibrary

int
PND_gl_loadlibrary(_THIS, const char *path)
{
    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;

    /* Check if OpenGL ES library is specified for GF driver */
    if (path == NULL) {
        path = SDL_getenv("SDL_OPENGL_LIBRARY");
        if (path == NULL) {
            path = SDL_getenv("SDL_OPENGLES_LIBRARY");
        }
    }

    /* Check if default library loading requested */
    if (path == NULL) {
        /* Already linked with GF library which provides egl* subset of  */
        /* functions, use Common profile of OpenGL ES library by default */
        path = "/usr/lib/libGLES_CM.so";
    }

    /* Load dynamic library */
    _this->gl_config.dll_handle = SDL_LoadObject(path);
    if (!_this->gl_config.dll_handle) {
        /* Failed to load new GL ES library */
        SDL_SetError("PND: Failed to locate OpenGL ES library");
        return -1;
    }

    /* Store OpenGL ES library path and name */
    SDL_strlcpy(_this->gl_config.driver_path, path,
                SDL_arraysize(_this->gl_config.driver_path));

    /* New OpenGL ES library is loaded */
    return 0;
}
开发者ID:g-truc,项目名称:shooter,代码行数:35,代码来源:SDL_pandora.c

示例6: OpenAudioPath

static int
OpenAudioPath(char *path, int maxlen, int flags, int classic)
{
    struct stat sb;
    int cycle = 0;
    int fd = OpenUserDefinedDevice(path, maxlen, flags);

    if (fd != -1) {
        return fd;
    }

    /* !!! FIXME: do we really need a table here? */
    while (devsettings[cycle][0] != '\0') {
        char audiopath[1024];
        SDL_snprintf(audiopath, SDL_arraysize(audiopath),
                     _PATH_DEV_DSP,
                     devsettings[cycle][0],
                     devsettings[cycle][1], devsettings[cycle][2]);

        if (stat(audiopath, &sb) == 0) {
            fd = open(audiopath, flags, 0);
            if (fd > 0) {
                if (path != NULL) {
                    SDL_strlcpy(path, audiopath, maxlen);
                }
                return fd;
            }
        }
    }
    return -1;
}
开发者ID:1414648814,项目名称:Torque3D,代码行数:31,代码来源:SDL_paudio.c

示例7: SDL_OpenAudioPath

int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic)
{
    struct stat sb;
    int         audio_fd;
    char        audiopath[1024];
    int         cycle;

    audio_fd = OpenUserDefinedDevice(path,maxlen,flags);
    if ( audio_fd != -1 ) {
        return audio_fd;
    }

    cycle    = 0;
    while( devsettings[cycle][0] != '\0' ) {
        SDL_snprintf( audiopath, SDL_arraysize(audiopath),
                 _PATH_DEV_DSP,
                 devsettings[cycle][0],
                 devsettings[cycle][1],
                 devsettings[cycle][2]);

	if ( stat(audiopath, &sb) == 0 ) {
	    audio_fd = open(audiopath, flags, 0);
	    if ( audio_fd > 0 ) {
		if ( path != NULL ) {
		    SDL_strlcpy( path, audiopath, maxlen );
		}
	        return audio_fd;
	    }
	}
    }
    return -1;
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:32,代码来源:SDL_audiodev.c

示例8: ph_GL_LoadLibrary

int ph_GL_LoadLibrary(_THIS, const char* path)
{
    void* handle;
    int dlopen_flags=RTLD_WORLD | RTLD_GROUP;

    if (this->gl_config.dll_handle!=NULL)
    {
        return 0;
    }

    handle = dlopen(path, dlopen_flags);

    if (handle==NULL)
    {
        SDL_SetError("ph_GL_LoadLibrary(): Could not load OpenGL library");
        return -1;
    }

    this->gl_config.dll_handle = handle;
    this->gl_config.driver_loaded = 1;

    SDL_strlcpy(this->gl_config.driver_path, path, SDL_arraysize(this->gl_config.driver_path));

    return 0;
}
开发者ID:ahpho,项目名称:wowmapviewer,代码行数:25,代码来源:SDL_ph_gl.c

示例9: SetMouseAccel

/* Sets the mouse acceleration from a string of the form:
	2/1/0
   The first number is the numerator, followed by the acceleration
   denumenator and threshold.
*/
static void SetMouseAccel(_THIS, const char *accel_param)
{
	int i;
	size_t len;
	int accel_value[3];
	char *mouse_param, *mouse_param_buf, *pin;

	len = SDL_strlen(accel_param)+1;
	mouse_param_buf = SDL_stack_alloc(char, len);
	if ( ! mouse_param_buf ) {
		return;
	}
	SDL_strlcpy(mouse_param_buf, accel_param, len);
	mouse_param = mouse_param_buf;

	for ( i=0; (i < 3) && mouse_param; ++i ) {
		pin = SDL_strchr(mouse_param, '/');
		if ( pin ) {
			*pin = '\0';
		}
		accel_value[i] = atoi(mouse_param);
		if ( pin ) {
			mouse_param = pin+1;
		} else {
			mouse_param = NULL;
		}
	}
	if ( mouse_param_buf ) {
		XChangePointerControl(SDL_Display, True, True,
			accel_value[0], accel_value[1], accel_value[2]);
		SDL_free(mouse_param_buf);
	}
}
开发者ID:BITINT,项目名称:DEFCON2,代码行数:38,代码来源:SDL_x11mouse.c

示例10: get_caps

static void get_caps(struct udev_device *dev, struct udev_device *pdev, const char *attr, unsigned long *bitmask, size_t bitmask_len)
{
    const char *value;
    char text[4096];
    char *word;
    int i;
    unsigned long v;

    SDL_memset(bitmask, 0, bitmask_len*sizeof(*bitmask));
    value = _this->udev_device_get_sysattr_value(pdev, attr);
    if (!value) {
        return;
    }

    SDL_strlcpy(text, value, sizeof(text));
    i = 0;
    while ((word = SDL_strrchr(text, ' ')) != NULL) {
        v = SDL_strtoul(word+1, NULL, 16);
        if (i < bitmask_len) {
            bitmask[i] = v;
        }
        ++i;
        *word = '\0';
    }
    v = SDL_strtoul(text, NULL, 16);
    if (i < bitmask_len) {
        bitmask[i] = v;
    }
}
开发者ID:Derek-OBrien,项目名称:DsdlEngine,代码行数:29,代码来源:SDL_udev.c

示例11: fileData

void ResourceSerializer::SerializeToBinary(const char* szReadPath, const char* szSavePath, const char* szFilename)
{
	FileSystem::FileData fileData(255);
	FileSystem::GetListOfFiles(szReadPath, "*.tga", fileData);

	SDL_RWops* pRW = NULL;

	if(szSavePath != NULL)
	{
		const size_t uSize = 255;
		char sFullPath[uSize];
		SDL_strlcpy(sFullPath, szSavePath, uSize);
		SDL_strlcat(sFullPath, szFilename, uSize);
		pRW = SDL_RWFromFile(sFullPath, "wb");
	}
	else
	{
		pRW = SDL_RWFromFile(szFilename, "wb");
	}

	ASSERT(pRW != NULL);
	SDL_RWwrite(pRW, &s_szWatermark[0], SDL_strlen(s_szWatermark) * sizeof(char), 1);

	for(auto it = fileData.Begin(); !it.IsEnd(); ++it)
	{
		IMGHeader imgHeader;
		SDL_Surface* pSurface = IMG_tga::Load((*it), &imgHeader);
		if(pSurface != NULL)
		{
			imgHeader.hasPalette = pSurface->format->palette != NULL ? true : false;

			U8String sName;
			str::GetFilenameAsIs((*it), sName);
			StringCRC hash(sName.CStr());
			int iSize = (imgHeader.width * imgHeader.height) * 4;
			uint32 uHashName = hash.Get();
			uint32 uBlockSize = (uint32)(sizeof(neko::IMGHeader) + ((size_t)iSize) * sizeof(Uint8)) + (imgHeader.hasPalette ? sizeof(neko::IMGPalette) : (size_t)0);
			
			SDL_RWwrite(pRW, &uBlockSize, sizeof(uint32), 1);
			SDL_RWwrite(pRW, &uHashName, sizeof(uint32), 1);
			SDL_RWwrite(pRW, &imgHeader, sizeof(neko::IMGHeader), 1);

			if(imgHeader.hasPalette)
			{
				IMGPalette palette;
				palette.ncolor = pSurface->format->palette->ncolors;
				Color::Copy(palette.color, *pSurface->format->palette->colors);

				SDL_RWwrite(pRW, &palette, sizeof(neko::IMGPalette), 1);
			}
			
			SDL_RWwrite(pRW, pSurface->pixels, iSize * sizeof(Uint8), 1);
		}
	}

	uint32 uEnd = 0;
	SDL_RWwrite(pRW, &uEnd, sizeof(uint32), 1);

	SDL_RWclose(pRW);
}
开发者ID:olowal,项目名称:neko,代码行数:60,代码来源:ResourceSerializer.cpp

示例12: SDL_SYS_CDInit

int  SDL_SYS_CDInit(void)
{
	static char *checklist[] = {
#if defined(__OPENBSD__)
		"?0 cd?c", "cdrom", NULL
#elif defined(__NETBSD__)
		"?0 cd?d", "?0 cd?c", "cdrom", NULL
#else
		"?0 cd?c", "?0 acd?c", "cdrom", NULL
#endif
	};
	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:ahpho,项目名称:wowmapviewer,代码行数:59,代码来源:SDL_syscdrom.c

示例13: WIN_GL_LoadLibrary

int
WIN_GL_LoadLibrary(_THIS, const char *path)
{
    LPTSTR wpath;
    HANDLE handle;

    if (path == NULL) {
        path = SDL_getenv("SDL_OPENGL_LIBRARY");
    }
    if (path == NULL) {
        path = DEFAULT_OPENGL;
    }
    wpath = WIN_UTF8ToString(path);
    _this->gl_config.dll_handle = LoadLibrary(wpath);
    SDL_free(wpath);
    if (!_this->gl_config.dll_handle) {
        char message[1024];
        SDL_snprintf(message, SDL_arraysize(message), "LoadLibrary(\"%s\")",
                     path);
        WIN_SetError(message);
        return -1;
    }
    SDL_strlcpy(_this->gl_config.driver_path, path,
                SDL_arraysize(_this->gl_config.driver_path));

    /* Allocate OpenGL memory */
    _this->gl_data =
        (struct SDL_GLDriverData *) SDL_calloc(1,
                                               sizeof(struct
                                                      SDL_GLDriverData));
    if (!_this->gl_data) {
        SDL_OutOfMemory();
        return -1;
    }

    /* Load function pointers */
    handle = _this->gl_config.dll_handle;
    _this->gl_data->wglGetProcAddress = (void *(WINAPI *) (const char *))
        GetProcAddress(handle, "wglGetProcAddress");
    _this->gl_data->wglCreateContext = (HGLRC(WINAPI *) (HDC))
        GetProcAddress(handle, "wglCreateContext");
    _this->gl_data->wglDeleteContext = (BOOL(WINAPI *) (HGLRC))
        GetProcAddress(handle, "wglDeleteContext");
    _this->gl_data->wglMakeCurrent = (BOOL(WINAPI *) (HDC, HGLRC))
        GetProcAddress(handle, "wglMakeCurrent");
    _this->gl_data->wglShareLists = (BOOL(WINAPI *) (HGLRC, HGLRC))
        GetProcAddress(handle, "wglShareLists");

    if (!_this->gl_data->wglGetProcAddress ||
        !_this->gl_data->wglCreateContext ||
        !_this->gl_data->wglDeleteContext ||
        !_this->gl_data->wglMakeCurrent) {
        SDL_SetError("Could not retrieve OpenGL functions");
        SDL_UnloadObject(handle);
        return -1;
    }

    return 0;
}
开发者ID:Javilop,项目名称:indielib-crossplatform,代码行数:59,代码来源:SDL_windowsopengl.c

示例14: SDL_AddMouse

int
SDL_AddMouse(const SDL_Mouse * mouse, char *name, int pressure_max,
             int pressure_min, int ends)
{
    SDL_Mouse **mice;
    int selected_mouse;
    int index;
    size_t length;

    if (SDL_GetMouseIndexId(mouse->id) != -1) {
        SDL_SetError("Mouse ID already in use");
    }

    /* Add the mouse to the list of mice */
    mice = (SDL_Mouse **) SDL_realloc(SDL_mice,
                                      (SDL_num_mice + 1) * sizeof(*mice));
    if (!mice) {
        SDL_OutOfMemory();
        return -1;
    }

    SDL_mice = mice;
    index = SDL_num_mice++;

    SDL_mice[index] = (SDL_Mouse *) SDL_malloc(sizeof(*SDL_mice[index]));
    if (!SDL_mice[index]) {
        SDL_OutOfMemory();
        return -1;
    }
    *SDL_mice[index] = *mouse;

    /* we're setting the mouse properties */
    length = 0;
    length = SDL_strlen(name);
    SDL_mice[index]->focus = 0;
    SDL_mice[index]->name = SDL_malloc((length + 2) * sizeof(char));
    SDL_strlcpy(SDL_mice[index]->name, name, length + 1);
    SDL_mice[index]->pressure_max = pressure_max;
    SDL_mice[index]->pressure_min = pressure_min;
    SDL_mice[index]->cursor_shown = SDL_TRUE;
    selected_mouse = SDL_SelectMouse(index);
    SDL_mice[index]->cur_cursor = NULL;
    SDL_mice[index]->def_cursor =
        SDL_CreateCursor(default_cdata, default_cmask, DEFAULT_CWIDTH,
                         DEFAULT_CHEIGHT, DEFAULT_CHOTX, DEFAULT_CHOTY);
    SDL_SetCursor(SDL_mice[index]->def_cursor);
    /* we're assuming that all mice are in the computer sensing zone */
    SDL_mice[index]->proximity = SDL_TRUE;
    /* we're assuming that all mice are working in the absolute position mode
       thanx to that, the users that don't want to use many mice don't have to
       worry about anything */
    SDL_mice[index]->relative_mode = SDL_FALSE;
    SDL_mice[index]->current_end = 0;
    SDL_mice[index]->total_ends = ends;
    SDL_SelectMouse(selected_mouse);

    return index;
}
开发者ID:Avin15,项目名称:dospad,代码行数:58,代码来源:SDL_mouse.c

示例15: SDL_SYS_CDInit

int  SDL_SYS_CDInit(void)
{
    struct {
	char *dir;
	char *name;
    } checklist[] = {
	{"/dev/rdisk", "cdrom"},
	{"/dev", "rrz"},
	{NULL, NULL}};
    char drive[32];
    char *SDLcdrom;
    int i, j, exists;
    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,代码行数:58,代码来源:SDL_syscdrom.c


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