summaryrefslogtreecommitdiffstats
path: root/rfc822/rfc822_getaddr.c
diff options
context:
space:
mode:
authorSam Varshavchik2013-08-19 16:39:41 -0400
committerSam Varshavchik2013-08-25 14:43:51 -0400
commit9c45d9ad13fdf439d44d7443ae75da15ea0223ed (patch)
tree7a81a04cb51efb078ee350859a64be2ebc6b8813 /rfc822/rfc822_getaddr.c
parenta9520698b770168d1f33d6301463bb70a19655ec (diff)
downloadcourier-libs-9c45d9ad13fdf439d44d7443ae75da15ea0223ed.tar.bz2
Initial checkin
Imported from subversion report, converted to git. Updated all paths in scripts and makefiles, reflecting the new directory hierarchy.
Diffstat (limited to 'rfc822/rfc822_getaddr.c')
-rw-r--r--rfc822/rfc822_getaddr.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/rfc822/rfc822_getaddr.c b/rfc822/rfc822_getaddr.c
new file mode 100644
index 0000000..6286727
--- /dev/null
+++ b/rfc822/rfc822_getaddr.c
@@ -0,0 +1,46 @@
+/*
+** Copyright 1998 - 2008 Double Precision, Inc.
+** See COPYING for distribution information.
+*/
+
+/*
+*/
+#include "rfc822.h"
+#include <stdlib.h>
+
+static void cntlen(char c, void *p)
+{
+ if (c != '\n')
+ ++ *(size_t *)p;
+}
+
+static void saveaddr(char c, void *p)
+{
+ if (c != '\n')
+ {
+ char **cp=(char **)p;
+
+ *(*cp)++=c;
+ }
+}
+
+char *rfc822_getaddr(const struct rfc822a *rfc, int n)
+{
+ return rfc822_display_addr_tobuf(rfc, n, NULL);
+}
+
+char *rfc822_gettok(const struct rfc822token *t)
+{
+size_t addrbuflen=0;
+char *addrbuf, *ptr;
+
+ rfc822tok_print(t, &cntlen, &addrbuflen);
+
+ if (!(addrbuf=malloc(addrbuflen+1)))
+ return (0);
+
+ ptr=addrbuf;
+ rfc822tok_print(t, &saveaddr, &ptr);
+ addrbuf[addrbuflen]=0;
+ return (addrbuf);
+}