static int get_rpid_num(const char *input, char *output, int maxlen);
static int get_rdnis(struct sip_pvt *p, struct sip_request *oreq);
static int get_destination(struct sip_pvt *p, struct sip_request *oreq);
-static int get_msg_text(char *buf, int len, struct sip_request *req);
+static int get_msg_text(char *buf, int len, struct sip_request *req, int addnewline);
static int transmit_state_notify(struct sip_pvt *p, int state, int full, int timeout);
/*--- Constructing requests and responses */
}
/*! \brief Get text out of a SIP MESSAGE packet */
-static int get_msg_text(char *buf, int len, struct sip_request *req)
+static int get_msg_text(char *buf, int len, struct sip_request *req, int addnewline)
{
int x;
int y;
y = len - strlen(buf) - 5;
if (y < 0)
y = 0;
- for (x=0;x<req->lines;x++) {
+ for (x=0; x < req->lines; x++) {
strncat(buf, req->line[x], y); /* safe */
y -= strlen(req->line[x]) + 1;
if (y < 0)
y = 0;
- if (y != 0)
+ if (y != 0 && addnewline)
strcat(buf, "\n"); /* safe */
}
return 0;
return;
}
- if (get_msg_text(buf, sizeof(buf), req)) {
+ if (get_msg_text(buf, sizeof(buf), req, FALSE)) {
ast_log(LOG_WARNING, "Unable to retrieve text from %s\n", p->callid);
transmit_response(p, "202 Accepted", req);
if (!p->owner)
return;
}
- get_msg_text(buf, sizeof(buf), req);
+ get_msg_text(buf, sizeof(buf), req, TRUE);
duration = 100; /* 100 ms */
if (ast_strlen_zero(buf)) {
}
/* Get the text of the attachment */
- if (get_msg_text(buf, sizeof(buf), req)) {
+ if (get_msg_text(buf, sizeof(buf), req, TRUE)) {
ast_log(LOG_WARNING, "Unable to retrieve attachment from NOTIFY %s\n", p->callid);
transmit_response(p, "400 Bad request", req);
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);