istereo2
annotate src/assman.c @ 30:900651a2f401
foo
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 08 Oct 2015 06:54:18 +0300 |
parents | |
children |
rev | line source |
---|---|
nuclear@7 | 1 #include <stdio.h> |
nuclear@7 | 2 #include "assman.h" |
nuclear@7 | 3 |
nuclear@7 | 4 int ass_fgetc(ass_file *fp) |
nuclear@7 | 5 { |
nuclear@7 | 6 unsigned char c; |
nuclear@7 | 7 |
nuclear@7 | 8 if(ass_fread(&c, 1, 1, fp) < 1) { |
nuclear@7 | 9 return -1; |
nuclear@7 | 10 } |
nuclear@7 | 11 return (int)c; |
nuclear@7 | 12 } |
nuclear@7 | 13 |
nuclear@7 | 14 char *ass_fgets(char *s, int size, ass_file *fp) |
nuclear@7 | 15 { |
nuclear@7 | 16 int i, c; |
nuclear@7 | 17 char *ptr = s; |
nuclear@7 | 18 |
nuclear@7 | 19 if(!size) return 0; |
nuclear@7 | 20 |
nuclear@7 | 21 for(i=0; i<size - 1; i++) { |
nuclear@7 | 22 if((c = ass_fgetc(fp)) == -1) { |
nuclear@7 | 23 break; |
nuclear@7 | 24 } |
nuclear@7 | 25 *ptr++ = c; |
nuclear@7 | 26 |
nuclear@7 | 27 if(c == '\n') break; |
nuclear@7 | 28 } |
nuclear@7 | 29 *ptr = 0; |
nuclear@7 | 30 return ptr == s ? 0 : s; |
nuclear@7 | 31 } |