source: abuse/trunk/src/fakelib.hpp @ 112

Last change on this file since 112 was 57, checked in by Sam Hocevar, 11 years ago
  • Move each header to the same directory as its corresponding source, to get a better idea of which files are likely to export symbols.
File size: 1.2 KB
Line 
1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
4 *
5 *  This software was released into the Public Domain. As with most public
6 *  domain software, no warranty is made or implied by Crack dot Com or
7 *  Jonathan Clark.
8 */
9
10#ifndef __FAKELIB_HPP_
11#define __FAKELIB_HPP_
12
13#define jmalloc(x,y) malloc(x)
14#define jrealloc(x,y,z) realloc(x,y)
15#define jfree(x) free(x)
16
17#ifdef __sgi
18#include <sys/bsd_types.h>
19#else
20#include <stdint.h>
21#endif
22
23class bFILE
24{
25  public :
26  FILE *fp;
27  bFILE(FILE *FP) { fp=FP; }
28  bFILE(char *fn, char *mode) { fp=fopen(fn,mode); }
29  long file_size() { long cur=ftell(fp),ret; fseek(fp,0,2); ret=ftell(fp);
30                     fseek(fp,cur,0); return ret; }
31  int read(void *buf, int count) { return fread(buf,count,1,fp); }
32  int write(void *buf, int count) { return fwrite(buf,count,1,fp); }
33  int write_byte(uchar x) { return fputc(x,fp); }
34  int open_failure() { return fp==NULL; }
35  ~bFILE() { if (fp) fclose(fp); }
36} ;
37
38#define jFILE bFILE
39
40bFILE *open_file(char *name, char *perm) { return new bFILE(fopen(name,perm)); }
41#define dprintf printf
42void dgets(char *s, int x)
43{ fgets(s,x,stdin);
44  if (strlen(s)>0) s[strlen(s)-1]=0;
45}
46
47#endif
Note: See TracBrowser for help on using the repository browser.