Browse Source

updates concerning how stuff runs

master
0x3F 1 year ago
parent
commit
567517631e
9 changed files with 44 additions and 5 deletions
  1. +2
    -1
      Makefile
  2. +3
    -0
      cgiserver.c
  3. +0
    -0
      nginx_chost.conf
  4. +1
    -0
      nginx_install.sh
  5. BIN
      picoc
  6. +13
    -3
      site-root-data/lib/web_utils.h
  7. +0
    -1
      site-root-data/s/example
  8. BIN
      site-root-data/s/hidden_test/.index.c.swp
  9. +25
    -0
      site-root-data/s/hidden_test/index.c

+ 2
- 1
Makefile View File

@@ -1,4 +1,5 @@
LDLIBS := -lpthread -m32
CFLAGS := -g -pedantic -std=c99
#CFLAGS := -pedantic -std=c99 -Wl,--dynamic-linker -Wl,/lib/ld-musl-i386.so.1
CFLAGS := -pedantic -std=c99

all: cgiserver

+ 3
- 0
cgiserver.c View File

@@ -60,6 +60,7 @@
#define CGI_POST 10240L /* Buffer size for reading POST data to CGI */
#define CGI_BUFFER 10240L /* Buffer size for reading CGI output */
#define FLAT_BUFFER 10240L /* Buffer size for reading flat files */
#define C_INTERPRETER "picoc"

/*
* Standard extensions
@@ -810,7 +811,9 @@ _use_file:
* SERVER_PORT : TCP host port
* SERVER_PROTOCOL : The HTTP version of the request
* SERVER_SOFTWARE : Our application name and version
* C_INTERPRETER : Obvious
*/
setenv("C_INTERPRETER", C_INTERPRETER, 1);
setenv("SERVER_SOFTWARE", VERSION_STRING, 1);
if (!host) {
char hostname[1024];

chost.conf → nginx_chost.conf View File


+ 1
- 0
nginx_install.sh View File

@@ -1,4 +1,5 @@
#!/bin/sh
echo installing
cp -R ../chost /var/www
cp nginx_chost.conf /etc/nginx/sites-enabled
chown -R www-data:www-data /var/www/chost

BIN
picoc View File


+ 13
- 3
site-root-data/lib/web_utils.h View File

@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>


char *string_replace(char *original, char *find, char *replace)
@@ -185,15 +186,24 @@ void unencode(char *src, char *last, char *dest)
void log_string(char *location, char *data1, char *data2, char *data3, char *data4)
{
FILE *f;
char *buffer = malloc(strlen(data1) + strlen(data2) + strlen(data3) + strlen(data4) + 2);
time_t timer;
char t_buffer[26], *buffer = malloc(strlen(data1) + strlen(data2) + strlen(data3) + strlen(data4) + 2 + 26 + 1);
struct tm* tm_info;

time(&timer);
tm_info = localtime(&timer);

strftime(t_buffer, 26, "%Y-%m-%d %H:%M:%S", tm_info);

f = fopen(location, "a");
snprintf(buffer, strlen(data1) + strlen(data2) + strlen(data3) + strlen(data4) + 2, "%s%s%s%s\n", data1, data2, data3, data4);
snprintf(buffer, strlen(data1) + strlen(data2) + strlen(data3) + strlen(data4) + 2 + 26 + 1, "%s %s%s%s%s\n", t_buffer, data1, data2, data3, data4);
fwrite(buffer, 1, strlen(data1) + strlen(data2) + strlen(data3) + strlen(data4) + 1, f);
fwrite(buffer, 1, strlen(buffer), f);

fclose(f);
fprintf(stderr, buffer);

fs_update_event();


+ 0
- 1
site-root-data/s/example

@@ -1 +0,0 @@
Subproject commit f134ba0fc9b294baa8c733a4da683c42dfd84955

BIN
site-root-data/s/hidden_test/.index.c.swp View File


+ 25
- 0
site-root-data/s/hidden_test/index.c View File

@@ -0,0 +1,25 @@
#!../../../picoc
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "../../lib/web_utils.h"

int main(int argc, char **argv)
{
/* necessary for template thing */
//char *page = NULL;
char *page = "<html>[int]</html>";
unsigned long page_len;


/* read the template in*/
//page = read_file("index.template", &page_len);
page = string_replace(page, "[int]", getenv("C_INTERPRETER"));
//log_string("../../../chost.log", "main page visited", "", "", "");

http_reply(page);

return 0;
}

Loading…
Cancel
Save