Update of /cvsroot/pure-data/externals/mrpeach/net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13583
Modified Files: tcpclient.c Log Message: added file send
Index: tcpclient.c =================================================================== RCS file: /cvsroot/pure-data/externals/mrpeach/net/tcpclient.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcpclient.c 24 Aug 2006 06:51:16 -0000 1.1 --- tcpclient.c 7 Nov 2006 21:18:27 -0000 1.2 *************** *** 86,92 **** static void *tcpclient_new(t_floatarg udpflag); static void tcpclient_free(t_tcpclient *x); - #ifdef MSW - __declspec(dllexport) - #endif void tcpclient_setup(void);
--- 86,89 ---- *************** *** 220,225 **** static void tcpclient_send(t_tcpclient *x, t_symbol *s, int argc, t_atom *argv) { ! static char byte_buf[65536];// arbitrary maximum similar to max IP packet size ! int i, d; unsigned char c; float f, e; --- 217,223 ---- static void tcpclient_send(t_tcpclient *x, t_symbol *s, int argc, t_atom *argv) { ! #define BYTE_BUF_LEN 65536 // arbitrary maximum similar to max IP packet size ! static char byte_buf[BYTE_BUF_LEN]; ! int i, j, d; unsigned char c; float f, e; *************** *** 232,235 **** --- 230,235 ---- double timeafter; int late; + char fpath[MAX_PATH]; + FILE *fptr;
#ifdef DEBUG *************** *** 238,242 **** #endif
! for (i = 0; i < argc; ++i) { if (argv[i].a_type == A_FLOAT) --- 238,242 ---- #endif
! for (i = j = 0; i < argc; ++i) { if (argv[i].a_type == A_FLOAT) *************** *** 262,275 **** post("%s_send: argv[%d]: %d", objName, i, c); #endif ! byte_buf[i] = c; } else { ! error("%s_send: item %d is not a float", objName, i); return; } }
! length = i; if ((x->x_fd >= 0) && (length > 0)) { --- 262,308 ---- post("%s_send: argv[%d]: %d", objName, i, c); #endif ! byte_buf[j++] = c; ! } ! else if (argv[i].a_type == A_SYMBOL) ! { ! ! atom_string(&argv[i], fpath, MAX_PATH); ! #ifdef DEBUG ! post ("%s_send fname: %s", objName, fpath); ! #endif ! fptr = fopen(fpath, "rb"); ! if (fptr == NULL) ! { ! post("%s_send: unable to open "%s"", objName, fpath); ! return; ! } ! rewind(fptr); ! #ifdef DEBUG ! post("%s_send: d is %d", objName, d); ! #endif ! while ((d = fgetc(fptr)) != EOF) ! { ! byte_buf[j++] = (char)(d & 0x0FF); ! #ifdef DEBUG ! post("%s_send: byte_buf[%d] = %d", objName, j-1, byte_buf[j-1]); ! #endif ! if (j >= BYTE_BUF_LEN) ! { ! post ("%s_send: file too long, truncating at %lu", objName, BYTE_BUF_LEN); ! break; ! } ! } ! fclose(fptr); ! fptr = NULL; ! post("%s_send: read "%s" length %d byte%s", objName, fpath, j, ((d==1)?"":"s")); } else { ! error("%s_send: item %d is not a float or a file name", objName, i); return; } }
! length = j; if ((x->x_fd >= 0) && (length > 0)) { *************** *** 424,430 **** }
- #ifdef MSW - __declspec(dllexport) - #endif void tcpclient_setup(void) { --- 457,460 ----