29 lines
494 B
C
29 lines
494 B
C
#include "pp.h"
|
|
#include "pp_defines.h"
|
|
#include "line_handler.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
int pp_compute(void *def_map, const struct str_dyn_arr *inc_dirs, FILE *source,
|
|
FILE *out)
|
|
{
|
|
char line[PP_LINE_LEN + 1];
|
|
int read_lines;
|
|
int ret;
|
|
|
|
read_lines = 0;
|
|
|
|
while (fgets(line, PP_LINE_LEN, source)) {
|
|
read_lines++;
|
|
|
|
ret = line_handler(line, def_map, inc_dirs, source, out);
|
|
if (ret == PP_FAILED)
|
|
return ret;
|
|
}
|
|
|
|
if (ferror(source) || !read_lines)
|
|
return PP_FAILED;
|
|
|
|
return PP_OK;
|
|
}
|