File: rfc2045find.c

package info (click to toggle)
cone 0.89-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 25,628 kB
  • ctags: 14,171
  • sloc: ansic: 85,400; cpp: 82,903; sh: 11,713; makefile: 1,732; perl: 832; yacc: 291; sed: 16
file content (49 lines) | stat: -rw-r--r-- 913 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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);
}