summaryrefslogtreecommitdiffstats
path: root/src/standard.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/standard.c')
-rw-r--r--src/standard.c92
1 files changed, 46 insertions, 46 deletions
diff --git a/src/standard.c b/src/standard.c
index 9e8f200..f377bec 100644
--- a/src/standard.c
+++ b/src/standard.c
@@ -1,10 +1,11 @@
-/* Asterisk Manager Proxy
- Copyright (c) 2005 David C. Troy <dave@popvox.com>
+/* Asterisk Manager Proxy
+ Copyright (c) 2005-2006 David C. Troy <dave@popvox.com>
- This program is free software, distributed under the terms of
- the GNU General Public License.
+ This program is free software, distributed under the terms of
+ the GNU General Public License.
- Standard I/O Handler
+ standard.c
+ Standard I/O Handler
*/
#include "astmanproxy.h"
@@ -13,58 +14,57 @@ extern struct mansession *sessions;
/* Return a fully formed message block to session_do for processing */
int _read(struct mansession *s, struct message *m) {
- int res;
-
- for (;;) {
- res = get_input(s, m->headers[m->hdrcount]);
-
- /*fprintf(stderr, "-------> %s\n", m->headers[m->hdrcount]);*/
- if (strstr(m->headers[m->hdrcount], "--END COMMAND--")) {
- if (debug) debugmsg("Found END COMMAND");
- m->in_command = 0;
- }
- if (strstr(m->headers[m->hdrcount], "Response: Follows")) {
- if (debug) debugmsg("Found Response Follows");
- m->in_command = 1;
- }
- if (res > 0) {
- if (!m->in_command && *(m->headers[m->hdrcount]) == '\0' ) {
- break;
- } else if (m->hdrcount < MAX_HEADERS - 1) {
- m->hdrcount++;
- } else {
- m->in_command = 0; // reset when block full
- }
- } else if (res < 0)
- break;
- }
-
- return res;
+ int res;
+
+ for (;;) {
+ res = get_input(s, m->headers[m->hdrcount]);
+
+ if (strstr(m->headers[m->hdrcount], "--END COMMAND--")) {
+ if (debug) debugmsg("Found END COMMAND");
+ m->in_command = 0;
+ }
+ if (strstr(m->headers[m->hdrcount], "Response: Follows")) {
+ if (debug) debugmsg("Found Response Follows");
+ m->in_command = 1;
+ }
+ if (res > 0) {
+ if (!m->in_command && *(m->headers[m->hdrcount]) == '\0' ) {
+ break;
+ } else if (m->hdrcount < MAX_HEADERS - 1) {
+ m->hdrcount++;
+ } else {
+ m->in_command = 0; // reset when block full
+ }
+ } else if (res < 0)
+ break;
+ }
+
+ return res;
}
int _write(struct mansession *s, struct message *m) {
- int i;
+ int i;
- pthread_mutex_lock(&s->lock);
- for (i=0; i<m->hdrcount; i++) {
+ pthread_mutex_lock(&s->lock);
+ for (i=0; i<m->hdrcount; i++) {
ast_carefulwrite(s->fd, m->headers[i], strlen(m->headers[i]) , s->writetimeout);
- ast_carefulwrite(s->fd, "\r\n", 2, s->writetimeout);
- }
- ast_carefulwrite(s->fd, "\r\n", 2, s->writetimeout);
- pthread_mutex_unlock(&s->lock);
+ ast_carefulwrite(s->fd, "\r\n", 2, s->writetimeout);
+ }
+ ast_carefulwrite(s->fd, "\r\n", 2, s->writetimeout);
+ pthread_mutex_unlock(&s->lock);
- return 0;
+ return 0;
}
int _onconnect(struct mansession *s, struct message *m) {
- char banner[100];
+ char banner[100];
- sprintf(banner, "%s/%s\r\n", PROXY_BANNER, PROXY_VERSION);
- pthread_mutex_lock(&s->lock);
- ast_carefulwrite(s->fd, banner, strlen(banner), s->writetimeout);
- pthread_mutex_unlock(&s->lock);
+ sprintf(banner, "%s/%s\r\n", PROXY_BANNER, PROXY_VERSION);
+ pthread_mutex_lock(&s->lock);
+ ast_carefulwrite(s->fd, banner, strlen(banner), s->writetimeout);
+ pthread_mutex_unlock(&s->lock);
- return 0;
+ return 0;
}