{
struct v250_settings v250 = server->v250;
- char buf[MAX_TEXT_SIZE];
+ char buf[MAX_TEXT_SIZE + 1];
char t = v250.s3;
char r = v250.s4;
unsigned int len;
if (result == NULL)
return;
+ if (strlen(result) > 2048)
+ return;
+
if (v250.is_v1)
- len = snprintf(buf, sizeof(buf), "%c%c%s%c%c", t, r, result,
- t, r);
+ len = sprintf(buf, "%c%c%s%c%c", t, r, result, t, r);
else
- len = snprintf(buf, sizeof(buf), "%s%c", result,
- t);
+ len = sprintf(buf, "%s%c", result, t);
- send_common(server, buf, MIN(len, sizeof(buf)-1));
+ send_common(server, buf, len);
}
void g_at_server_send_final(GAtServer *server, GAtServerResult result)
send_result_common(server, result);
}
-void g_at_server_send_info(GAtServer *server, const char *info)
-{
- send_result_common(server, info);
-}
-
-void g_at_server_send_info_lines(GAtServer *server, GSList *text)
+void g_at_server_send_info(GAtServer *server, const char *line, gboolean last)
{
- char buf[MAX_TEXT_SIZE];
+ char buf[MAX_TEXT_SIZE + 1];
char t = server->v250.s3;
char r = server->v250.s4;
unsigned int len;
- GSList *l;
- if (!text)
+ if (strlen(line) > 2048)
return;
- for (l = text; l; l = l->next) {
- char *line = l->data;
- if (!line)
- return;
-
- len = snprintf(buf, sizeof(buf), "%c%c%s", t, r, line);
- send_common(server, buf, MIN(len, sizeof(buf)-1));
- }
+ if (last)
+ len = sprintf(buf, "%c%c%s%c%c", t, r, line, t, r);
+ else
+ len = sprintf(buf, "%c%c%s", t, r, line);
- len = snprintf(buf, sizeof(buf), "%c%c", t, r);
send_common(server, buf, len);
}
/* Send an unsolicited result code. E.g. RING */
void g_at_server_send_unsolicited(GAtServer *server, const char *result);
-/* Send an information text. The text could contain multiple lines. Each
- * line, including line terminators, should not exceed 2048 characters.
- */
-void g_at_server_send_info_lines(GAtServer *server, GSList *text);
-
/*
* Send a single response line for the command. The line should be no longer
* than 2048 characters. If the response contains multiple lines, use
- * g_at_server_send_info_lines instead, since the formatting of 27.007
- * compliant multi-line responses is different.
+ * FALSE for the 'last' parameter for lines 1 .. n -1, and 'TRUE' for the last
+ * line. This is required for formatting of 27.007 compliant multi-line
+ * responses.
*/
-void g_at_server_send_info(GAtServer *server, const char *line);
+void g_at_server_send_info(GAtServer *server, const char *line, gboolean last);
#ifdef __cplusplus
}