Debian Codegraph @

tools/io.c

raw symbols SCIP
1 #include "io.h"
2
3 /* Adapter to C I/O functions */
4
5 #include <string.h>
6
7
8 FILE *open_file(const char *filename, const char *mode) {
9 return fopen(filename, mode);
10 }
11
12 int close_file(FILE *file) {
13 return fclose(file);
14 }
15
16 FILE *open_process(const char *command, const char *mode) {
17 return popen(command, mode);
18 }
19
20 int close_process(FILE *process) {
21 return pclose(process);
22 }
23
24
25 /*
26 read_line() - read characters from a FILE
27 - behaves like fgets() except will return
28 - number of characters read and
29 - EOF if at end of file
30 */
31 int read_line(FILE *file, char *buffer, int max_length) {
32 char *result = fgets(buffer, max_length, file);
33 return result==NULL? EOF : (signed)strlen(result);
34 }