added header - fiche - A pastebin adjusted for gopher use
(HTM) git clone git://vernunftzentrum.de/fiche.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit c1e0d782ed0e1abed028122e08a8adde09edbcd4
(DIR) parent 5eec8608b72555c6e748beae0cb19a1da6383709
(HTM) Author: solusipse <solus1ps3@gmail.com>
Date: Fri, 6 Sep 2013 04:42:52 +0200
added header
Diffstat:
fiche.c | 31 +++++++++++++++++++++++++------
fiche.h | 41 +++++++++++++++++++++++--------
2 files changed, 56 insertions(+), 16 deletions(-)
---
(DIR) diff --git a/fiche.c b/fiche.c
@@ -1,6 +1,26 @@
/*
-Fiche - terminal pastebin
-Still in development, not usable!
+Fiche - Command line pastebin for sharing terminal output.
+
+-------------------------------------------------------------------------------
+
+License: MIT (http://www.opensource.org/licenses/mit-license.php)
+Repository: https://github.com/solusipse/fiche/
+Live example: http://code.solusipse.net/
+
+-------------------------------------------------------------------------------
+
+usage: fiche [-bdpqs].
+ [-d host_domain.com] [-p port] [-s slug_size]
+ [-o output_directory] [-b buffer_size] [-q queue_size]
+
+Compile with Makefile or manually with -O2 and -pthread flags.
+To install use `make install` command.
+
+Use netcat to push text - example:
+
+$ cat fiche.c | nc localhost 9999
+
+-------------------------------------------------------------------------------
*/
#include "fiche.h"
@@ -136,8 +156,7 @@ void bind_to_port(int listen_socket, struct sockaddr_in server_address)
void generate_url(char *buffer, char *slug)
{
- int i;
- int time_seed = time(0);
+ int i, time_seed = time(0);
memset(slug, '\0', sizeof(slug));
for (i = 0; i <= SLUG_SIZE - 1; i++)
@@ -148,7 +167,7 @@ void generate_url(char *buffer, char *slug)
while (create_directory(slug) == -1)
{
- int symbol_id = rand() % strlen(symbols);
+ int symbol_id = rand_r(&time_seed) % strlen(symbols);
slug[strlen(slug)] = symbols[symbol_id];
}
@@ -157,7 +176,7 @@ void generate_url(char *buffer, char *slug)
int create_directory(char *slug)
{
- char *directory = malloc(100);
+ char *directory = malloc(strlen(BASEDIR) + strlen(slug));
strcpy(directory, BASEDIR);
strcat(directory, slug);
(DIR) diff --git a/fiche.h b/fiche.h
@@ -1,28 +1,49 @@
/*
-Fiche - terminal pastebin
+Fiche - Command line pastebin for sharing terminal output.
+
+-------------------------------------------------------------------------------
+
+License: MIT (http://www.opensource.org/licenses/mit-license.php)
+Repository: https://github.com/solusipse/fiche/
+Live example: http://code.solusipse.net/
+
+-------------------------------------------------------------------------------
+
+usage: fiche [-bdpqs].
+ [-d host_domain.com] [-p port] [-s slug_size]
+ [-o output_directory] [-b buffer_size] [-q queue_size]
+
+Compile with Makefile or manually with -O2 and -pthread flags.
+To install use `make install` command.
+
+Use netcat to push text - example:
+
+$ cat fiche.c | nc localhost 9999
+
+-------------------------------------------------------------------------------
*/
#ifndef FICHE_H
#define FICHE_H
+#include <time.h>
+#include <netdb.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
-#include <netdb.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
#include <pthread.h>
-#include <time.h>
#include <sys/stat.h>
+#include <sys/types.h>
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
-int BUFSIZE = 8192;
-int QUEUE_SIZE = 100;
+char *BASEDIR;
int PORT = 9999;
int SLUG_SIZE = 4;
-char *BASEDIR;
+int BUFSIZE = 8192;
+int QUEUE_SIZE = 100;
char DOMAIN[128] = "http://localhost/";
const char *symbols = "abcdefghijklmnopqrstuvwxyz0123456789";