SUBROUTINE CGIRETRIEVE C C---------------------------------------------------------------------- C C.IDENTIFICATION: Subroutine CGIRETRIEVE C.LIBRARY: CGILIB C.AUTHOR: L.Chiappetti - IFCTR Milano C.VERSIONS: 0.0 - 10 Feb 99 - original versions C.PURPOSE: retrieve POST or GET query string C.SYNTAX: not intended to be called by user, called implicitly C first time by GET_xxx_VARIABLE routines C.PARAMETERS: none C it loads the CGI common instead ! C C---------------------------------------------------------------------- C INCLUDE 'cgi.inc' INTEGER NTIMES DATA NTIMES /0/ SAVE NTIMES C C retrieve the query string only the first time is called IF (NTIMES.EQ.0)THEN IF(CGIDEBUG)write(*,*)'CGI debug flag is ON' NTIMES=1 C get environment variable with GET or POST method CALL GET_GLOBAL_DEFAULT('REQUEST_METHOD','unknown',CGIMETHOD) IF(CGIDEBUG)CALL CGITOKEN('h1','method '//CGIMETHOD) C C for POST method there is an environment variable with the length in bytes C and then one reads from stdin (yeah, this works even on Digital Unix) IF(CGIMETHOD.EQ.'POST')THEN CALL GET_GLOBAL_DEFAULT('CONTENT_LENGTH','unknown',CGISTRING) IF(CGIDEBUG)CALL CGITOKEN('i','content-length '//CGIstring) READ(CGISTRING,*)LCONTENT IF(LCONTENT.GT.MAXCGI)THEN write(*,*)'
Error : POST method gives ',LCONTENT,' bytes'
write(*,*)'but the buffer is only ',MAXCGI,' bytes'
write(*,*)'query string is truncated'
LCONTENT=MAXCGI
ENDIF
C--> might allocate LCONTENT bytes, so far use static variable
C--> but beware, it might be truncated !!
READ(*,'(A)')CGISTRING(:LCONTENT)
IF(CGIDEBUG)write(*,*)'
stdin ',blu,CGIstring,blk,'
' C C for GET method there is an environment variable with the query C CONTENT_LENGTH not defined : no way to tell if string is truncated ELSEIF(CGIMETHOD.EQ.'GET')THEN CALL GET_GLOBAL_DEFAULT('QUERY_STRING','unknown',CGISTRING) IF(CGIDEBUG)write(*,*)'query string ',blu,CGIstring,blk,'
' ELSE write(*,*)'
Error : unknown method ',CGIMETHOD STOP ENDIF ENDIF RETURN END C BLOCK DATA CGIBLK INCLUDE 'cgi.inc' DATA CGIDEBUG /.FALSE./ END