summaryrefslogtreecommitdiffstats
path: root/src/standard.c
diff options
context:
space:
mode:
authorDavid Troy <dave@popvox.com>2006-07-01 15:43:37 +0000
committerDavid Troy <dave@popvox.com>2006-07-01 15:43:37 +0000
commit5d52864609b3750bfeb7cda411802900aa190fc3 (patch)
treea7989cf5de2e99955310d8508582e6d19e8712d0 /src/standard.c
parent926f2742b7295cc83b2377535ebcaca2ad09936d (diff)
downloadastmanproxy-5d52864609b3750bfeb7cda411802900aa190fc3.tar.gz
astmanproxy-5d52864609b3750bfeb7cda411802900aa190fc3.tar.xz
astmanproxy-5d52864609b3750bfeb7cda411802900aa190fc3.zip
Cleanup 1.21pre into 1.21 (release)
git-svn-id: http://svncommunity.digium.com/svn/astmanproxy/trunk@129 f02b47b9-160a-0410-81a6-dc3441afb0ec
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;
}