Update of /cvsroot/pure-data/externals/miXed/shared/common
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23748/shared/common
Modified Files:
Makefile.sources binport.c binport.h fitter.c fitter.h loud.c
port.c port.h
Added Files:
os.c os.h
Removed Files:
fi.c fi.h
Log Message:
cyclone alpha52 and toxy alpha15 (see notes.txt for cyclone, toxy and shared)
Index: port.h
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/port.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** port.h 12 May 2004 15:01:35 -0000 1.2
--- port.h 27 Jan 2005 14:42:53 -0000 1.3
***************
*** 1,3 ****
! /* Copyright (c) 2003-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. */
--- 1,3 ----
! /* 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. */
***************
*** 6,10 ****
#define __PORT_H__
! void import_max(char *fn, char *dir);
void import_setmapping(int size, char **mapping);
char **import_getmapping(int *sizep);
--- 6,10 ----
#define __PORT_H__
! int import_max(char *fn, char *dir);
void import_setmapping(int size, char **mapping);
char **import_getmapping(int *sizep);
Index: binport.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/binport.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** binport.c 10 Dec 2004 20:47:03 -0000 1.7
--- binport.c 27 Jan 2005 14:42:53 -0000 1.8
***************
*** 1,3 ****
! /* Copyright (c) 1997-2004 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. */
--- 1,3 ----
! /* 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. */
***************
*** 585,589 ****
static char pd_header[3] = { '#', 'N', ' ' }; /* canvas or struct */
if (memcmp(header, bin_header, 4) == 0)
! *ftypep = BINPORT_OK;
else if (memcmp(header, text_header, 4) == 0)
*ftypep = BINPORT_MAXTEXT;
--- 585,589 ----
static char pd_header[3] = { '#', 'N', ' ' }; /* canvas or struct */
if (memcmp(header, bin_header, 4) == 0)
! *ftypep = BINPORT_MAXBINARY;
else if (memcmp(header, text_header, 4) == 0)
*ftypep = BINPORT_MAXTEXT;
***************
*** 632,636 ****
bp->b_ftype = *ftypep;
bp->b_nsymbols = 0;
! if (*ftypep == BINPORT_OK)
{
bp->b_symsize = BINPORT_SYMGROW;
--- 632,636 ----
bp->b_ftype = *ftypep;
bp->b_nsymbols = 0;
! if (*ftypep == BINPORT_MAXBINARY)
{
bp->b_symsize = BINPORT_SYMGROW;
***************
*** 713,719 ****
if (bp)
{
! if (ftype == BINPORT_OK)
result = (binport_tobinbuf(bp, bb)
! ? BINPORT_OK : BINPORT_CORRUPT);
else if (ftype == BINPORT_MAXTEXT)
{
--- 713,719 ----
if (bp)
{
! if (ftype == BINPORT_MAXBINARY)
result = (binport_tobinbuf(bp, bb)
! ? BINPORT_MAXBINARY : BINPORT_CORRUPT);
else if (ftype == BINPORT_MAXTEXT)
{
***************
*** 726,730 ****
binbuf_addv(bb, "ss;", gensym("max"), gensym("v2"));
result = (binport_tobinbuf(bp, bb)
! ? BINPORT_OK : BINPORT_CORRUPT);
}
else result = BINPORT_FAILED;
--- 726,730 ----
binbuf_addv(bb, "ss;", gensym("max"), gensym("v2"));
result = (binport_tobinbuf(bp, bb)
! ? BINPORT_MAXTEXT : BINPORT_CORRUPT);
}
else result = BINPORT_FAILED;
***************
*** 738,742 ****
bp->b_old = old;
if (binpold_load(old) && binport_tobinbuf(bp, bb))
! result = BINPORT_OK;
}
else binpold_failure(filename);
--- 738,742 ----
bp->b_old = old;
if (binpold_load(old) && binport_tobinbuf(bp, bb))
! result = BINPORT_MAXOLD;
}
else binpold_failure(filename);
***************
*** 810,814 ****
if (bp)
{
! if (ftype == BINPORT_OK)
binport_print(bp, stdout);
else if (ftype == BINPORT_MAXTEXT)
--- 810,814 ----
if (bp)
{
! if (ftype == BINPORT_MAXBINARY)
binport_print(bp, stdout);
else if (ftype == BINPORT_MAXTEXT)
Index: fitter.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/fitter.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** fitter.c 11 Jan 2005 10:33:21 -0000 1.1
--- fitter.c 27 Jan 2005 14:42:53 -0000 1.2
***************
*** 26,30 ****
{
t_class *fc_owner;
! t_symbol **fc_mirror;
t_fittermode_callback fc_callback;
struct _fittermode_client *fc_next;
--- 26,30 ----
{
t_class *fc_owner;
! t_canvas *fc_canvas;
t_fittermode_callback fc_callback;
struct _fittermode_client *fc_next;
***************
*** 37,40 ****
--- 37,41 ----
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() */
***************
*** 56,59 ****
--- 57,65 ----
static void fittermode_symbol(t_pd *x, t_symbol *s)
{
+ if (!s || s == &s_)
+ {
+ loudbug_bug("fittermode_symbol");
+ s = fitterps_none;
+ }
fittermode_value = s;
}
***************
*** 65,74 ****
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);
! }
}
--- 71,76 ----
fittermode_value = s;
for (fc = fittermode_clients; fc; fc = fc->fc_next)
if (fc->fc_callback)
! fc->fc_callback();
}
***************
*** 79,85 ****
fitterps_hashcompatibility = gensym("#compatibility");
fitterps_max = gensym("max");
fittermode_class = class_new(fitterps_hashcompatibility,
! 0, 0, sizeof(t_pd),
! CLASS_PD | CLASS_NOINLET, 0);
class_addbang(fittermode_class, fittermode_bang);
class_addsymbol(fittermode_class, fittermode_symbol);
--- 81,89 ----
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);
class_addbang(fittermode_class, fittermode_bang);
class_addsymbol(fittermode_class, fittermode_symbol);
***************
*** 94,112 ****
}
! void fitter_setup(t_class *owner, t_symbol **mirror,
! t_fittermode_callback callback)
{
if (!fittermode_class)
fittermode_dosetup(0);
! if (mirror || callback)
{
t_fittermode_client *fc = getbytes(sizeof(*fc));
fc->fc_owner = owner;
! fc->fc_mirror = mirror;
fc->fc_callback = callback;
fc->fc_next = fittermode_clients;
fittermode_clients = fc;
- if (mirror)
- *mirror = fittermode_value;
}
}
--- 98,113 ----
}
! void fitter_setup(t_class *owner, t_fittermode_callback callback)
{
if (!fittermode_class)
fittermode_dosetup(0);
! if (callback)
{
t_fittermode_client *fc = getbytes(sizeof(*fc));
fc->fc_owner = owner;
! fc->fc_canvas = 0; /* a global client */
fc->fc_callback = callback;
fc->fc_next = fittermode_clients;
fittermode_clients = fc;
}
}
***************
*** 141,145 ****
void fitter_setmode(t_symbol *s)
{
! post("setting compatibility mode to '%s'", (s ? s->s_name : "none"));
if (!fittermode_class)
fittermode_dosetup(1);
--- 142,148 ----
void fitter_setmode(t_symbol *s)
{
! if (!s || s == &s_)
! s = fitterps_none;
! post("setting compatibility mode to '%s'", s->s_name);
if (!fittermode_class)
fittermode_dosetup(1);
Index: Makefile.sources
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/Makefile.sources,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Makefile.sources 11 Jan 2005 10:33:21 -0000 1.5
--- Makefile.sources 27 Jan 2005 14:42:53 -0000 1.6
***************
*** 3,7 ****
clc.c \
dict.c \
- fi.c \
fitter.c \
grow.c \
--- 3,6 ----
***************
*** 9,12 ****
--- 8,12 ----
loud.c \
mifi.c \
+ os.c \
port.c \
props.c \
Index: port.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/port.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** port.c 11 Jan 2005 10:33:21 -0000 1.16
--- port.c 27 Jan 2005 14:42:53 -0000 1.17
***************
*** 1,3 ****
! /* Copyright (c) 1997-2004 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. */
--- 1,3 ----
! /* 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. */
***************
*** 1597,1605 ****
}
! void import_max(char *fn, char *dir)
{
t_port *x;
t_binbuf *inbb, *outbb;
! int fd, ftype;
char buf[MAXPDSTRING], *bufp;
t_pd *stackp = 0;
--- 1597,1606 ----
}
! int import_max(char *fn, char *dir)
{
+ int result;
t_port *x;
t_binbuf *inbb, *outbb;
! int fd;
char buf[MAXPDSTRING], *bufp;
t_pd *stackp = 0;
***************
*** 1609,1613 ****
{
loud_error(0, "%s: can't open", fn);
! return;
}
else close (fd);
--- 1610,1614 ----
{
loud_error(0, "%s: can't open", fn);
! return (BINPORT_NOFILE);
}
else close (fd);
***************
*** 1616,1629 ****
inbb = binbuf_new();
glob_setfilename(0, gensym(bufp), gensym(buf));
! ftype = binport_read(inbb, bufp, buf);
! if (ftype == BINPORT_OK)
{
#ifdef PORT_DEBUG
binport_write(inbb, "import-debug.pat", "");
#endif
outbb = binbuf_new();
! if (import_binbuf(x, inbb, outbb) != PORT_OK)
{
! loud_error(0, "%s: import failed", fn);
binbuf_free(outbb);
outbb = 0;
--- 1617,1637 ----
inbb = binbuf_new();
glob_setfilename(0, gensym(bufp), gensym(buf));
! 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 ((bbresult = import_binbuf(x, inbb, outbb)) != PORT_OK)
{
! 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;
***************
*** 1634,1638 ****
#endif
}
! else if (ftype == BINPORT_PDFILE)
outbb = inbb;
else
--- 1642,1646 ----
#endif
}
! else if (result == BINPORT_PDFILE)
outbb = inbb;
else
***************
*** 1657,1659 ****
--- 1665,1669 ----
pd_doloadbang();
#endif
+
+ return (result);
}
Index: fitter.h
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/fitter.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** fitter.h 11 Jan 2005 10:33:21 -0000 1.1
--- fitter.h 27 Jan 2005 14:42:53 -0000 1.2
***************
*** 6,13 ****
#define __FITTER_H__
! typedef void (*t_fittermode_callback)(t_symbol *s);
! void fitter_setup(t_class *owner, t_symbol **mirror,
! t_fittermode_callback callback);
void fitter_drop(t_class *owner);
void fitter_setmode(t_symbol *s);
--- 6,12 ----
#define __FITTER_H__
! typedef void (*t_fittermode_callback)(void);
! void fitter_setup(t_class *owner, t_fittermode_callback callback);
void fitter_drop(t_class *owner);
void fitter_setmode(t_symbol *s);
Index: binport.h
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/binport.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** binport.h 8 Dec 2004 15:40:12 -0000 1.4
--- binport.h 27 Jan 2005 14:42:53 -0000 1.5
***************
*** 1,3 ****
! /* Copyright (c) 2003-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. */
--- 1,3 ----
! /* 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. */
***************
*** 6,11 ****
#define __BINPORT_H__
! enum { BINPORT_OK, BINPORT_MAXTEXT, BINPORT_MAXOLD, BINPORT_PDFILE,
! BINPORT_INVALID, BINPORT_CORRUPT, BINPORT_FAILED };
#ifndef MIXED_STANDALONE
--- 6,19 ----
#define __BINPORT_H__
! /* 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
--- NEW FILE: os.h ---
/* 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
--- fi.h DELETED ---
Index: loud.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/loud.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** loud.c 11 Jan 2005 10:33:21 -0000 1.5
--- loud.c 27 Jan 2005 14:42:53 -0000 1.6
***************
*** 349,352 ****
--- 349,355 ----
va_end(ap);
fprintf(stderr, "%s\n", buf);
+ #ifdef MSW
+ fflush(stderr);
+ #endif
}
***************
*** 359,362 ****
--- 362,368 ----
va_end(ap);
fputs(buf, stderr);
+ #ifdef MSW
+ fflush(stderr);
+ #endif
}
***************
*** 364,367 ****
--- 370,376 ----
{
fputs("\n", stderr);
+ #ifdef MSW
+ fflush(stderr);
+ #endif
}
***************
*** 373,376 ****
--- 382,388 ----
atom_string(av++, buf, MAXPDSTRING);
fprintf(stderr, " %s", buf);
+ #ifdef MSW
+ fflush(stderr);
+ #endif
}
}
***************
*** 392,398 ****
}
else fprintf(stderr, "%s", buf);
aprev = ap++;
}
! if (aprev) fputs("\n", stderr);
}
--- 404,419 ----
}
else fprintf(stderr, "%s", buf);
+ #ifdef MSW
+ fflush(stderr);
+ #endif
aprev = ap++;
}
! if (aprev)
! {
! fputs("\n", stderr);
! #ifdef MSW
! fflush(stderr);
! #endif
! }
}
***************
*** 405,408 ****
--- 426,432 ----
va_end(ap);
fprintf(stderr, "miXed consistency check failed: %s\n", buf);
+ #ifdef MSW
+ fflush(stderr);
+ #endif
bug(buf);
}
--- fi.c DELETED ---
--- NEW FILE: os.c ---
/* 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")));
}