1: .TH OPENNET 3 "25 Nov 04" "@PACKAGE_STRING@" 2: .SH NAME 3: opennet \- URL handling library. 4: 5: .SH SYNOPSIS 6: .B #include <opennet.h> 7: .sp 8: .BI "int open_net(const char *" pathname ", int " flags ", mode_t " mode ");" 9: .br 10: .BI "off_t lseek_net(int " filedes ", off_t " offset ", int " whence ");" 11: .br 12: .BI "ssize_t read_net(int " fd ", void *" buf ", size_t " count ");" 13: .br 14: .BI "NETFILE *fopen_net(const char *" path ", const char *" mode ");" 15: .br 16: .BI "int fseek_net(NETFILE *" stream ", long " offset ", int " whence ");" 17: .br 18: .BI "int fgets_net(char *" s ", int " size ", NETFILE *" stream ");" 19: .br 20: .BI "int fread_net(void *" ptr ", size_t " size ", size_t " nmemb ", NETFILE *" stream ");" 21: 22: .SH DESCRIPTION 23: Opennet is a library to provide an easy mechanism to open and handle URLs in the same way you would open and handle a regular file. 24: 25: .SH EXAMPLE 26: .nf 27: #include <opennet.h> 28: #include <stdlib.h> 29: #include <unistd.h> 30: #include <stdio.h> 31: 32: int main(int argc, char **argv) { 33: NETFILE *fp = NULL; 34: char *filename = NULL, *fg_ret = NULL; 35: char buf[512] = {0}; 36: 37: filename = "http://www.rkeene.org/robots.txt"; 38: 39: fp = fopen_net(filename, "r"); 40: 41: if (fp == NULL) { 42: fprintf(stder, "fopen: Error\n"); 43: return(EXIT_FAILURE); 44: } 45: 46: fg_ret = fgets_net(buf, sizeof(buf) - 1, fp); 47: 48: if (fg_ret == NULL) { 49: fprintf(stder, "fgets: Error\n"); 50: return(EXIT_FAILURE); 51: } 52: 53: printf("read: %s", buf); 54: 55: return(EXIT_SUCCESS); 56: } 57: .fi 58: 59: .SH "SEE ALSO" 60: .BR fopen_net (3), 61: .BR fseek_net (3), 62: .BR lseek_net (3), 63: .BR open_net (3), 64: .BR read_net (3) |