| 1 | #cxx . . $ `<file>/tools/io.c`/include "io.h"cxx . . $ `<file>/tools/io.h`/ |
| 2 | |
| 3 | /* Adapter to C I/O functions */ |
| 4 | |
| 5 | #include <string.h> |
| 6 | |
| 7 | |
| 8 | FILEcxx . . $ FILE# *open_filecxx . . $ open_file(82ec0787cd37e0a3).(const char *filename, const char *mode) { |
| 9 | return fopencxx . . $ fopen(82ec0787cd37e0a3).(filename, mode); |
| 10 | } |
| 11 | |
| 12 | int close_filecxx . . $ close_file(89bc1efcdac0ca22).(FILEcxx . . $ FILE# *file) { |
| 13 | return fclosecxx . . $ fclose(89bc1efcdac0ca22).(file); |
| 14 | } |
| 15 | |
| 16 | FILEcxx . . $ FILE# *open_processcxx . . $ open_process(82ec0787cd37e0a3).(const char *command, const char *mode) { |
| 17 | return popencxx . . $ popen(82ec0787cd37e0a3).(command, mode); |
| 18 | } |
| 19 | |
| 20 | int close_processcxx . . $ close_process(89bc1efcdac0ca22).(FILEcxx . . $ FILE# *process) { |
| 21 | return pclosecxx . . $ pclose(89bc1efcdac0ca22).(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_linecxx . . $ read_line(324bcb2c939f72bd).(FILEcxx . . $ FILE# *file, char *buffer, int max_length) { |
| 32 | char *result = fgetscxx . . $ fgets(efb0aaba7ac866ae).(buffer, max_length, file); |
| 33 | return result==NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!? EOFcxx . . $ `<external>/232824719582829767/stdio.h:109:9`! : (signed)strlencxx . . $ strlen(751346f8406fd082).(result); |
| 34 | } |