Skip to content
Snippets Groups Projects
Select Git revision
  • aa4bfb14ff04b95f21236f6c254603d64b0807cc
  • master default protected
2 results

fanout.c

Blame
  • fanout.c 35.85 KiB
    /*
       A simple server in the internet domain using TCP
       MIT Licensed
    */
    
    #define _GNU_SOURCE
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <unistd.h>
    #include <ctype.h>
    #include <sys/types.h>
    #include <pwd.h>
    #include <grp.h>
    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <errno.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netdb.h>
    #include <arpa/inet.h>
    #include <sys/stat.h>
    #include <netinet/in.h>
    #include <time.h>
    #include <getopt.h>
    #include <stdarg.h>
    #include <limits.h>
    #include <sys/resource.h>
    #include <errno.h>
    #include <sys/epoll.h>
    
    
    struct client
    {
        int fd;
        char *input_buffer;
        char *output_buffer;
        struct client *next;
        struct client *previous;
    };
    
    
    struct channel
    {
        char *name;
        struct channel *next;
        struct channel *previous;
        u_int subscription_count;
    };
    
    
    struct subscription
    {
        struct client *client;
        struct channel *channel;
        struct subscription *next;
        struct subscription *previous;
    };
    
    
    int is_numeric (char *str);
    int strcpos (const char *haystack, const char c);
    char *substr (const char *s, int start, int stop);
    void str_swap_free (char **target, char *source);
    char *str_append (char *target, const char *data);
    void clear_socket_buffer (int sock);
    void fanout_error (const char *msg);
    void fanout_debug (int level, const char *format, ...);
    char *getsocketpeername (int fd);