3dphotoshoot

diff src/assman.c @ 22:d7fe157c402d

fonts
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 13 Jun 2015 05:32:07 +0300
parents
children 3d082c566b53
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/assman.c	Sat Jun 13 05:32:07 2015 +0300
     1.3 @@ -0,0 +1,30 @@
     1.4 +#include "assman.h"
     1.5 +
     1.6 +int ass_fgetc(ass_file *fp)
     1.7 +{
     1.8 +	char c;
     1.9 +
    1.10 +	if(ass_fread(&c, 1, 1, fp) < 1) {
    1.11 +		return -1;
    1.12 +	}
    1.13 +	return c;
    1.14 +}
    1.15 +
    1.16 +char *ass_fgets(char *s, int size, ass_file *fp)
    1.17 +{
    1.18 +	int i, c;
    1.19 +	char *ptr = s;
    1.20 +
    1.21 +	if(!size) return 0;
    1.22 +
    1.23 +	for(i=0; i<size - 1; i++) {
    1.24 +		if((c = ass_fgetc(fp)) == -1) {
    1.25 +			break;
    1.26 +		}
    1.27 +		*ptr++ = c;
    1.28 +
    1.29 +		if(c == '\n') break;
    1.30 +	}
    1.31 +	*ptr = 0;
    1.32 +	return ptr == s ? 0 : s;
    1.33 +}