Test C

Urmatorul program C afisaza variabilele CGI.

#include <stdio.h>
#include <stdlib.h>
/* model de citire a variabilelor de mediu*/
int main(void) {
  printf("Content-type: text/html%c%c",10,10);
  /* MIME html directive */
  printf("AUTH_TYPE: %s<br>",getenv("AUTH_TYPE"));
  printf("CONTENT_LENGTH: %s<br>",getenv("CONTENT_LENGTH"));
  printf("CONTENT_TYPE: %s<br>",getenv("CONTENT_TYPE"));
  printf("GATEWAY_INTERFACE: %s<br>",getenv("GATEWAY_INTERFACE"));
  printf("PATH_INFO: %s<br>",getenv("PATH_INFO"));
  printf("PATH_TRANSLATED: %s<br>",getenv("PATH_TRANSLATED"));
  printf("QUERY_STRING: %s<br>",getenv("QUERY_STRING"));
  printf("REMOTE_ADDR: %s<br>",getenv("REMOTE_ADDR"));
  printf("REMOTE_HOST: %s<br>",getenv("REMOTE_HOST"));
  printf("REMOTE_IDENT: %s<br>",getenv("REMOTE_IDENT"));
  printf("REMOTE_USER: %s<br>",getenv("REMOTE_USER"));
  printf("REQUEST_METHOD: %s<br>",getenv("REQUEST_METHOD"));
  printf("SCRIPT_NAME: %s<br>",getenv("SCRIPT_NAME"));
  printf("SERVER_NAME: %s<br>",getenv("SERVER_NAME"));
  printf("SERVER_PORT: %s<br>",getenv("SERVER_PORT"));
  printf("SERVER_PROTOCOL: %s<br>",getenv("SERVER_PROTOCOL"));
  printf("SERVER_SOFTWARE: %s<br>",getenv("SERVER_SOFTWARE"));
  printf("HTTP_ACCEPT: %s<br>",getenv("HTTP_ACCEPT"));
  printf("HTTP_ACCEPT_ENCODING: %s<br>",getenv("HTTP_ACCEPT_ENCODING"));
  printf("HTTP_ACCEPT_LANGUAGE: %s<br>",getenv("HTTP_ACCEPT_LANGUAGE"));
  printf("HTTP_AUTHORIZATION: %s<br>",getenv("HTTP_AUTHORIZATION"));
  printf("HTTP_CHARGE_TO: %s<br>",getenv("HTTP_CHARGE_TO"));
  printf("HTTP_FROM: %s<br>",getenv("HTTP_FROM"));
  printf("HTTP_IF_MODIFIED_SINCE: %s<br>",getenv("HTTP_IF_MODIFIED_SINCE"));
  printf("HTTP_PRAGMA: %s<br>",getenv("HTTP_PRAGMA"));
  printf("HTTP_REFERER: %s<br>",getenv("HTTP_REFERER"));
  printf("HTTP_USER_AGENT: %s<br>",getenv("HTTP_USER_AGENT"));
  return(0);
}

Apasa butonul de mai jos pentru a vedea variabilele

 

Cornel Mironel Niculae, 2003-2007

05-May-2008