~retropikzel/fcgi-bridge

81e4a98e19959b6c26b4c931bc61fc40c4373d1e — retropikzel 6 months ago
Backup
8 files changed, 67 insertions(+), 0 deletions(-)

A .gitignore
A Makefile
A dist/fcgi2scgi.fcgi
A init.sh
A manifest.scm
A src/fcgi2scgi.c
A test.cgi
A test.fcgi
A  => .gitignore +2 -0
@@ 1,2 @@
sftp
libs

A  => Makefile +31 -0
@@ 1,31 @@
dist:
	mkdir -p dist

dist/fcgi2scgi.fcgi: libs dist src/fcgi2scgi.c
	zig cc --target=x86_64-linux-musl \
		-o dist/fcgi2scgi.fcgi \
		src/fcgi2scgi.c \
		./libs/fcgi2-2.4.2/libfcgi/os_unix.c \
		./libs/fcgi2-2.4.2/libfcgi/fcgiapp.c \
		./libs/fcgi2-2.4.2/libfcgi/fcgi_stdio.c \
		-I./libs/fcgi2-2.4.2 \
		-I./libs/fcgi2-2.4.2/include \
		-L./libs/fcgi2-2.4.2/libfcgi

libs:
	mkdir -p libs
	cd libs \
		&& wget https://github.com/FastCGI-Archives/fcgi2/archive/refs/tags/2.4.2.tar.gz
	cd libs \
		&& tar -xf *.tar.gz
	cd libs/fcgi2-2.4.2 \
		&& ./autogen.sh
	cd libs/fcgi2-2.4.2 \
		&& ./configure
	cd libs/fcgi2-2.4.2 \
		&& make

clean-all:
	rm -rf libs
	rm -rf dist/*


A  => dist/fcgi2scgi.fcgi +0 -0
A  => init.sh +2 -0
@@ 1,2 @@
#!/bin/bash
echo "Hell from init" > init_output.txt

A  => manifest.scm +5 -0
@@ 1,5 @@
;; What follows is a "manifest" equivalent to the command line you gave.
;; You can store it in a file that you may then pass to any 'guix' command
;; that accepts a '--manifest' (or '-m') option.

(specifications->manifest (list "zig" "gcc-toolchain" "autogen" "m4" "make" "autoconf" "automake" "libtool"))

A  => src/fcgi2scgi.c +16 -0
@@ 1,16 @@
#include <stdlib.h>
#include "fcgi_config.h"
#include "fcgi_stdio.h"


int main () {
    int count = 0;
    while (FCGI_Accept() >= 0) {
        printf("Content-type: text/html\r\n"
                "\r\n"
                "<title>FastCGI echo</title>"
                "<h1>FastCGI echo</h1>\n"
                "Request number %d\n", result);
        exit(0);
    }
}

A  => test.cgi +10 -0
@@ 1,10 @@
#!/bin/bash
# vim: ft=bash

printf "Content-Type: text/html"
printf "\r\n"
printf "\r\n"
echo "Hello"

ldd fcgi2scgi.fcgi


A  => test.fcgi +1 -0
@@ 1,1 @@
#!/bin/bash