comparison src/audio/SDL_audiodev.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
22 22
23 /* Get the name of the audio device we use for output */ 23 /* Get the name of the audio device we use for output */
24 24
25 #if defined(unix) || defined(__unix__) || defined(__riscos__) 25 #if defined(unix) || defined(__unix__) || defined(__riscos__)
26 26
27 #include <stdlib.h>
28 #include <stdio.h>
29 #include <fcntl.h> 27 #include <fcntl.h>
30 #include <sys/types.h> 28 #include <sys/types.h>
31 #include <sys/stat.h> 29 #include <sys/stat.h>
32 #include <string.h>
33 30
31 #include "SDL_stdlib.h"
32 #include "SDL_string.h"
34 #include "SDL_audiodev_c.h" 33 #include "SDL_audiodev_c.h"
35 34
36 #ifndef _PATH_DEV_DSP 35 #ifndef _PATH_DEV_DSP
37 #if defined(__NetBSD__) || defined(__OpenBSD__) 36 #if defined(__NetBSD__) || defined(__OpenBSD__)
38 #define _PATH_DEV_DSP "/dev/audio" 37 #define _PATH_DEV_DSP "/dev/audio"
78 int exists, instance; 77 int exists, instance;
79 struct stat sb; 78 struct stat sb;
80 79
81 instance = 1; 80 instance = 1;
82 do { /* Don't use errno ENOENT - it may not be thread-safe */ 81 do { /* Don't use errno ENOENT - it may not be thread-safe */
83 sprintf(audiopath, "%s%d", audiodev, instance++); 82 SDL_snprintf(audiopath, SDL_arraysize(audiopath),
83 "%s%d", audiodev, instance++);
84 exists = 0; 84 exists = 0;
85 if ( stat(audiopath, &sb) == 0 ) { 85 if ( stat(audiopath, &sb) == 0 ) {
86 exists = 1; 86 exists = 1;
87 audio_fd = open(audiopath, flags, 0); 87 audio_fd = open(audiopath, flags, 0);
88 } 88 }
98 98
99 #elif defined(_AIX) 99 #elif defined(_AIX)
100 100
101 /* Get the name of the audio device we use for output */ 101 /* Get the name of the audio device we use for output */
102 102
103 #include <stdlib.h>
104 #include <sys/types.h> 103 #include <sys/types.h>
105 #include <sys/stat.h> 104 #include <sys/stat.h>
106 #include <string.h>
107 105
106 #include "SDL_stdlib.h"
107 #include "SDL_string.h"
108 #include "SDL_audiodev_c.h" 108 #include "SDL_audiodev_c.h"
109 109
110 #ifndef _PATH_DEV_DSP 110 #ifndef _PATH_DEV_DSP
111 #define _PATH_DEV_DSP "/dev/%caud%c/%c" 111 #define _PATH_DEV_DSP "/dev/%caud%c/%c"
112 #endif 112 #endif
156 return audio_fd; 156 return audio_fd;
157 } 157 }
158 158
159 cycle = 0; 159 cycle = 0;
160 while( devsettings[cycle][0] != '\0' ) { 160 while( devsettings[cycle][0] != '\0' ) {
161 sprintf( audiopath, 161 SDL_snprintf( audiopath, SDL_arraysize(audiopath),
162 _PATH_DEV_DSP, 162 _PATH_DEV_DSP,
163 devsettings[cycle][0], 163 devsettings[cycle][0],
164 devsettings[cycle][1], 164 devsettings[cycle][1],
165 devsettings[cycle][2]); 165 devsettings[cycle][2]);
166 166