Back to index

courier  0.68.2
cgiversion.c
Go to the documentation of this file.
00001 /*
00002 ** Copyright 1998 - 1999 Double Precision, Inc.
00003 ** See COPYING for distribution information.
00004 */
00005 
00006 /*
00007 */
00008 #include      "cgi.h"
00009 #include      <stdlib.h>
00010 #include      <ctype.h>
00011 
00012 void cgiversion(unsigned *major, unsigned *minor)
00013 {
00014 const char *p=getenv("SERVER_PROTOCOL");
00015 
00016        *major=0;
00017        *minor=0;
00018        if (!p)       return;
00019        if ( toupper(*p++) != 'H' ||
00020               toupper(*p++) != 'T' ||
00021               toupper(*p++) != 'T' ||
00022               toupper(*p++) != 'P' ||
00023               *p++ != '/')  return;
00024 
00025        while (isdigit(*p))
00026               *major= *major * 10 + (*p++ - '0');
00027        if (*p++ == '.')
00028        {
00029               while (isdigit(*p))
00030                      *minor= *minor * 10 + (*p++ - '0');
00031        }
00032 }