istereo2

view src/assman.c @ 30:900651a2f401

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