summaryrefslogtreecommitdiffstats
path: root/rfc2045/rfc2045find.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 /rfc2045/rfc2045find.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 'rfc2045/rfc2045find.c')
-rw-r--r--rfc2045/rfc2045find.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/rfc2045/rfc2045find.c b/rfc2045/rfc2045find.c
new file mode 100644
index 0000000..b1368ad
--- /dev/null
+++ b/rfc2045/rfc2045find.c
@@ -0,0 +1,49 @@
+/*
+** Copyright 1998 - 1999 Double Precision, Inc. See COPYING for
+** distribution information.
+*/
+
+/*
+*/
+#include "rfc2045.h"
+#include <ctype.h>
+
+struct rfc2045findstruct {
+
+ const char *partnum;
+ struct rfc2045 *ptr;
+ } ;
+
+static void do_decode(struct rfc2045 *p, struct rfc2045id *id, void *ptr)
+{
+struct rfc2045findstruct *fs=(struct rfc2045findstruct *)ptr;
+const char *partnum=fs->partnum;
+unsigned n;
+
+ while (id)
+ {
+ if (!isdigit((int)(unsigned char)*partnum)) return;
+ n=0;
+ while (isdigit((int)(unsigned char)*partnum))
+ n=n*10 + *partnum++ - '0';
+ if (*partnum)
+ {
+ if (*partnum != '.') return;
+ ++partnum;
+ }
+ if (n != (unsigned)id->idnum) return;
+ id=id->next;
+ }
+ if ( *partnum == '\0') fs->ptr=p;
+}
+
+
+struct rfc2045 *rfc2045_find(struct rfc2045 *p, const char *str)
+{
+struct rfc2045findstruct fs;
+
+ fs.partnum=str;
+ fs.ptr=0;
+ rfc2045_decode(p, &do_decode, &fs);
+ return (fs.ptr);
+}