Changeset 1355 for libcaca/trunk/src
- Timestamp:
- Nov 12, 2006, 11:06:35 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/src/cacaplay.c
r1352 r1355 33 33 caca_display_t *dp; 34 34 unsigned char *buf = NULL; 35 long int bytes , total = 0;35 long int bytes = 0, total = 0; 36 36 int fd; 37 37 … … 59 59 caca_event_t ev; 60 60 int ret = caca_get_event(dp, CACA_EVENT_ANY, &ev, 0); 61 int eof = 0; 61 62 62 63 if(ret && ev.type & CACA_EVENT_KEY_PRESS) 63 64 break; 65 66 if(bytes == 0) 67 { 68 ssize_t n; 69 buf = realloc(buf, total + 1); 70 n = read(fd, buf + total, 1); 71 if(n < 0) 72 { 73 fprintf(stderr, "%s: read error\n", argv[0]); 74 return -1; 75 } 76 else if(n == 0) 77 { 78 eof = 1; 79 } 80 total += n; 81 } 64 82 65 83 bytes = cucul_import_memory(app, buf, total, "caca"); … … 73 91 caca_refresh_display(dp); 74 92 } 75 else if(bytes == 0) 76 { 77 ssize_t n; 78 buf = realloc(buf, total + 128); 79 n = read(fd, buf + total, 128); 80 if(n < 0) 81 { 82 fprintf(stderr, "%s: read error\n", argv[0]); 83 return -1; 84 } 85 total += n; 86 } 87 else /* bytes < 0 */ 93 else if(bytes < 0) 88 94 { 89 95 fprintf(stderr, "%s: corrupted caca file\n", argv[0]); 90 return -1;96 break; 91 97 } 98 99 if(eof) 100 break; 92 101 } 102 103 caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1); 93 104 94 105 /* Clean up */
Note: See TracChangeset
for help on using the changeset viewer.