libextreme
Mike Machado <mike@innercite.com>

libextreme is a set of functions I have made along the way and have decided to share with the world. Make sure libextreme.a is in your LD_LIBRARY_PATH or that you add the -L flag to your linker flags and link to -lextreme.


#include "extreme.h"

  int strparse(char *string, const char *delimiter, int sections, ...);

    Argument 1 is a pointer to a string
    Argument 2 is a constant string in which to seperate string by.
    Argument 3 is the number of sections to break string into
    Argument 4 - n are pointers to arrays in which to hold the seperated parts into
    Returns the number of sections it was able to split string into, 1 if not split

    Example usage:

      char parta[10], partb[10], partc[10];
      int split;
      char mystring[] = "splitJ7othisJ7oup";

      split = strparse(mystring, "J7o", 3, parta, partb, partc);
      printf("parta is now %s and partb is %s and partc is %s\n", parta, partb, partc);



  int esock_new(char *hostname, int port);

    Argument 1 is string containing the hostname to open a new connection
    Argument 2 is the port to connect to hostname on in integer format
    Returns a file descriptor to the open socket connection, -1 on error

    Example Usage:

      int sockfd;

      sockfd = esock_new("www.slashdot.org", 80); 



  
  char *esock_read(int sockfd);

    Argument 1 is the file descriptor of an open socket connection in which to read data from
    Returns a pointer to a null terminated string read from the socket
    Errors:
       ENOMEM: esock_read is unable to allocate memory to hold data from the socket

    Example Usage:

       char *buffer;
       int sockfd;

       sockfd = esock_new("www.slashdot.org", 80);
       if (sockfd != -1)
         buffer = esock_read(sockfd);




  int esock_write(int sockfd, char *data);

    Argument 1 is the file descriptor of an open socket conection in which to write data to
    Returns the number of charactors succesfully written to the socket

    Example Usage:

       char sendstr[] = "SEND THIS DATA\n";
       int sent;

       sockfd = esock_new("pop3.mailserver.com", 110);
       if (sockfd != -1)
         sent = esock_write(sockfd, sendstr);
      

