rfc2045find.c
上传用户:s81996212
上传日期:2007-01-04
资源大小:722k
文件大小:1k
- /*
- ** Copyright 1998 - 1999 Double Precision, Inc. See COPYING for
- ** distribution information.
- */
- /*
- ** $Id: rfc2045find.c,v 1.3 1999/12/06 13:29:02 mrsam Exp $
- */
- #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 == ' ') 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);
- }