Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3417
Modified Files: Tag: devel_0_37 u_pdsend.c Log Message: added command line feature to send messages
Index: u_pdsend.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/u_pdsend.c,v retrieving revision 1.1.1.3 retrieving revision 1.1.1.3.2.1 diff -C2 -d -r1.1.1.3 -r1.1.1.3.2.1 *** u_pdsend.c 9 May 2003 16:03:44 -0000 1.1.1.3 --- u_pdsend.c 1 Apr 2004 09:54:58 -0000 1.1.1.3.2.1 *************** *** 49,52 **** --- 49,63 ---- else goto usage; } + + //patch: support for command line messages by tim blechmann + char message[BUFSIZE*10]; //we allow pretty long messages + if (argc == 5) + { + strncpy(message,*(argv+4),strlen(*(argv+4))); + } + if (argc > 5) + goto usage; + //end of patch + else protocol = SOCK_STREAM; #ifdef MSW *************** *** 101,104 **** --- 112,136 ---- } #endif + + //patch: support for command line messages by tim blechmann + if (argc==5) + { + char *bp, nsent, nsend; + nsend = strlen(message); + for (bp = message, nsent = 0; nsent < nsend;) + { + int res = send(sockfd, message, nsend-nsent, 0); + if (res < 0) + { + sockerror("send"); + goto done; + } + nsent += res; + bp += res; + } + } + else + //end of patch + /* now loop reading stdin and sending it to socket */ while (1) *************** *** 125,130 **** exit (0); usage: ! fprintf(stderr, "usage: pdsend <portnumber> [host] [udp|tcp]\n"); fprintf(stderr, "(default is localhost and tcp)\n"); exit(1); } --- 157,166 ---- exit (0); usage: ! //usage message adapted to the command line message patch ! fprintf(stderr, ! "usage: pdsend <portnumber> [host] [udp|tcp] ["message"]\n"); fprintf(stderr, "(default is localhost and tcp)\n"); + fprintf(stderr, "(if no message is given, pdsend reads from stdin)\n"); + exit(1); }