Files
fiche/fiche.h

105 lines
2.7 KiB
C
Raw Normal View History

2013-09-06 04:01:55 +02:00
/*
2013-09-06 04:42:52 +02:00
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/
-------------------------------------------------------------------------------
2015-09-04 12:03:25 +02:00
usage: fiche [-DepbsdolBuw].
[-D] [-e] [-d domain] [-p port] [-s slug size]
2013-09-13 23:51:58 +02:00
[-o output directory] [-B buffer size] [-u user name]
[-l log file] [-b banlist] [-w whitelist]
2013-09-06 04:42:52 +02:00
2015-09-04 12:03:25 +02:00
-D option is for daemonizing fiche
-e option is for using an extended character set for the URL
2013-09-06 04:42:52 +02:00
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
-------------------------------------------------------------------------------
2013-09-06 04:01:55 +02:00
*/
#ifndef FICHE_H
#define FICHE_H
2013-09-13 23:51:58 +02:00
#include <pwd.h>
2013-09-06 04:42:52 +02:00
#include <time.h>
#include <netdb.h>
2013-09-06 04:01:55 +02:00
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <sys/stat.h>
2013-09-06 04:42:52 +02:00
#include <sys/types.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>
2013-09-06 04:01:55 +02:00
2013-09-13 23:51:58 +02:00
int UID = -1;
int GID = -1;
2013-09-09 21:02:33 +02:00
char *LOG;
2013-09-06 04:42:52 +02:00
char *BASEDIR;
2013-09-10 10:30:49 +02:00
char *BANLIST;
char *BANFILE;
2013-09-14 00:17:26 +02:00
char *WHITEFILE;
2013-09-13 23:51:58 +02:00
char *WHITELIST;
2015-09-04 12:03:25 +02:00
int DAEMON = 0;
2013-09-06 04:01:55 +02:00
int PORT = 9999;
int SLUG_SIZE = 4;
2013-09-13 20:32:08 +02:00
int BUFSIZE = 32768;
2013-09-13 23:51:58 +02:00
int QUEUE_SIZE = 500;
2013-09-06 04:01:55 +02:00
char DOMAIN[128] = "http://localhost/";
char symbols[67] = "abcdefghijklmnopqrstuvwxyz0123456789";
2013-09-09 21:02:33 +02:00
2013-10-30 00:39:51 +01:00
unsigned int time_seed;
2013-09-06 04:01:55 +02:00
2013-09-26 13:06:52 +02:00
struct thread_arguments
{
int connection_socket;
struct sockaddr_in client_address;
};
struct client_data
{
char *ip_address;
char *hostname;
};
2013-09-06 04:01:55 +02:00
int create_socket();
int create_directory(char *slug);
2013-09-26 12:36:29 +02:00
int check_protocol(char *buffer);
2013-09-06 04:01:55 +02:00
void bind_to_port(int listen_socket, struct sockaddr_in serveraddr);
2013-09-16 10:53:32 +02:00
void error(char *error_code){perror(error_code); exit(1);}
2013-09-06 04:01:55 +02:00
void perform_connection(int listen_socket);
2013-09-26 13:06:52 +02:00
void generate_url(char *buffer, char *slug, size_t slug_length, struct client_data data);
void save_to_file(char *buffer, char *slug, struct client_data data);
void display_info(struct client_data data, char *slug, char *message);
2013-09-06 04:01:55 +02:00
void startup_message();
void set_basedir();
2013-09-14 00:17:26 +02:00
void load_list(char *file_path, int type);
2013-09-06 04:01:55 +02:00
void parse_parameters(int argc, char **argv);
2013-09-09 21:02:33 +02:00
void save_log(char *slug, char *hostaddrp, char *h_name);
2013-09-13 23:51:58 +02:00
void change_owner(char *directory);
void set_uid_gid();
void info(char *buffer, ...);
2013-09-06 04:01:55 +02:00
2013-09-10 10:30:49 +02:00
char *check_banlist(char *ip_address);
2013-09-14 00:17:26 +02:00
char *check_whitelist(char *ip_address);
2013-09-10 10:30:49 +02:00
char *get_date();
2013-09-06 04:01:55 +02:00
struct sockaddr_in set_address(struct sockaddr_in serveraddr);
2013-09-10 10:30:49 +02:00
struct client_data get_client_address(struct sockaddr_in client_address);
2013-09-06 04:01:55 +02:00
2013-09-17 20:46:02 +04:00
#endif