source: abuse/trunk/src/fakelib.h @ 682

Last change on this file since 682 was 555, checked in by Sam Hocevar, 9 years ago

ps3: make everything compile on the PS3. Of course, nothing links yet
because so much support is missing.

  • Property svn:keywords set to Id
File size: 1.1 KB
Line 
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, by
8 *  Jonathan Clark, or by Sam Hocevar.
9 */
10
11#ifndef __FAKELIB_HPP_
12#define __FAKELIB_HPP_
13
14#include <stdint.h>
15
16class 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
33bFILE *open_file(char *name, char *perm) { return new bFILE(fopen(name,perm)); }
34#define dprintf printf
35void dgets(char *s, int x)
36{ fgets(s,x,stdin);
37  if (strlen(s)>0) s[strlen(s)-1]=0;
38}
39
40#endif
Note: See TracBrowser for help on using the repository browser.