aboutsummaryrefslogtreecommitdiff
path: root/libutil/fscanf.c
blob: d567324b828ad64dfebb6b1a82b06b5194903940 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <stdio.h> 

// ugly hack because we don't have fscanf

int fscanf(FILE* stream, const char* format, int* value)
{
    int c;
    int r = 0;
    do {
        c = fgetc(stream);
        if (c>='0' && c<='9') {
            r = r*10 + (c-'0');
            continue;
        }
        break;
    } while (1);

    *value = r;

    // gahhhh
    return 1;
}