project_files/hwc/rtl/fileio.h
author Wuzzy <almikes@aol.com>
Thu, 04 May 2017 16:49:34 +0200
changeset 12407 8cc070640fd1
parent 11682 2c21bc80c95d
child 14934 68e1783762bc
permissions -rw-r--r--
Fix skipping in Racer causing the next team to be skipped, too
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7983
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     1
#ifndef FILEIO_H_
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     2
#define FILEIO_H_
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     3
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     4
#include <stdio.h>
8047
25a4daa6473c cleanup headers, remove -I . from rtl lib to save a few warnings
koda
parents: 7983
diff changeset
     5
#include "Types.h"
7983
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     6
#include "misc.h"
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     7
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     8
extern        int                                       FileMode;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     9
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    10
typedef enum{
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    11
    IO_NO_ERROR = 0,
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    12
    IO_ERROR_DUMMY = 1
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    13
}io_result_t;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    14
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    15
extern        io_result_t                               IOResult;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    16
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    17
typedef struct{
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    18
    FILE        *fp;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    19
    const char* mode;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    20
    char        file_name[256];
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    21
    int         eof;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    22
    int            record_len;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    23
}file_wrapper_t;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    24
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    25
typedef     file_wrapper_t*                             File;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    26
typedef     File                                        Text;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    27
typedef     Text                                        TextFile;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    28
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    29
void        __attribute__((overloadable))               fpcrtl_readLn(File f);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    30
#define     fpcrtl_readLn1(f)                           fpcrtl_readLn(f)
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    31
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    32
void        __attribute__((overloadable))               fpcrtl_readLn__vars(File f, Integer *i);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    33
void        __attribute__((overloadable))               fpcrtl_readLn__vars(File f, LongWord *i);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    34
void        __attribute__((overloadable))               fpcrtl_readLn__vars(File f, string255 *s);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    35
#define     fpcrtl_readLn2(f, t)                        fpcrtl_readLn__vars(f, &(t))
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    36
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    37
#define     fpcrtl_readLn(...)                          macro_dispatcher(fpcrtl_readLn, __VA_ARGS__)(__VA_ARGS__)
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    38
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    39
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    40
void        fpcrtl_blockRead__vars(File f, void *buf, Integer count, Integer *result);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    41
#define     fpcrtl_blockRead(f, buf, count, result)     fpcrtl_blockRead__vars(f, &(buf), count, &(result))
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    42
#define     fpcrtl_BlockRead                            fpcrtl_blockRead
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    43
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    44
#define     fpcrtl_assign(f, name)                      fpcrtl_assign__vars(&f, name)
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    45
void        fpcrtl_assign__vars(File *f, string255 name);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    46
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    47
boolean     fpcrtl_eof(File f);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    48
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    49
void        fpcrtl_reset1(File f);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    50
void        fpcrtl_reset2(File f, Integer l);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    51
#define     fpcrtl_reset1(f)                            fpcrtl_reset1(f)
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    52
#define     fpcrtl_reset2(f, l)                         fpcrtl_reset2(f, l)
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    53
#define     fpcrtl_reset(...)                           macro_dispatcher(fpcrtl_reset, __VA_ARGS__)(__VA_ARGS__)
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    54
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    55
void        fpcrtl_close(File f);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    56
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    57
void        __attribute__((overloadable))               fpcrtl_rewrite(File f);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    58
void        __attribute__((overloadable))               fpcrtl_rewrite(File f, Integer l);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    59
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    60
void        __attribute__((overloadable))               fpcrtl_flush(Text f);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    61
void        __attribute__((overloadable))               fpcrtl_flush(FILE *f);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    62
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    63
void        __attribute__((overloadable))               fpcrtl_write(File f, string255 s);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    64
void        __attribute__((overloadable))               fpcrtl_write(FILE *f, string255 s);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    65
void        __attribute__((overloadable))               fpcrtl_writeLn(File f, string255 s);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    66
void        __attribute__((overloadable))               fpcrtl_writeLn(FILE *f, string255 s);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    67
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    68
void        fpcrtl_blockWrite__vars(File f, const void *buf, Integer count, Integer *result);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    69
#define     fpcrtl_blockWrite(f, buf, count, result)    fpcrtl_blockWrite__vars(f, &(buf), count, &(result))
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    70
#define     fpcrtl_BlockWrite                           fpcrtl_blockWrite
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    71
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    72
bool        fpcrtl_directoryExists(string255 dir);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    73
#define     fpcrtl_DirectoryExists                      fpcrtl_directoryExists
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    74
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    75
bool        fpcrtl_fileExists(string255 filename);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    76
#define     fpcrtl_FileExists                           fpcrtl_fileExists
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    77
11682
2c21bc80c95d Implement GetCurrentDir in the c rtl
koda
parents: 8047
diff changeset
    78
char *      fpcrtl_getCurrentDir(void);
2c21bc80c95d Implement GetCurrentDir in the c rtl
koda
parents: 8047
diff changeset
    79
#define     fpcrtl_GetCurrentDir                        fpcrtl_getCurrentDir
2c21bc80c95d Implement GetCurrentDir in the c rtl
koda
parents: 8047
diff changeset
    80
7983
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    81
#endif /* FILEIO_H_ */