File: cgiversion.c

package info (click to toggle)
courier 1.5.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 54,460 kB
  • sloc: ansic: 130,619; cpp: 33,255; sh: 10,437; perl: 4,250; makefile: 3,447; sed: 39
file content (32 lines) | stat: -rw-r--r-- 574 bytes parent folder | download | duplicates (10)
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
/*
** Copyright 1998 - 1999 Double Precision, Inc.
** See COPYING for distribution information.
*/

/*
*/
#include	"cgi.h"
#include	<stdlib.h>
#include	<ctype.h>

void cgiversion(unsigned *major, unsigned *minor)
{
const char *p=getenv("SERVER_PROTOCOL");

	*major=0;
	*minor=0;
	if (!p)	return;
	if ( toupper(*p++) != 'H' ||
		toupper(*p++) != 'T' ||
		toupper(*p++) != 'T' ||
		toupper(*p++) != 'P' ||
		*p++ != '/')	return;

	while (isdigit(*p))
		*major= *major * 10 + (*p++ - '0');
	if (*p++ == '.')
	{
		while (isdigit(*p))
			*minor= *minor * 10 + (*p++ - '0');
	}
}