diff options
author | David Troy <dave@popvox.com> | 2006-04-08 02:59:37 +0000 |
---|---|---|
committer | David Troy <dave@popvox.com> | 2006-04-08 02:59:37 +0000 |
commit | ab4b54852ac9270880a85acc18a3718fd93e2de2 (patch) | |
tree | 4faa4f0b79a6e642849b5f3344beff4304e41b63 /src/csv.c | |
parent | a6bb95888b0262222975589d8c651798c1f1c773 (diff) | |
parent | edf54a3c22f04b10a0ff8694cf03ed81fd7079c0 (diff) | |
download | astmanproxy-ab4b54852ac9270880a85acc18a3718fd93e2de2.tar.gz astmanproxy-ab4b54852ac9270880a85acc18a3718fd93e2de2.tar.xz astmanproxy-ab4b54852ac9270880a85acc18a3718fd93e2de2.zip |
Trunk, based on 1.20
git-svn-id: http://svncommunity.digium.com/svn/astmanproxy/trunk@101 f02b47b9-160a-0410-81a6-dc3441afb0ec
Diffstat (limited to 'src/csv.c')
-rw-r--r-- | src/csv.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/csv.c b/src/csv.c new file mode 100644 index 0000000..94d9a00 --- /dev/null +++ b/src/csv.c @@ -0,0 +1,30 @@ +/* Asterisk Manager Proxy + Copyright (c) 2005 David C. Troy <dave@popvox.com> + + This program is free software, distributed under the terms of + the GNU General Public License. + + CSV I/O Handler +*/ + +#include "astmanproxy.h" + +/* TODO: catch and expand/handle commas in output */ + +int _write(struct mansession *s, struct message *m) { + int i; + char outstring[MAX_LEN]; + + pthread_mutex_lock(&s->lock); + for (i=0; i<m->hdrcount; i++) { + sprintf(outstring, "\"%s\"", m->headers[i]); + if (i<m->hdrcount-1) + strcat(outstring, ", "); + ast_carefulwrite(s->fd, outstring, strlen(outstring), s->writetimeout); + } + ast_carefulwrite(s->fd, "\r\n\r\n", 4, s->writetimeout); + pthread_mutex_unlock(&s->lock); + + return 0; +} + |