bb_result_t blorb_res;
bb_map_t *blorb_map;
-/*
- * isblorb
- *
- * Returns 1 if this file is a Blorb file, 0 if not.
- *
- * FIXME Is there a potential endian problem here?
- */
-static int isblorb(FILE *fp)
-{
- char mybuf[4];
-
- if (fp == NULL)
- return 0;
-
- fread(mybuf, 1, 4, fp);
- if (strncmp(mybuf, "FORM", 4))
- return 0;
-
- fseek(fp, 4, SEEK_CUR);
- fread(mybuf, 1, 4, fp);
-
- if (strncmp(mybuf, "IFRS", 4))
- return 0;
+/* uint32 *findchunk(uint32 *data, char *chunkID, int length); */
+static char *findchunk(char *pstart, char *fourcc, int n);
+static unsigned short ReadShort(const unsigned char *bytes);
+static unsigned long ReadLong(const unsigned char *bytes);
+static double ReadExtended(const unsigned char *bytes);
+static int isblorb(FILE *);
- return 1;
-}
+#define UnsignedToFloat(u) (((double)((long)(u - 2147483647L - 1))) + 2147483648.0)
/*
bb_err_t blorb_err;
-/*
blorb_map = NULL;
- blorb_res = NULL;
-*/
if ((fp = fopen(filename, "rb")) == NULL)
return bb_err_Read;
blorb_fp = NULL;
}
-char *findchunk(char *data, char *string, int length)
+
+
+/*
+ * isblorb
+ *
+ * Returns 1 if this file is a Blorb file, 0 if not.
+ *
+ * FIXME Is there a potential endian problem here?
+ */
+static int isblorb(FILE *fp)
+{
+ char mybuf[4];
+
+ if (fp == NULL)
+ return 0;
+
+ fread(mybuf, 1, 4, fp);
+ if (strncmp(mybuf, "FORM", 4))
+ return 0;
+
+ fseek(fp, 4, SEEK_CUR);
+ fread(mybuf, 1, 4, fp);
+
+ if (strncmp(mybuf, "IFRS", 4))
+ return 0;
+
+ return 1;
+}
+
+static char *findchunk(char *data, char *string, int length)
{
char *mydata = data+12;
while (TRUE) {
}
-unsigned short ReadShort(const unsigned char *bytes)
+static unsigned short ReadShort(const unsigned char *bytes)
{
return (unsigned short)(
((unsigned short)(bytes[0] & 0xFF) << 8) |
}
-unsigned long ReadLong(const unsigned char *bytes)
+static unsigned long ReadLong(const unsigned char *bytes)
{
return (unsigned long)(
((unsigned long)(bytes[0] & 0xFF) << 24) |
}
-double ReadExtended(const unsigned char *bytes)
+static double ReadExtended(const unsigned char *bytes)
{
double f;
int expon;
#include <libgen.h>
/* We will use our own private getopt functions. */
-#include "getopt.h"
+//#include "getopt.h"
#ifdef USE_NCURSES_H
#include <ncurses.h>
char semi_stripped_story_name[FILENAME_MAX+1];
*/
+static int zgetopt (int, char **, const char *);
+static int zoptind = 1;
+static int zoptopt = 0;
+static char *zoptarg = NULL;
+
+static int getconfig(char *);
+static int getbool(char *);
+static int getcolor(char *);
+static int geterrmode(char *);
+static void redraw(void);
+static FILE *pathopen(const char *, const char *, const char *, char *);
+
/*
* os_fatal
*
/* Parse the options */
do {
- c = getopt(argc, argv, "aAb:c:def:Fh:il:oOpPQqr:s:S:tu:w:xZ:");
+ c = zgetopt(argc, argv, "aAb:c:def:Fh:il:oOpPQqr:s:S:tu:w:xZ:");
switch(c) {
case 'a': f_setup.attribute_assignment = 1; break;
case 'A': f_setup.attribute_testing = 1; break;
- case 'b': u_setup.background_color = atoi(optarg);
+ case 'b': u_setup.background_color = atoi(zoptarg);
u_setup.force_color = 1;
u_setup.disable_color = 0;
if ((u_setup.background_color < 2) ||
(u_setup.background_color > 9))
u_setup.background_color = -1;
break;
- case 'c': f_setup.context_lines = atoi(optarg); break;
+ case 'c': f_setup.context_lines = atoi(zoptarg); break;
case 'd': u_setup.disable_color = 1; break;
case 'e': f_setup.sound = 1; break;
- case 'f': u_setup.foreground_color = getcolor(optarg);
+ case 'f': u_setup.foreground_color = getcolor(zoptarg);
u_setup.force_color = 1;
u_setup.disable_color = 0;
if ((u_setup.foreground_color < 2) ||
case 'F': u_setup.force_color = 1;
u_setup.disable_color = 0;
break;
- case 'h': u_setup.screen_height = atoi(optarg); break;
+ case 'h': u_setup.screen_height = atoi(zoptarg); break;
case 'i': f_setup.ignore_errors = 1; break;
- case 'l': f_setup.left_margin = atoi(optarg); break;
+ case 'l': f_setup.left_margin = atoi(zoptarg); break;
case 'o': f_setup.object_movement = 1; break;
case 'O': f_setup.object_locating = 1; break;
case 'p': u_setup.plain_ascii = 1; break;
case 'P': f_setup.piracy = 1; break;
case 'q': f_setup.sound = 0; break;
case 'Q': f_setup.save_quetzal = 0; break;
- case 'r': f_setup.right_margin = atoi(optarg); break;
- case 's': u_setup.random_seed = atoi(optarg); break;
- case 'S': f_setup.script_cols = atoi(optarg); break;
+ case 'r': f_setup.right_margin = atoi(zoptarg); break;
+ case 's': u_setup.random_seed = atoi(zoptarg); break;
+ case 'S': f_setup.script_cols = atoi(zoptarg); break;
case 't': u_setup.tandy_bit = 1; break;
- case 'u': f_setup.undo_slots = atoi(optarg); break;
- case 'w': u_setup.screen_width = atoi(optarg); break;
+ case 'u': f_setup.undo_slots = atoi(zoptarg); break;
+ case 'w': u_setup.screen_width = atoi(zoptarg); break;
case 'x': f_setup.expand_abbreviations = 1; break;
- case 'Z': f_setup.err_report_mode = atoi(optarg);
+ case 'Z': f_setup.err_report_mode = atoi(zoptarg);
if ((f_setup.err_report_mode < ERR_REPORT_NEVER) ||
(f_setup.err_report_mode > ERR_REPORT_FATAL))
f_setup.err_report_mode = ERR_DEFAULT_REPORT_MODE;
*
*/
-FILE *pathopen(const char *name, const char *p, const char *mode, char *fullname)
+static FILE *pathopen(const char *name, const char *p, const char *mode, char *fullname)
{
FILE *fp;
char buf[FILENAME_MAX + 1];
* compile targets to have those two tools installed.
*
*/
-int getconfig(char *configfile)
+static int getconfig(char *configfile)
{
FILE *fp;
* Otherwise return FALSE.
*
*/
-int getbool(char *value)
+static int getbool(char *value)
{
int num;
* corresponding to the color macros defined in frotz.h.
*
*/
-int getcolor(char *value)
+static int getcolor(char *value)
{
int num;
* defined in ux_frotz.h related to the error reporting mode.
*
*/
-int geterrmode(char *value)
+static int geterrmode(char *value)
{
int num;
}
+/* A unix-like getopt, but with the names changed to avoid any problems.
+*/
+static int zgetopt (int argc, char *argv[], const char *options)
+{
+ static int pos = 1;
+ const char *p;
+ if (zoptind >= argc || argv[zoptind][0] != '-' || argv[zoptind][1] == 0)
+ return EOF;
+ zoptopt = argv[zoptind][pos++];
+ zoptarg = NULL;
+ if (argv[zoptind][pos] == 0) {
+ pos = 1;
+ zoptind++;
+ }
+ p = strchr (options, zoptopt);
+ if (zoptopt == ':' || p == NULL) {
+ fputs ("illegal option -- ", stderr);
+ goto error;
+ } else if (p[1] == ':') {
+ if (zoptind >= argc) {
+ fputs ("option requires an argument -- ", stderr);
+ goto error;
+ } else {
+ zoptarg = argv[zoptind];
+ if (pos != 1)
+ zoptarg += pos;
+ pos = 1; zoptind++;
+ }
+ }
+ return zoptopt;
+error:
+ fputc (zoptopt, stderr);
+ fputc ('\n', stderr);
+ return '?';
+}/* zgetopt */
+