README 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. libextreme
  2. Mike Machado <mike@innercite.com>
  3. 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.
  4. #include "extreme.h"
  5. char **strparse(char *string, const char *dilim, int *numsections);
  6. Argument 1 is pointer to the string being parsed
  7. Argument 2 is a constant string in which to seperate string by
  8. Argument 3 is the address if an int to put the number of sections string was split into
  9. Returns the address of a two dimensional array of the split parts
  10. Example usage:
  11. char **parts;
  12. int sections;
  13. int idx;
  14. char string[] = "splitJ7othisJ7oup";
  15. parts = newstrparse(string, "J7o", &sections);
  16. for (idx = 0; idx < sections; idx++)
  17. printf("found part %s\n", parts[idx]);
  18. int esock_new(char *hostname, int port);
  19. Argument 1 is string containing the hostname to open a new connection
  20. Argument 2 is the port to connect to hostname on in integer format
  21. Returns a file descriptor to the open socket connection, -1 on error
  22. Example Usage:
  23. int sockfd;
  24. sockfd = esock_new("www.slashdot.org", 80);
  25. char *esock_read(int sockfd);
  26. Argument 1 is the file descriptor of an open socket connection in which to read data from
  27. Returns a pointer to a null terminated string read from the socket
  28. Errors:
  29. ENOMEM: esock_read is unable to allocate memory to hold data from the socket
  30. Example Usage:
  31. char *buffer;
  32. int sockfd;
  33. sockfd = esock_new("www.slashdot.org", 80);
  34. if (sockfd != -1)
  35. buffer = esock_read(sockfd);
  36. int esock_write(int sockfd, char *data);
  37. Argument 1 is the file descriptor of an open socket conection in which to write data to
  38. Returns the number of charactors succesfully written to the socket
  39. Example Usage:
  40. char sendstr[] = "SEND THIS DATA\n";
  41. int sent;
  42. sockfd = esock_new("pop3.mailserver.com", 110);
  43. if (sockfd != -1)
  44. sent = esock_write(sockfd, sendstr);