From 2e003fbbcfd67e6fadb1f882f3240cd4b542a052 Mon Sep 17 00:00:00 2001 From: Martin Peach Date: Wed, 20 Feb 2013 21:00:16 +0000 Subject: fopen and fclose -> sys_fopen and sys_fclose for recent pd svn path=/trunk/externals/mrpeach/; revision=17047 --- net/tcpclient.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/net/tcpclient.c b/net/tcpclient.c index bba25f1..7827001 100644 --- a/net/tcpclient.c +++ b/net/tcpclient.c @@ -47,6 +47,13 @@ #include /* for socklen_t */ #endif +/* support older Pd versions without sys_open(), sys_fopen(), sys_fclose() */ +#if PD_MAJOR_VERSION == 0 && PD_MINOR_VERSION < 44 +#define sys_open open +#define sys_fopen fopen +#define sys_fclose fclose +#endif + #ifdef _MSC_VER #define snprintf sprintf_s #endif @@ -305,7 +312,7 @@ static void tcpclient_send(t_tcpclient *x, t_symbol *s, int argc, t_atom *argv) else if (argv[i].a_type == A_SYMBOL) { atom_string(&argv[i], fpath, FILENAME_MAX); - fptr = fopen(fpath, "rb"); + fptr = sys_fopen(fpath, "rb"); if (fptr == NULL) { post("%s_send: unable to open \"%s\"", objName, fpath); @@ -322,7 +329,7 @@ static void tcpclient_send(t_tcpclient *x, t_symbol *s, int argc, t_atom *argv) j = 0; } } - fclose(fptr); + sys_fclose(fptr); fptr = NULL; if (x->x_verbosity) post("%s_send: read \"%s\" length %d byte%s", objName, fpath, j, ((d==1)?"":"s")); } -- cgit v1.2.1