/*
* Compile commandline: cc -static -g -W -Wall -Wextra -Os -o ip cgi_ip.c
* Source code:
https://04d.co/dl/software/cgi_ip.c
* License: public domain
*/
#include <err.h> /* err(3) */
#include <stdlib.h> /* EXIT_xxxx */
#include <stdio.h> /* puts(3) */
#include <unistd.h> /* pledge(2) */
int main(void)
{
if(pledge("stdio", NULL) == -1)
err(EXIT_FAILURE, "pledge");
char * forwardedFor = getenv("HTTP_X_FORWARDED_FOR");
puts("Status: 200 OK\r");
puts("Content-Type: text/plain\r");
puts("\r");
printf("%s\n", forwardedFor);
return EXIT_SUCCESS;
}