inetnull.cc
1 /******************************************************************** 2 * Description: inetnull.cc 3 * This file provides a set of functions to read from a local 4 * password file 5 * 6 * Derived from a work by Fred Proctor & Will Shackleford 7 * 8 * Author: 9 * License: LGPL Version 2 10 * System: Linux 11 * 12 * Copyright (c) 2004 All rights reserved. 13 * 14 * Last change: 15 ********************************************************************/ 16 17 #include "inetfile.hh" 18 #include <stdio.h> 19 20 class INET_FILE { 21 public: 22 FILE * fp; 23 }; 24 25 int inet_file_init(const char *agent_name, char *agent_version, int debug) 26 { 27 return 0; 28 } 29 30 INET_FILE *inet_file_open(const char *url, char *type) 31 { 32 33 FILE *fp = NULL; 34 INET_FILE *inet_file = NULL; 35 36 fp = fopen(url, type); 37 if (NULL == fp) { 38 return NULL; 39 } 40 inet_file = new INET_FILE; 41 if (NULL != inet_file) { 42 inet_file->fp = fp; 43 } 44 return inet_file; 45 } 46 47 char *inet_file_gets(char *str, int maxlen, INET_FILE * inet_file) 48 { 49 if (NULL == inet_file) { 50 return NULL; 51 } 52 return fgets(str, maxlen, inet_file->fp); 53 } 54 55 int inet_file_close(INET_FILE * inet_file) 56 { 57 if (NULL != inet_file) { 58 fclose(inet_file->fp); 59 delete inet_file; 60 } 61 return 0; 62 } 63 64 int inet_file_eof(INET_FILE * inet_file) 65 { 66 if (NULL == inet_file) { 67 return 1; 68 } 69 return feof(inet_file->fp); 70 } 71 72 int inet_file_exit() 73 { 74 return 0; 75 } 76 77 int inet_file_rewind(INET_FILE * ifp) 78 { 79 if (NULL == ifp) { 80 return -1; 81 } 82 if (ifp->fp != NULL) { 83 rewind(ifp->fp); 84 return 0; 85 } 86 return 0; 87 }