comparison src/video/ps2gs/SDL_gsevents.c @ 1338:604d73db6802

Removed uses of stdlib.h and string.h
author Sam Lantinga <slouken@libsdl.org>
date Tue, 07 Feb 2006 09:29:18 +0000
parents 3692456e7b0f
children c71e05b4dc2e
comparison
equal deleted inserted replaced
1337:c687f06c7473 1338:604d73db6802
23 /* Handle the event stream, converting console events into SDL events */ 23 /* Handle the event stream, converting console events into SDL events */
24 24
25 #include <sys/types.h> 25 #include <sys/types.h>
26 #include <sys/time.h> 26 #include <sys/time.h>
27 #include <sys/ioctl.h> 27 #include <sys/ioctl.h>
28 #include <stdlib.h>
29 #include <stdio.h>
30 #include <unistd.h> 28 #include <unistd.h>
31 #include <fcntl.h> 29 #include <fcntl.h>
32 #include <string.h>
33 #include <errno.h> 30 #include <errno.h>
34 #include <limits.h> 31 #include <limits.h>
35 32
36 /* For parsing /proc */ 33 /* For parsing /proc */
37 #include <dirent.h> 34 #include <dirent.h>
40 #include <linux/vt.h> 37 #include <linux/vt.h>
41 #include <linux/kd.h> 38 #include <linux/kd.h>
42 #include <linux/keyboard.h> 39 #include <linux/keyboard.h>
43 40
44 #include "SDL.h" 41 #include "SDL.h"
42 #include "SDL_string.h"
45 #include "SDL_mutex.h" 43 #include "SDL_mutex.h"
46 #include "SDL_sysevents.h" 44 #include "SDL_sysevents.h"
47 #include "SDL_sysvideo.h" 45 #include "SDL_sysvideo.h"
48 #include "SDL_events_c.h" 46 #include "SDL_events_c.h"
49 #include "SDL_gsvideo.h" 47 #include "SDL_gsvideo.h"
255 close(tty0_fd); 253 close(tty0_fd);
256 if ( (geteuid() == 0) && (current_vt > 0) ) { 254 if ( (geteuid() == 0) && (current_vt > 0) ) {
257 for ( i=0; vcs[i] && (keyboard_fd < 0); ++i ) { 255 for ( i=0; vcs[i] && (keyboard_fd < 0); ++i ) {
258 char vtpath[12]; 256 char vtpath[12];
259 257
260 sprintf(vtpath, vcs[i], current_vt); 258 SDL_snprintf(vtpath, SDL_arraysize(vtpath), vcs[i], current_vt);
261 keyboard_fd = open(vtpath, O_RDWR, 0); 259 keyboard_fd = open(vtpath, O_RDWR, 0);
262 #ifdef DEBUG_KEYBOARD 260 #ifdef DEBUG_KEYBOARD
263 fprintf(stderr, "vtpath = %s, fd = %d\n", 261 fprintf(stderr, "vtpath = %s, fd = %d\n",
264 vtpath, keyboard_fd); 262 vtpath, keyboard_fd);
265 #endif /* DEBUG_KEYBOARD */ 263 #endif /* DEBUG_KEYBOARD */
331 if ( isdigit(entry->d_name[0]) ) { 329 if ( isdigit(entry->d_name[0]) ) {
332 FILE *status; 330 FILE *status;
333 char path[PATH_MAX]; 331 char path[PATH_MAX];
334 char name[PATH_MAX]; 332 char name[PATH_MAX];
335 333
336 sprintf(path, "/proc/%s/status", entry->d_name); 334 SDL_snprintf(path, SDL_arraysize(path), "/proc/%s/status", entry->d_name);
337 status=fopen(path, "r"); 335 status=fopen(path, "r");
338 if ( status ) { 336 if ( status ) {
339 name[0] = '\0'; 337 name[0] = '\0';
340 fscanf(status, "Name: %s", name); 338 fscanf(status, "Name: %s", name);
341 if ( SDL_strcmp(name, wanted_name) == 0 ) { 339 if ( SDL_strcmp(name, wanted_name) == 0 ) {
365 363
366 available = 0; 364 available = 0;
367 proc = opendir("/proc"); 365 proc = opendir("/proc");
368 if ( proc ) { 366 if ( proc ) {
369 while ( (pid=find_pid(proc, "gpm")) > 0 ) { 367 while ( (pid=find_pid(proc, "gpm")) > 0 ) {
370 sprintf(path, "/proc/%d/cmdline", pid); 368 SDL_snprintf(path, SDL_arraysize(path), "/proc/%d/cmdline", pid);
371 cmdline = open(path, O_RDONLY, 0); 369 cmdline = open(path, O_RDONLY, 0);
372 if ( cmdline >= 0 ) { 370 if ( cmdline >= 0 ) {
373 len = read(cmdline, args, sizeof(args)); 371 len = read(cmdline, args, sizeof(args));
374 arg = args; 372 arg = args;
375 while ( len > 0 ) { 373 while ( len > 0 ) {