|
|
char *ident = _ds_read_attribute(agent_config, "DeliveryIdent"); | char *ident = _ds_read_attribute(agent_config, "DeliveryIdent"); |
int exitcode = EFAILURE; | int exitcode = EFAILURE; |
int msglen, code; | int msglen, code; |
|
int buflen; |
char *inp; | char *inp; |
int i; | int i; |
| |
|
|
i = 0; | i = 0; |
msglen = strlen(msg); | msglen = strlen(msg); |
while(i<msglen) { | while(i<msglen) { |
int r = send(TTX.sockfd, msg+i, msglen - i, 0); |
int r; |
if (r <= 0) { |
int t; |
LOG(LOG_ERR, ERR_CLIENT_SEND_FAILED); |
|
STATUS(ERR_CLIENT_SEND_FAILED); |
/* fill buf with partial msg, replacing \n with \r\n */ |
goto BAIL; |
buflen = 0; |
|
while (buflen < (sizeof(buf) - 1) && i < msglen) { |
|
/* only replace \n and not \r\n */ |
|
if (i > 0 && msg[i] == '\n' && msg[i - 1] != '\r') { |
|
buf[buflen] = '\r'; |
|
buflen++; |
|
} |
|
|
|
buf[buflen] = msg[i]; |
|
buflen++; |
|
i++; |
|
} |
|
|
|
/* send buf */ |
|
t = 0; |
|
while (t < buflen) { |
|
r = send(TTX.sockfd, buf+t, buflen - t, 0); |
|
if (r <= 0) { |
|
LOG(LOG_ERR, ERR_CLIENT_SEND_FAILED); |
|
STATUS(ERR_CLIENT_SEND_FAILED); |
|
goto BAIL; |
|
} |
|
t += r; |
} | } |
i += r; |
|
} | } |
| |
if (msg[strlen(msg)-1]!= '\n') { | if (msg[strlen(msg)-1]!= '\n') { |