added header
This commit is contained in:
31
fiche.c
31
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);
|
||||
|
||||
41
fiche.h
41
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 <pthread.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <pthread.h>
|
||||
#include <time.h>
|
||||
#include <sys/stat.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";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user