f80935e66086e97d29426bb9053c10eae078385b kent Sun Feb 2 16:22:01 2014 -0800 Moving a check on commands against message size to library since in fact it was already implemented twice, and I needed it a third time. diff --git src/parasol/lib/paraMessage.c src/parasol/lib/paraMessage.c index 9ecb93a..fe90ca9 100644 --- src/parasol/lib/paraMessage.c +++ src/parasol/lib/paraMessage.c @@ -98,30 +98,43 @@ boolean pmSend(struct paraMessage *pm, struct rudp *ru) /* Send out message. Print warning message and return FALSE if * there is a problem. */ { return rudpSend(ru, &pm->ipAddress, pm->data, pm->size) == 0; } boolean pmSendString(struct paraMessage *pm, struct rudp *ru, char *string) /* Send out given message strng. Print warning message and return FALSE if * there is a problem. */ { pmSet(pm, string); return pmSend(pm, ru); } +void pmCheckCommandSize(char *string, int len) +/* Check that string of given len is not too long to fit into paraMessage. + * If it is, abort with good error message assuming it was a command string */ +{ +if (len > rudpMaxSize) + { + errAbort("The following string has %d bytes, but can only be %d:\n%s\n" + "Please either shorten the current directory or the command line\n" + "possibly by making a shell script that encapsulates a long command.\n" + , len, (int)rudpMaxSize, string); + } +} + boolean pmReceiveTimeOut(struct paraMessage *pm, struct rudp *ru, int timeOut) /* Wait up to timeOut microseconds for message. To wait forever * set timeOut to zero. */ { int size = rudpReceiveTimeOut(ru, pm->data, sizeof(pm->data)-1, &pm->ipAddress, timeOut); if (size < 0) { pmClear(pm); return FALSE; } pm->size = size; pm->data[size] = 0; return TRUE; }