aboutsummaryrefslogtreecommitdiff
path: root/shared/common
diff options
context:
space:
mode:
authorN.N. <krzyszcz@users.sourceforge.net>2005-01-27 14:42:55 +0000
committerN.N. <krzyszcz@users.sourceforge.net>2005-01-27 14:42:55 +0000
commitbfb359fd22e61faaca3a6e49ad3b7a81f2d71551 (patch)
treed070071515c7e7f53073da32046b24855e8307c8 /shared/common
parent6435314717c5fb8fa062eb682c72c8df095b1be3 (diff)
cyclone alpha52 and toxy alpha15 (see notes.txt for cyclone, toxy and shared)
svn path=/trunk/externals/miXed/; revision=2550
Diffstat (limited to 'shared/common')
-rw-r--r--shared/common/Makefile.sources2
-rw-r--r--shared/common/binport.c16
-rw-r--r--shared/common/binport.h14
-rw-r--r--shared/common/fi.c54
-rw-r--r--shared/common/fi.h11
-rw-r--r--shared/common/fitter.c33
-rw-r--r--shared/common/fitter.h5
-rw-r--r--shared/common/loud.c26
-rw-r--r--shared/common/os.c235
-rw-r--r--shared/common/os.h13
-rw-r--r--shared/common/port.c28
-rw-r--r--shared/common/port.h4
12 files changed, 334 insertions, 107 deletions
diff --git a/shared/common/Makefile.sources b/shared/common/Makefile.sources
index f605df4..76fd3cc 100644
--- a/shared/common/Makefile.sources
+++ b/shared/common/Makefile.sources
@@ -2,12 +2,12 @@ OTHER_SOURCES = \
binport.c \
clc.c \
dict.c \
-fi.c \
fitter.c \
grow.c \
lex.c \
loud.c \
mifi.c \
+os.c \
port.c \
props.c \
qtree.c \
diff --git a/shared/common/binport.c b/shared/common/binport.c
index 4fe46e8..1df9571 100644
--- a/shared/common/binport.c
+++ b/shared/common/binport.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1997-2004 Miller Puckette, krzYszcz, and others.
+/* Copyright (c) 1997-2005 Miller Puckette, krzYszcz, and others.
* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
@@ -584,7 +584,7 @@ static int binport_alike(char *header, int *ftypep)
static char text_header[4] = { 'm', 'a', 'x', ' ' };
static char pd_header[3] = { '#', 'N', ' ' }; /* canvas or struct */
if (memcmp(header, bin_header, 4) == 0)
- *ftypep = BINPORT_OK;
+ *ftypep = BINPORT_MAXBINARY;
else if (memcmp(header, text_header, 4) == 0)
*ftypep = BINPORT_MAXTEXT;
else if (memcmp(header, old_header, 4) == 0)
@@ -631,7 +631,7 @@ static t_binport *binport_new(FILE *fp, int *ftypep)
bp->b_fp = fp;
bp->b_ftype = *ftypep;
bp->b_nsymbols = 0;
- if (*ftypep == BINPORT_OK)
+ if (*ftypep == BINPORT_MAXBINARY)
{
bp->b_symsize = BINPORT_SYMGROW;
bp->b_symtable =
@@ -712,9 +712,9 @@ int binport_read(t_binbuf *bb, char *filename, char *dirname)
t_binport *bp = binport_new(fp, &ftype);
if (bp)
{
- if (ftype == BINPORT_OK)
+ if (ftype == BINPORT_MAXBINARY)
result = (binport_tobinbuf(bp, bb)
- ? BINPORT_OK : BINPORT_CORRUPT);
+ ? BINPORT_MAXBINARY : BINPORT_CORRUPT);
else if (ftype == BINPORT_MAXTEXT)
{
t_atom at;
@@ -725,7 +725,7 @@ int binport_read(t_binbuf *bb, char *filename, char *dirname)
break;
binbuf_addv(bb, "ss;", gensym("max"), gensym("v2"));
result = (binport_tobinbuf(bp, bb)
- ? BINPORT_OK : BINPORT_CORRUPT);
+ ? BINPORT_MAXTEXT : BINPORT_CORRUPT);
}
else result = BINPORT_FAILED;
}
@@ -737,7 +737,7 @@ int binport_read(t_binbuf *bb, char *filename, char *dirname)
{
bp->b_old = old;
if (binpold_load(old) && binport_tobinbuf(bp, bb))
- result = BINPORT_OK;
+ result = BINPORT_MAXOLD;
}
else binpold_failure(filename);
}
@@ -809,7 +809,7 @@ int main(int ac, char **av)
t_binport *bp = binport_new(fp, &ftype);
if (bp)
{
- if (ftype == BINPORT_OK)
+ if (ftype == BINPORT_MAXBINARY)
binport_print(bp, stdout);
else if (ftype == BINPORT_MAXTEXT)
binport_warning("\"%s\" looks like a Max text file", av[1]);
diff --git a/shared/common/binport.h b/shared/common/binport.h
index f29d24d..b70c555 100644
--- a/shared/common/binport.h
+++ b/shared/common/binport.h
@@ -1,12 +1,20 @@
-/* Copyright (c) 2003-2004 krzYszcz and others.
+/* Copyright (c) 2003-2005 krzYszcz and others.
* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
#ifndef __BINPORT_H__
#define __BINPORT_H__
-enum { BINPORT_OK, BINPORT_MAXTEXT, BINPORT_MAXOLD, BINPORT_PDFILE,
- BINPORT_INVALID, BINPORT_CORRUPT, BINPORT_FAILED };
+/* return values of binport_read() and import_max(), also passed to
+ outlet_float() by cyclone library objects (cyclone, maxmode...) */
+#define BINPORT_FAILED -4 /* internal error */
+#define BINPORT_CORRUPT -3 /* file contents inconsistency */
+#define BINPORT_INVALID -2 /* file type not recognized */
+#define BINPORT_NOFILE -1 /* file not found */
+#define BINPORT_MAXBINARY 0
+#define BINPORT_MAXTEXT 1
+#define BINPORT_MAXOLD 2
+#define BINPORT_PDFILE 3
#ifndef MIXED_STANDALONE
int binport_read(t_binbuf *bb, char *filename, char *dirname);
diff --git a/shared/common/fi.c b/shared/common/fi.c
deleted file mode 100644
index e46d001..0000000
--- a/shared/common/fi.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (c) 2004 krzYszcz and others.
- * For information on usage and redistribution, and for a DISCLAIMER OF ALL
- * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-#ifdef NT
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-#include <stdio.h>
-#include <string.h>
-#include "m_pd.h"
-#include "fi.h"
-
-FILE *firead_open(char *filename, t_canvas *cv, int textmode)
-{
- int fd;
- char path[MAXPDSTRING+2], *nameptr;
- t_symbol *dirsym = (cv ? canvas_getdir(cv) : 0);
- /* path arg is returned unbashed (system-independent) */
- if ((fd = open_via_path((dirsym ? dirsym->s_name : ""), filename,
- "", path, &nameptr, MAXPDSTRING, 1)) < 0)
- return (0);
- /* Closing/reopening dance. This is unnecessary under linux, and we
- could have tried to convert fd to fp, but under windows open_via_path()
- returns what seems to be an invalid fd.
- LATER try to understand what is going on here... */
- close(fd);
- if (path != nameptr)
- {
- char *slashpos = path + strlen(path);
- *slashpos++ = '/';
- /* try not to be dependent on current open_via_path() implementation */
- if (nameptr != slashpos)
- strcpy(slashpos, nameptr);
- }
- sys_bashfilename(path, path);
- return (fopen(path, (textmode ? "r" : "rb")));
-}
-
-FILE *fiwrite_open(char *filename, t_canvas *cv, int textmode)
-{
- char path[MAXPDSTRING+2];
- if (cv)
- /* path arg is returned unbashed (system-independent) */
- canvas_makefilename(cv, filename, path, MAXPDSTRING);
- else
- {
- strncpy(path, filename, MAXPDSTRING);
- path[MAXPDSTRING-1] = 0;
- }
- sys_bashfilename(path, path);
- return (fopen(path, (textmode ? "w" : "wb")));
-}
diff --git a/shared/common/fi.h b/shared/common/fi.h
deleted file mode 100644
index c6e8401..0000000
--- a/shared/common/fi.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/* Copyright (c) 2004 krzYszcz and others.
- * For information on usage and redistribution, and for a DISCLAIMER OF ALL
- * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-#ifndef __FI_H__
-#define __FI_H__
-
-FILE *firead_open(char *filename, t_canvas *cv, int textmode);
-FILE *fiwrite_open(char *filename, t_canvas *cv, int textmode);
-
-#endif
diff --git a/shared/common/fitter.c b/shared/common/fitter.c
index 2ccdd53..faba970 100644
--- a/shared/common/fitter.c
+++ b/shared/common/fitter.c
@@ -25,7 +25,7 @@ static t_symbol *fittermode_value = 0;
typedef struct _fittermode_client
{
t_class *fc_owner;
- t_symbol **fc_mirror;
+ t_canvas *fc_canvas;
t_fittermode_callback fc_callback;
struct _fittermode_client *fc_next;
} t_fittermode_client;
@@ -36,6 +36,7 @@ static t_pd *fittermode_target = 0;
static int fittermode_ready = 0;
static t_symbol *fitterps_hashcompatibility = 0;
static t_symbol *fitterps_max = 0;
+static t_symbol *fitterps_none = 0;
/* read access (query), only from fittermode_dosetup() */
static void fittermode_bang(t_pd *x)
@@ -55,6 +56,11 @@ static void fittermode_bang(t_pd *x)
/* read access (reply), only from fitter_dosetup() */
static void fittermode_symbol(t_pd *x, t_symbol *s)
{
+ if (!s || s == &s_)
+ {
+ loudbug_bug("fittermode_symbol");
+ s = fitterps_none;
+ }
fittermode_value = s;
}
@@ -64,12 +70,8 @@ static void fittermode_set(t_pd *x, t_symbol *s)
t_fittermode_client *fc;
fittermode_value = s;
for (fc = fittermode_clients; fc; fc = fc->fc_next)
- {
- if (fc->fc_mirror)
- *fc->fc_mirror = s;
if (fc->fc_callback)
- fc->fc_callback(s);
- }
+ fc->fc_callback();
}
static void fittermode_dosetup(int noquery)
@@ -78,9 +80,11 @@ static void fittermode_dosetup(int noquery)
loudbug_bug("fittermode_dosetup");
fitterps_hashcompatibility = gensym("#compatibility");
fitterps_max = gensym("max");
+ fitterps_none = gensym("none");
+ fittermode_value = fitterps_none;
fittermode_class = class_new(fitterps_hashcompatibility,
- 0, 0, sizeof(t_pd),
- CLASS_PD | CLASS_NOINLET, 0);
+ 0, 0, sizeof(t_pd),
+ CLASS_PD | CLASS_NOINLET, 0);
class_addbang(fittermode_class, fittermode_bang);
class_addsymbol(fittermode_class, fittermode_symbol);
class_addmethod(fittermode_class,
@@ -93,21 +97,18 @@ static void fittermode_dosetup(int noquery)
fittermode_ready = 1;
}
-void fitter_setup(t_class *owner, t_symbol **mirror,
- t_fittermode_callback callback)
+void fitter_setup(t_class *owner, t_fittermode_callback callback)
{
if (!fittermode_class)
fittermode_dosetup(0);
- if (mirror || callback)
+ if (callback)
{
t_fittermode_client *fc = getbytes(sizeof(*fc));
fc->fc_owner = owner;
- fc->fc_mirror = mirror;
+ fc->fc_canvas = 0; /* a global client */
fc->fc_callback = callback;
fc->fc_next = fittermode_clients;
fittermode_clients = fc;
- if (mirror)
- *mirror = fittermode_value;
}
}
@@ -140,7 +141,9 @@ void fitter_drop(t_class *owner)
void fitter_setmode(t_symbol *s)
{
- post("setting compatibility mode to '%s'", (s ? s->s_name : "none"));
+ if (!s || s == &s_)
+ s = fitterps_none;
+ post("setting compatibility mode to '%s'", s->s_name);
if (!fittermode_class)
fittermode_dosetup(1);
if (fitterps_hashcompatibility->s_thing)
diff --git a/shared/common/fitter.h b/shared/common/fitter.h
index 3f3303c..2e5c24d 100644
--- a/shared/common/fitter.h
+++ b/shared/common/fitter.h
@@ -5,10 +5,9 @@
#ifndef __FITTER_H__
#define __FITTER_H__
-typedef void (*t_fittermode_callback)(t_symbol *s);
+typedef void (*t_fittermode_callback)(void);
-void fitter_setup(t_class *owner, t_symbol **mirror,
- t_fittermode_callback callback);
+void fitter_setup(t_class *owner, t_fittermode_callback callback);
void fitter_drop(t_class *owner);
void fitter_setmode(t_symbol *s);
t_symbol *fitter_getmode(void);
diff --git a/shared/common/loud.c b/shared/common/loud.c
index 6229a77..d87d3c0 100644
--- a/shared/common/loud.c
+++ b/shared/common/loud.c
@@ -348,6 +348,9 @@ void loudbug_post(char *fmt, ...)
vsnprintf(buf, MAXPDSTRING-1, fmt, ap);
va_end(ap);
fprintf(stderr, "%s\n", buf);
+#ifdef MSW
+ fflush(stderr);
+#endif
}
void loudbug_startpost(char *fmt, ...)
@@ -358,11 +361,17 @@ void loudbug_startpost(char *fmt, ...)
vsnprintf(buf, MAXPDSTRING-1, fmt, ap);
va_end(ap);
fputs(buf, stderr);
+#ifdef MSW
+ fflush(stderr);
+#endif
}
void loudbug_endpost(void)
{
fputs("\n", stderr);
+#ifdef MSW
+ fflush(stderr);
+#endif
}
void loudbug_postatom(int ac, t_atom *av)
@@ -372,6 +381,9 @@ void loudbug_postatom(int ac, t_atom *av)
char buf[MAXPDSTRING];
atom_string(av++, buf, MAXPDSTRING);
fprintf(stderr, " %s", buf);
+#ifdef MSW
+ fflush(stderr);
+#endif
}
}
@@ -391,9 +403,18 @@ void loudbug_postbinbuf(t_binbuf *bb)
fprintf(stderr, " %s", buf);
}
else fprintf(stderr, "%s", buf);
+#ifdef MSW
+ fflush(stderr);
+#endif
aprev = ap++;
}
- if (aprev) fputs("\n", stderr);
+ if (aprev)
+ {
+ fputs("\n", stderr);
+#ifdef MSW
+ fflush(stderr);
+#endif
+ }
}
void loudbug_bug(char *fmt, ...)
@@ -404,5 +425,8 @@ void loudbug_bug(char *fmt, ...)
vsnprintf(buf, MAXPDSTRING-1, fmt, ap);
va_end(ap);
fprintf(stderr, "miXed consistency check failed: %s\n", buf);
+#ifdef MSW
+ fflush(stderr);
+#endif
bug(buf);
}
diff --git a/shared/common/os.c b/shared/common/os.c
new file mode 100644
index 0000000..9129f82
--- /dev/null
+++ b/shared/common/os.c
@@ -0,0 +1,235 @@
+/* Copyright (c) 2004-2005 krzYszcz and others.
+ * For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+#ifdef MSW
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "m_pd.h"
+#include "os.h"
+
+static int ospath_doabsolute(char *path, char *cwd, char *result)
+{
+ if (*path == 0)
+ {
+ if (result)
+ strcpy(result, cwd);
+ else
+ return (strlen(cwd));
+ }
+ else if (*path == '~')
+ {
+ path++;
+ if (*path == '/' || *path == 0)
+ {
+#ifdef UNIX
+ char *home = getenv("HOME");
+ if (home)
+ {
+ if (result)
+ {
+ strcpy(result, home);
+ if (*path)
+ strcat(result, path);
+ }
+ else return (strlen(home) + strlen(path));
+ }
+ else goto badpath;
+#else
+ goto badpath;
+#endif
+ }
+ else goto badpath;
+ }
+ else if (*path == '/')
+ {
+#ifdef MSW
+ /* path is absolute, drive is implicit, LATER UNC? */
+ if (*cwd && cwd[1] == ':')
+ {
+ if (result)
+ {
+ *result = *cwd;
+ result[1] = ':';
+ strcpy(result + 2, path);
+ }
+ else return (2 + strlen(path));
+ }
+ else goto badpath;
+#else
+ /* path is absolute */
+ if (result)
+ strcpy(result, path);
+ else
+ return (strlen(path));
+#endif
+ }
+ else
+ {
+#ifdef MSW
+ if (path[1] == ':')
+ {
+ if (path[2] == '/')
+ {
+ /* path is absolute */
+ if (result)
+ strcpy(result, path);
+ else
+ return (strlen(path));
+ }
+ else if (*cwd == *path)
+ {
+ /* path is relative, drive is explicitly current */
+ if (result)
+ {
+ int ndx = strlen(cwd);
+ strcpy(result, cwd);
+ result[ndx++] = '/';
+ strcpy(result + ndx, path + 2);
+ }
+ else return (strlen(cwd) + strlen(path) - 1);
+ }
+ /* we do not maintain per-drive cwd, LATER rethink */
+ else goto badpath;
+ }
+ /* LATER devices? */
+ else
+ {
+ /* path is relative */
+ if (result)
+ {
+ int ndx = strlen(cwd);
+ strcpy(result, cwd);
+ result[ndx++] = '/';
+ strcpy(result + ndx, path);
+ }
+ else return (strlen(cwd) + 1 + strlen(path));
+ }
+#else
+ /* path is relative */
+ if (result)
+ {
+ int ndx = strlen(cwd);
+ strcpy(result, cwd);
+ result[ndx++] = '/';
+ strcpy(result + ndx, path);
+ }
+ else return (strlen(cwd) + 1 + strlen(path));
+#endif
+ }
+ if (result && *result && *result != '.')
+ {
+ /* clean-up */
+ char *inptr, *outptr = result;
+ int ndx = strlen(result);
+ if (result[ndx - 1] == '.')
+ {
+ result[ndx] = '/'; /* guarding slash */
+ result[ndx + 1] = 0;
+ }
+ for (inptr = result + 1; *inptr; inptr++)
+ {
+ if (*inptr == '/')
+ {
+ if (*outptr == '/')
+ continue;
+ else if (*outptr == '.')
+ {
+ if (outptr[-1] == '/')
+ {
+ outptr--;
+ continue;
+ }
+ else if (outptr[-1] == '.' && outptr[-2] == '/')
+ {
+ outptr -= 2;
+ if (outptr == result)
+ continue;
+ else for (outptr--; outptr != result; outptr--)
+ if (*outptr == '/')
+ break;
+ continue;
+ }
+ }
+ }
+ *++outptr = *inptr;
+ }
+ if (*outptr == '/' && outptr != result)
+ *outptr = 0;
+ else
+ outptr[1] = 0;
+ }
+ else bug("ospath_doabsolute 1");
+ return (0);
+badpath:
+ if (result)
+ bug("ospath_doabsolute 2");
+ return (0);
+}
+
+/* Returns an estimated length of an absolute path made up from the first arg.
+ The actual ospath_absolute()'s length may be shorter (since it erases
+ superfluous slashes and dots), but not longer. Both args should be unbashed
+ (system-independent), cwd should be absolute. Returns 0 in case of any
+ error (LATER revisit). */
+int ospath_length(char *path, char *cwd)
+{
+ /* one extra byte used internally (guarding slash) */
+ return (ospath_doabsolute(path, cwd, 0) + 1);
+}
+
+/* Copies an absolute path to result. Arguments: path and cwd, are the same
+ as in ospath_length(). Caller should first consult ospath_length(), and
+ allocate at least ospath_length() + 1 bytes to the result buffer.
+ Should never fail (failure is a bug). */
+char *ospath_absolute(char *path, char *cwd, char *result)
+{
+ ospath_doabsolute(path, cwd, result);
+ return (result);
+}
+
+FILE *fileread_open(char *filename, t_canvas *cv, int textmode)
+{
+ int fd;
+ char path[MAXPDSTRING+2], *nameptr;
+ t_symbol *dirsym = (cv ? canvas_getdir(cv) : 0);
+ /* path arg is returned unbashed (system-independent) */
+ if ((fd = open_via_path((dirsym ? dirsym->s_name : ""), filename,
+ "", path, &nameptr, MAXPDSTRING, 1)) < 0)
+ return (0);
+ /* Closing/reopening dance. This is unnecessary under linux, and we
+ could have tried to convert fd to fp, but under windows open_via_path()
+ returns what seems to be an invalid fd.
+ LATER try to understand what is going on here... */
+ close(fd);
+ if (path != nameptr)
+ {
+ char *slashpos = path + strlen(path);
+ *slashpos++ = '/';
+ /* try not to be dependent on current open_via_path() implementation */
+ if (nameptr != slashpos)
+ strcpy(slashpos, nameptr);
+ }
+ sys_bashfilename(path, path);
+ return (fopen(path, (textmode ? "r" : "rb")));
+}
+
+FILE *filewrite_open(char *filename, t_canvas *cv, int textmode)
+{
+ char path[MAXPDSTRING+2];
+ if (cv)
+ /* path arg is returned unbashed (system-independent) */
+ canvas_makefilename(cv, filename, path, MAXPDSTRING);
+ else
+ {
+ strncpy(path, filename, MAXPDSTRING);
+ path[MAXPDSTRING-1] = 0;
+ }
+ sys_bashfilename(path, path);
+ return (fopen(path, (textmode ? "w" : "wb")));
+}
diff --git a/shared/common/os.h b/shared/common/os.h
new file mode 100644
index 0000000..f3dde89
--- /dev/null
+++ b/shared/common/os.h
@@ -0,0 +1,13 @@
+/* Copyright (c) 2004-2005 krzYszcz and others.
+ * For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+#ifndef __OS_H__
+#define __OS_H__
+
+int ospath_length(char *path, char *cwd);
+char *ospath_absolute(char *path, char *cwd, char *result);
+FILE *fileread_open(char *filename, t_canvas *cv, int textmode);
+FILE *filewrite_open(char *filename, t_canvas *cv, int textmode);
+
+#endif
diff --git a/shared/common/port.c b/shared/common/port.c
index 159eab1..5845210 100644
--- a/shared/common/port.c
+++ b/shared/common/port.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1997-2004 Miller Puckette, krzYszcz, and others.
+/* Copyright (c) 1997-2005 Miller Puckette, krzYszcz, and others.
* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
@@ -1596,11 +1596,12 @@ endparsing:
return (result);
}
-void import_max(char *fn, char *dir)
+int import_max(char *fn, char *dir)
{
+ int result;
t_port *x;
t_binbuf *inbb, *outbb;
- int fd, ftype;
+ int fd;
char buf[MAXPDSTRING], *bufp;
t_pd *stackp = 0;
int dspstate = canvas_suspend_dsp();
@@ -1608,23 +1609,30 @@ void import_max(char *fn, char *dir)
if ((fd = open_via_path(dir, fn, "", buf, &bufp, MAXPDSTRING, 0)) < 0)
{
loud_error(0, "%s: can't open", fn);
- return;
+ return (BINPORT_NOFILE);
}
else close (fd);
x = port_new();
inbb = binbuf_new();
glob_setfilename(0, gensym(bufp), gensym(buf));
- ftype = binport_read(inbb, bufp, buf);
- if (ftype == BINPORT_OK)
+ result = binport_read(inbb, bufp, buf);
+ if (result == BINPORT_MAXBINARY ||
+ result == BINPORT_MAXTEXT ||
+ result == BINPORT_MAXOLD)
{
+ int bbresult;
#ifdef PORT_DEBUG
binport_write(inbb, "import-debug.pat", "");
#endif
outbb = binbuf_new();
- if (import_binbuf(x, inbb, outbb) != PORT_OK)
+ if ((bbresult = import_binbuf(x, inbb, outbb)) != PORT_OK)
{
- loud_error(0, "%s: import failed", fn);
+ loud_error(0, "%s: import failed (%d)", fn, bbresult);
+ if (bbresult == PORT_CORRUPT)
+ result = BINPORT_CORRUPT;
+ else
+ result = BINPORT_FAILED;
binbuf_free(outbb);
outbb = 0;
}
@@ -1633,7 +1641,7 @@ void import_max(char *fn, char *dir)
if (outbb) binbuf_write(outbb, "import-result.pd", "", 0);
#endif
}
- else if (ftype == BINPORT_PDFILE)
+ else if (result == BINPORT_PDFILE)
outbb = inbb;
else
{
@@ -1656,4 +1664,6 @@ void import_max(char *fn, char *dir)
#if 0 /* LATER */
pd_doloadbang();
#endif
+
+ return (result);
}
diff --git a/shared/common/port.h b/shared/common/port.h
index 2053c20..48f58bd 100644
--- a/shared/common/port.h
+++ b/shared/common/port.h
@@ -1,11 +1,11 @@
-/* Copyright (c) 2003-2004 krzYszcz and others.
+/* Copyright (c) 2003-2005 krzYszcz and others.
* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
#ifndef __PORT_H__
#define __PORT_H__
-void import_max(char *fn, char *dir);
+int import_max(char *fn, char *dir);
void import_setmapping(int size, char **mapping);
char **import_getmapping(int *sizep);
char *port_usemapping(char *from, int mapsize, char **mapping);