Mercurial > pidgin.yaz
comparison src/sound.c @ 2680:ab2ca2770d2e
[gaim-migrate @ 2693]
no goto!!!!
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Tue, 06 Nov 2001 21:30:31 +0000 |
parents | 61952dde7677 |
children | 0899f8c99a15 |
comparison
equal
deleted
inserted
replaced
2679:94aa499ecd39 | 2680:ab2ca2770d2e |
---|---|
245 struct stat stat_buf; | 245 struct stat stat_buf; |
246 unsigned char *buf = NULL; | 246 unsigned char *buf = NULL; |
247 int result = 0; | 247 int result = 0; |
248 int fd = -1; | 248 int fd = -1; |
249 | 249 |
250 if (!can_play_artsc()) | |
251 return 0; | |
252 | |
250 fd = open(file, O_RDONLY); | 253 fd = open(file, O_RDONLY); |
251 if (fd < 0) | 254 if (fd < 0) |
252 goto out; | 255 return 0; |
253 | 256 |
254 if (!can_play_artsc()) | 257 if (fstat(fd, &stat_buf)) { |
255 goto out; | 258 close(fd); |
256 | 259 return 0; |
257 if (fstat(fd, &stat_buf)) | 260 } |
258 goto out; | 261 |
259 | 262 if (!stat_buf.st_size) { |
260 if (!stat_buf.st_size) | 263 close(fd); |
261 goto out; | 264 return 0; |
265 } | |
262 | 266 |
263 buf = g_malloc(stat_buf.st_size); | 267 buf = g_malloc(stat_buf.st_size); |
264 if (!buf) | 268 if (!buf) { |
265 goto out; | 269 close(fd); |
266 | 270 return 0; |
267 if (read(fd, buf, stat_buf.st_size) < 0) | 271 } |
268 goto out; | 272 |
273 if (read(fd, buf, stat_buf.st_size) < 0) { | |
274 g_free(buf); | |
275 close(fd); | |
276 return 0; | |
277 } | |
269 | 278 |
270 result = play_artsc(buf, stat_buf.st_size); | 279 result = play_artsc(buf, stat_buf.st_size); |
271 | 280 |
272 out: | 281 g_free(buf); |
273 if (buf) | 282 close(fd); |
274 g_free(buf); | |
275 if (fd != -1) | |
276 close(fd); | |
277 return result; | 283 return result; |
278 } | 284 } |
279 | 285 |
280 #endif /* ARTSC_SOUND */ | 286 #endif /* ARTSC_SOUND */ |
281 | 287 |