1 | /* |
---|
2 | * Abuse - dark 2D side-scrolling platform game |
---|
3 | * Copyright (c) 1995 Crack dot Com |
---|
4 | * Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net> |
---|
5 | * |
---|
6 | * This software was released into the Public Domain. As with most public |
---|
7 | * domain software, no warranty is made or implied by Crack dot Com or |
---|
8 | * Jonathan Clark. |
---|
9 | */ |
---|
10 | |
---|
11 | #ifndef __FAKELIB_HPP_ |
---|
12 | #define __FAKELIB_HPP_ |
---|
13 | |
---|
14 | #include <stdint.h> |
---|
15 | |
---|
16 | class bFILE |
---|
17 | { |
---|
18 | public : |
---|
19 | FILE *fp; |
---|
20 | bFILE(FILE *FP) { fp=FP; } |
---|
21 | bFILE(char *fn, char *mode) { fp=fopen(fn,mode); } |
---|
22 | long file_size() { long cur=ftell(fp),ret; fseek(fp,0,2); ret=ftell(fp); |
---|
23 | fseek(fp,cur,0); return ret; } |
---|
24 | int read(void *buf, int count) { return fread(buf,count,1,fp); } |
---|
25 | int write(void *buf, int count) { return fwrite(buf,count,1,fp); } |
---|
26 | int write_byte(uchar x) { return fputc(x,fp); } |
---|
27 | int open_failure() { return fp==NULL; } |
---|
28 | ~bFILE() { if (fp) fclose(fp); } |
---|
29 | } ; |
---|
30 | |
---|
31 | #define jFILE bFILE |
---|
32 | |
---|
33 | bFILE *open_file(char *name, char *perm) { return new bFILE(fopen(name,perm)); } |
---|
34 | #define dprintf printf |
---|
35 | void dgets(char *s, int x) |
---|
36 | { fgets(s,x,stdin); |
---|
37 | if (strlen(s)>0) s[strlen(s)-1]=0; |
---|
38 | } |
---|
39 | |
---|
40 | #endif |
---|