Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

inetfile.cc File Reference

#include "rcs_defs.hh"
#include "inetfile.hh"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "WWWLib.h"
#include "WWWHTTP.h"
#include "WWWInit.h"
#include <dlfcn.h>

Include dependency graph for inetfile.cc:

Include dependency graph

Go to the source code of this file.

Data Structures

struct  _HTAtom
class  INET_FILE

Defines

#define DL(x)   x
#define YES   (BOOL)1
#define DL(x)   ptr_to_##x

Typedefs

typedef _HTAtom HTAtom
typedef void * HTAnchor
typedef void * HTStream
typedef void * HTChunk
typedef void * HTFormat
typedef void(* HTMemory_free_func_type )(void *)
typedef HTRequest *(* HTRequest_new_func_type )(void)
typedef BOOL(* HTLibInit_func_type )(const char *AppName, const char *AppVersion)
typedef HTList *(* HTList_new_func_type )(void)
typedef void(* HTTransportInit_func_type )(void)
typedef void(* HTProtocolInit_func_type )(void)
typedef void(* HTNetInit_func_type )(void)
typedef void(* HTConverterInit_func_type )(HTList *conversions)
typedef void(* HTFormat_setConversion_func_type )(HTList *list)
typedef void(* HTEncoderInit_func_type )(HTList *encodings)
typedef void(* HTFormat_setTransferCoding_func_type )(HTList *encodings)
typedef void(* HTMIMEInit_func_type )(void)
typedef HTAtom *(* HTAtom_for_func_type )(const char *string)
typedef void(* HTRequest_setOutputStream_func_type )(HTRequest *request, HTStream *output)
typedef void(* HTRequest_setPreemptive_func_type )(HTRequest *request, BOOL mode)
typedef char *(* HTGetCurrentDirectoryURL_func_type )(void)
typedef void(* HTRequest_setOutputFormat_func_type )(HTRequest *request, HTFormat format)
typedef char *(* HTParse_func_type )(const char *aName, const char *relatedName, int wanted)
typedef HTAnchor *(* HTAnchor_findAddress_func_type )(const char *address)
typedef HTChunk *(* HTLoadAnchorToChunk_func_type )(HTAnchor *anchor, HTRequest *request)
typedef char *(* HTChunk_toCString_func_type )(HTChunk *ch)
typedef void(* HTRequest_delete_func_type )(HTRequest *request)
typedef void(* HTFormat_deleteAll_func_type )(void)
typedef BOOL(* HTLibTerminate_func_type )(void)

Functions

int load_libwww_functions (void *handle)
int load_libwww ()
RCS_EXPORT int inet_file_init (const char *agent_name, char *agent_version, int debug)
RCS_EXPORT INET_FILEinet_file_open (const char *url, char *type)
RCS_EXPORT char * inet_file_gets (char *str, int maxlen, INET_FILE *inet_file)
RCS_EXPORT int inet_file_close (INET_FILE *inet_file)
RCS_EXPORT int inet_file_eof (INET_FILE *inet_file)
RCS_EXPORT int inet_file_exit ()
RCS_EXPORT int inet_file_rewind (INET_FILE *ifp)

Variables

int inet_file_initialized = 0
void(* ptr_to_HTMemory_free )(void *)=NULL
HTRequest *(* ptr_to_HTRequest_new )(void)=NULL
BOOL(* ptr_to_HTLibInit )(const char *AppName, const char *AppVersion)=NULL
HTList *(* ptr_to_HTList_new )(void)=NULL
void(* ptr_to_HTTransportInit )(void)=NULL
void(* ptr_to_HTProtocolInit )(void)=NULL
void(* ptr_to_HTNetInit )(void)=NULL
void(* ptr_to_HTConverterInit )(HTList *conversions)=NULL
void(* ptr_to_HTFormat_setConversion )(HTList *list)=NULL
void(* ptr_to_HTEncoderInit )(HTList *encodings)=NULL
void(* ptr_to_HTFormat_setTransferCoding )(HTList *encodings)=NULL
void(* ptr_to_HTMIMEInit )(void)=NULL
HTAtom *(* ptr_to_HTAtom_for )(const char *string)=NULL
void(* ptr_to_HTRequest_setOutputStream )(HTRequest *request, HTStream *output)
void(* ptr_to_HTRequest_setPreemptive )(HTRequest *request, BOOL mode)=NULL
char *(* ptr_to_HTGetCurrentDirectoryURL )(void)=NULL
void(* ptr_to_HTRequest_setOutputFormat )(HTRequest *request, HTFormat format)=NULL
char *(* ptr_to_HTParse )(const char *aName, const char *relatedName, int wanted)=NULL
HTAnchor *(* ptr_to_HTAnchor_findAddress )(const char *address)=NULL
HTChunk *(* ptr_to_HTLoadAnchorToChunk )(HTAnchor *anchor, HTRequest *request)=NULL
char *(* ptr_to_HTChunk_toCString )(HTChunk *ch)=NULL
void(* ptr_to_HTRequest_delete )(HTRequest *request)=NULL
void(* ptr_to_HTFormat_deleteAll )(void)=NULL
BOOL(* ptr_to_HTLibTerminate )(void)=NULL
int load_libwww_status = 0
void * libwww_handle = NULL
int show_load_libwww_errors = 1
HTRequest * request = NULL
HTList * converters = NULL
HTList * encodings = NULL


Define Documentation

#define DL      x
 

Definition at line 547 of file inetfile.cc.

#define YES   (BOOL)1
 

Definition at line 535 of file inetfile.cc.

#define DL      ptr_to_##x
 

Definition at line 547 of file inetfile.cc.


Typedef Documentation

typedef struct _HTAtom HTAtom
 

Definition at line 538 of file inetfile.cc.

typedef void* HTAnchor
 

Definition at line 543 of file inetfile.cc.

typedef void* HTStream
 

Definition at line 544 of file inetfile.cc.

typedef void* HTChunk
 

Definition at line 545 of file inetfile.cc.

typedef void* HTFormat
 

Definition at line 546 of file inetfile.cc.

typedef void(* HTMemory_free_func_type)(void *)
 

Definition at line 582 of file inetfile.cc.

typedef HTRequest*(* HTRequest_new_func_type)(void)
 

Definition at line 583 of file inetfile.cc.

typedef BOOL(* HTLibInit_func_type)(const char *AppName, const char *AppVersion)
 

Definition at line 584 of file inetfile.cc.

typedef HTList*(* HTList_new_func_type)(void)
 

Definition at line 586 of file inetfile.cc.

typedef void(* HTTransportInit_func_type)(void)
 

Definition at line 587 of file inetfile.cc.

typedef void(* HTProtocolInit_func_type)(void)
 

Definition at line 588 of file inetfile.cc.

typedef void(* HTNetInit_func_type)(void)
 

Definition at line 589 of file inetfile.cc.

typedef void(* HTConverterInit_func_type)(HTList * conversions)
 

Definition at line 590 of file inetfile.cc.

typedef void(* HTFormat_setConversion_func_type)(HTList * list)
 

Definition at line 591 of file inetfile.cc.

typedef void(* HTEncoderInit_func_type)(HTList * encodings)
 

Definition at line 592 of file inetfile.cc.

typedef void(* HTFormat_setTransferCoding_func_type)(HTList * encodings)
 

Definition at line 593 of file inetfile.cc.

typedef void(* HTMIMEInit_func_type)(void)
 

Definition at line 594 of file inetfile.cc.

typedef HTAtom*(* HTAtom_for_func_type)(const char *string)
 

Definition at line 595 of file inetfile.cc.

typedef void(* HTRequest_setOutputStream_func_type)(HTRequest * request, HTStream * output)
 

Definition at line 596 of file inetfile.cc.

typedef void(* HTRequest_setPreemptive_func_type)(HTRequest * request, BOOL mode)
 

Definition at line 598 of file inetfile.cc.

typedef char*(* HTGetCurrentDirectoryURL_func_type)(void)
 

Definition at line 600 of file inetfile.cc.

typedef void(* HTRequest_setOutputFormat_func_type)(HTRequest * request, HTFormat format)
 

Definition at line 601 of file inetfile.cc.

typedef char*(* HTParse_func_type)(const char *aName, const char *relatedName, int wanted)
 

Definition at line 603 of file inetfile.cc.

typedef HTAnchor*(* HTAnchor_findAddress_func_type)(const char *address)
 

Definition at line 605 of file inetfile.cc.

typedef HTChunk*(* HTLoadAnchorToChunk_func_type)(HTAnchor * anchor, HTRequest * request)
 

Definition at line 606 of file inetfile.cc.

typedef char*(* HTChunk_toCString_func_type)(HTChunk * ch)
 

Definition at line 608 of file inetfile.cc.

typedef void(* HTRequest_delete_func_type)(HTRequest * request)
 

Definition at line 609 of file inetfile.cc.

typedef void(* HTFormat_deleteAll_func_type)(void)
 

Definition at line 610 of file inetfile.cc.

typedef BOOL(* HTLibTerminate_func_type)(void)
 

Definition at line 611 of file inetfile.cc.


Function Documentation

int load_libwww_functions void *    handle
 

Definition at line 617 of file inetfile.cc.

00618   {
00619     ptr_to_HTMemory_free =
00620       (HTMemory_free_func_type) dlsym (handle, "HTMemory_free");
00621     if (NULL == ptr_to_HTMemory_free)
00622       {
00623         return -1;
00624       }
00625     ptr_to_HTRequest_new =
00626       (HTRequest_new_func_type) dlsym (handle, "HTRequest_new");
00627     if (NULL == ptr_to_HTRequest_new)
00628       {
00629         return -1;
00630       }
00631     ptr_to_HTLibInit = (HTLibInit_func_type) dlsym (handle, "HTLibInit");
00632     if (NULL == ptr_to_HTLibInit)
00633       {
00634         return -1;
00635       }
00636     ptr_to_HTList_new = (HTList_new_func_type) dlsym (handle, "HTList_new");
00637     if (NULL == ptr_to_HTList_new)
00638       {
00639         return -1;
00640       }
00641 
00642     ptr_to_HTTransportInit =
00643       (HTTransportInit_func_type) dlsym (handle, "HTTransportInit");
00644     if (NULL == ptr_to_HTTransportInit)
00645       {
00646         return -1;
00647       }
00648 
00649     ptr_to_HTProtocolInit =
00650       (HTProtocolInit_func_type) dlsym (handle, "HTProtocolInit");
00651     if (NULL == ptr_to_HTProtocolInit)
00652       {
00653         return -1;
00654       }
00655 
00656 
00657     ptr_to_HTNetInit = (HTNetInit_func_type) dlsym (handle, "HTNetInit");
00658     if (NULL == ptr_to_HTNetInit)
00659       {
00660         return -1;
00661       }
00662 
00663     ptr_to_HTConverterInit =
00664       (HTConverterInit_func_type) dlsym (handle, "HTConverterInit");
00665     if (NULL == ptr_to_HTConverterInit)
00666       {
00667         return -1;
00668       }
00669 
00670 
00671     ptr_to_HTFormat_setConversion =
00672       (HTFormat_setConversion_func_type) dlsym (handle,
00673                                                 "HTFormat_setConversion");
00674     if (NULL == ptr_to_HTFormat_setConversion)
00675       {
00676         return -1;
00677       }
00678 
00679 
00680     ptr_to_HTEncoderInit =
00681       (HTEncoderInit_func_type) dlsym (handle, "HTEncoderInit");
00682     if (NULL == ptr_to_HTEncoderInit)
00683       {
00684         return -1;
00685       }
00686 
00687     ptr_to_HTFormat_setTransferCoding =
00688       (HTFormat_setTransferCoding_func_type) dlsym (handle,
00689                                                     "HTFormat_setTransferCoding");
00690     if (NULL == ptr_to_HTFormat_setTransferCoding)
00691       {
00692         return -1;
00693       }
00694 
00695     ptr_to_HTMIMEInit = (HTMIMEInit_func_type) dlsym (handle, "HTMIMEInit");
00696     if (NULL == ptr_to_HTMIMEInit)
00697       {
00698         return -1;
00699       }
00700 
00701     ptr_to_HTAtom_for = (HTAtom_for_func_type) dlsym (handle, "HTAtom_for");
00702     if (NULL == ptr_to_HTAtom_for)
00703       {
00704         return -1;
00705       }
00706 
00707     ptr_to_HTRequest_setOutputStream =
00708       (HTRequest_setOutputStream_func_type) dlsym (handle,
00709                                                    "HTRequest_setOutputStream");
00710     if (NULL == ptr_to_HTRequest_setOutputStream)
00711       {
00712         return -1;
00713       }
00714 
00715     ptr_to_HTRequest_setPreemptive =
00716       (HTRequest_setPreemptive_func_type) dlsym (handle,
00717                                                  "HTRequest_setPreemptive");
00718     if (NULL == ptr_to_HTRequest_setPreemptive)
00719       {
00720         return -1;
00721       }
00722 
00723     ptr_to_HTGetCurrentDirectoryURL =
00724       (HTGetCurrentDirectoryURL_func_type) dlsym (handle,
00725                                                   "HTGetCurrentDirectoryURL");
00726     if (NULL == ptr_to_HTGetCurrentDirectoryURL)
00727       {
00728         return -1;
00729       }
00730 
00731     ptr_to_HTRequest_setOutputFormat =
00732       (HTRequest_setOutputFormat_func_type) dlsym (handle,
00733                                                    "HTRequest_setOutputFormat");
00734     if (NULL == ptr_to_HTRequest_setOutputFormat)
00735       {
00736         return -1;
00737       }
00738 
00739 
00740     ptr_to_HTParse = (HTParse_func_type) dlsym (handle, "HTParse");
00741     if (NULL == ptr_to_HTParse)
00742       {
00743         return -1;
00744       }
00745 
00746 
00747     ptr_to_HTAnchor_findAddress =
00748       (HTAnchor_findAddress_func_type) dlsym (handle, "HTAnchor_findAddress");
00749     if (NULL == ptr_to_HTAnchor_findAddress)
00750       {
00751         return -1;
00752       }
00753 
00754 
00755     ptr_to_HTLoadAnchorToChunk =
00756       (HTLoadAnchorToChunk_func_type) dlsym (handle, "HTLoadAnchorToChunk");
00757     if (NULL == ptr_to_HTLoadAnchorToChunk)
00758       {
00759         return -1;
00760       }
00761 
00762 
00763     ptr_to_HTChunk_toCString =
00764       (HTChunk_toCString_func_type) dlsym (handle, "HTChunk_toCString");
00765     if (NULL == ptr_to_HTChunk_toCString)
00766       {
00767         return -1;
00768       }
00769 
00770 
00771     ptr_to_HTRequest_delete =
00772       (HTRequest_delete_func_type) dlsym (handle, "HTRequest_delete");
00773     if (NULL == ptr_to_HTRequest_delete)
00774       {
00775         return -1;
00776       }
00777 
00778 
00779     ptr_to_HTFormat_deleteAll =
00780       (HTFormat_deleteAll_func_type) dlsym (handle, "HTFormat_deleteAll");
00781     if (NULL == ptr_to_HTFormat_deleteAll)
00782       {
00783         return -1;
00784       }
00785 
00786 
00787     ptr_to_HTLibTerminate =
00788       (HTLibTerminate_func_type) dlsym (handle, "HTLibTerminate");
00789     if (NULL == ptr_to_HTLibTerminate)
00790       {
00791         return -1;
00792       }
00793     return 0;
00794   }

int load_libwww  
 

Definition at line 799 of file inetfile.cc.

00800   {
00801     char libwww_name[256];
00802     char *ldpath = getenv ("LD_LIBRARY_PATH");
00803       libwww_handle = dlopen (NULL, RTLD_LAZY | RTLD_GLOBAL);
00804       memset (libwww_name, 0, 256);
00805     if (NULL != libwww_handle)
00806       {
00807         if (load_libwww_functions (libwww_handle) == 0)
00808           {
00809             load_libwww_status = 1;
00810             return 0;
00811           }
00812       }
00813     else
00814       {
00815         fprintf (stderr, "dlopen failed. %s\n", dlerror ());
00816       }
00817     libwww_handle = dlopen ("libwww.so", RTLD_LAZY | RTLD_GLOBAL);
00818     if (NULL != libwww_handle)
00819       {
00820         if (load_libwww_functions (libwww_handle) == 0)
00821           {
00822             load_libwww_status = 1;
00823             return 0;
00824           }
00825       }
00826     else
00827       {
00828         fprintf (stderr, "dlopen(%s) failed. %s\n", libwww_name, dlerror ());
00829       }
00830 
00831     if (NULL != ldpath)
00832       {
00833         char *dir = strtok (ldpath, ";:,");
00834         while (NULL != dir)
00835           {
00836             if (*dir == 0)
00837               {
00838                 break;
00839               }
00840             strncpy (libwww_name, dir, 256);
00841             strncat (libwww_name, "/libwww.so", 256 - strlen (dir));
00842             libwww_handle = dlopen (libwww_name, RTLD_LAZY | RTLD_GLOBAL);
00843             if (NULL != libwww_handle)
00844               {
00845                 if (load_libwww_functions (libwww_handle) == 0)
00846                   {
00847                     load_libwww_status = 1;
00848                     return 0;
00849                   }
00850               }
00851             else
00852               {
00853                 fprintf (stderr, "dlopen(%s) failed. %s\n", libwww_name,
00854                          dlerror ());
00855               }
00856             dir = strtok (NULL, ";:,");
00857           }
00858       }
00859 
00860     strncpy (libwww_name, "/isd/proj/rcslib/plat/" PLATNAME "/lib", 256);
00861     strcat (libwww_name, "/libwww.so");
00862     libwww_handle = dlopen (libwww_name, RTLD_LAZY | RTLD_GLOBAL);
00863     if (NULL != libwww_handle)
00864       {
00865         if (load_libwww_functions (libwww_handle) == 0)
00866           {
00867             load_libwww_status = 1;
00868             return 0;
00869           }
00870       }
00871     else
00872       {
00873         fprintf (stderr, "dlopen(%s) failed. %s\n", libwww_name, dlerror ());
00874       }
00875     strncpy (libwww_name, "/usr/local/rcslib/plat/" PLATNAME "/lib", 256);
00876     strcat (libwww_name, "/libwww.so");
00877     libwww_handle = dlopen (libwww_name, RTLD_LAZY | RTLD_GLOBAL);
00878     if (NULL != libwww_handle)
00879       {
00880         if (load_libwww_functions (libwww_handle) == 0)
00881           {
00882             load_libwww_status = 1;
00883             return 0;
00884           }
00885       }
00886     else
00887       {
00888         fprintf (stderr, "dlopen(%s) failed. %s\n", libwww_name, dlerror ());
00889       }
00890     strncpy (libwww_name, "/usr/local/nist/rcslib/plat/" PLATNAME "/lib",
00891              256);
00892     strcat (libwww_name, "/libwww.so");
00893     libwww_handle = dlopen (libwww_name, RTLD_LAZY | RTLD_GLOBAL);
00894     if (NULL != libwww_handle)
00895       {
00896         if (load_libwww_functions (libwww_handle) == 0)
00897           {
00898             load_libwww_status = 1;
00899             return 0;
00900           }
00901       }
00902     else
00903       {
00904         fprintf (stderr, "dlopen(%s) failed. %s\n", libwww_name, dlerror ());
00905       }
00906     return (load_libwww_status = -1);
00907   }

RCS_EXPORT int inet_file_init const char *    agent_name,
char *    agent_version,
int    debug
 

Definition at line 959 of file inetfile.cc.

00960 {
00961 #ifdef DYNAMICALLY_LOAD_LIBWWW
00962   switch (load_libwww_status)
00963     {
00964     case 0:
00965       if (load_libwww () == -1)
00966         {
00967           fprintf (stderr, "Can't load www library.\n");
00968           return (-1);
00969         }
00970       break;
00971     case 1:
00972       break;
00973 
00974     case -1:
00975     default:
00976       return (-1);
00977     }
00978 #endif
00979 
00980   if (NULL == request)
00981     {
00982       request = DL (HTRequest_new ());
00983     }
00984   if (NULL == converters)
00985     {
00986       converters = DL (HTList_new ());  /* List of converters */
00987     }
00988   if (NULL == encodings)
00989     {
00990       encodings = DL (HTList_new ());   /* List of encodings */
00991     }
00992 
00993   if (NULL == agent_name)
00994     {
00995       agent_name = "InetFileAgent";
00996     }
00997   if (NULL == agent_version)
00998     {
00999       agent_version = "1.0";
01000     }
01001   /* Initialize libwww core */
01002   DL (HTLibInit (agent_name, agent_version));
01003 
01004   /* Turn on TRACE so we can see what is going on */
01005   if (debug)
01006     {
01007       WWWTRACE = SHOW_CORE_TRACE + SHOW_STREAM_TRACE + SHOW_PROTOCOL_TRACE;
01008     }
01009 
01010   /* Register the default set of transport protocols */
01011   DL (HTTransportInit ());
01012 
01013   /* Register the default set of protocol modules */
01014   DL (HTProtocolInit ());
01015 
01016   /* Register the default set of BEFORE and AFTER callback functions */
01017   DL (HTNetInit ());
01018 
01019   /* Register the default set of converters */
01020   DL (HTConverterInit (converters));
01021   DL (HTFormat_setConversion (converters));
01022 
01023   /* Register the default set of transfer encodings and decoders */
01024   DL (HTEncoderInit (encodings));
01025   DL (HTFormat_setTransferCoding (encodings));
01026 
01027   /* Register the default set of MIME header parsers */
01028   DL (HTMIMEInit ());
01029 
01030   /* Set up the request and pass it to the Library */
01031   DL (HTRequest_setOutputFormat (request, WWW_SOURCE));
01032   DL (HTRequest_setPreemptive (request, YES));
01033 
01034   inet_file_initialized = 1;
01035 
01036   /* I don't know how to detect an error so I always return zero. */
01037   return 0;
01038 }

RCS_EXPORT INET_FILE* inet_file_open const char *    url,
char *    type
 

Definition at line 1042 of file inetfile.cc.

01043 {
01044   HTChunk *chunk = NULL;
01045   char *string = NULL;
01046   INET_FILE *inet_file = NULL;
01047 
01048   if (strncmp (url, "http:", 5) && strncmp (url, "ftp:", 4)
01049       && strncmp (url, "https:", 6) && strncmp (url, "file:", 5))
01050     {
01051       inet_file = new INET_FILE ();
01052       inet_file->local_fp = fopen (url, type);
01053       if (NULL == inet_file->local_fp)
01054         {
01055           delete inet_file;
01056           return NULL;
01057         }
01058       return inet_file;
01059     }
01060 
01061   if (!inet_file_initialized)
01062     {
01063       inet_file_init (NULL, NULL, 0);
01064     }
01065 
01066   if (NULL == url || NULL == request || NULL == converters ||
01067       NULL == encodings)
01068     {
01069       if (NULL != inet_file)
01070         {
01071           delete inet_file;
01072         }
01073       return NULL;
01074     }
01075 
01076   char *cwd = DL (HTGetCurrentDirectoryURL ());
01077   char *absolute_url = DL (HTParse (url, cwd, PARSE_ALL));
01078   if (NULL == absolute_url)
01079     {
01080       if (NULL != inet_file)
01081         {
01082           delete inet_file;
01083         }
01084       return NULL;
01085     }
01086   HTAnchor *anchor = DL (HTAnchor_findAddress (absolute_url));
01087   chunk = DL (HTLoadAnchorToChunk (anchor, request));
01088   HT_FREE (absolute_url);
01089   HT_FREE (cwd);
01090 
01091   /* If chunk != NULL then we have the data */
01092   if (chunk == NULL)
01093     {
01094       if (NULL != inet_file)
01095         {
01096           delete inet_file;
01097         }
01098       return NULL;
01099     }
01100   string = DL (HTChunk_toCString (chunk));
01101   if (string == NULL)
01102     {
01103       if (NULL != inet_file)
01104         {
01105           delete inet_file;
01106         }
01107       return NULL;
01108     }
01109   if (*string == 0)
01110     {
01111       if (NULL != inet_file)
01112         {
01113           delete inet_file;
01114         }
01115       return NULL;
01116     }
01117   inet_file = new INET_FILE;
01118   if (NULL == inet_file)
01119     {
01120       return NULL;
01121     }
01122   inet_file->buffer = string;
01123   inet_file->current_line = inet_file->buffer;
01124   inet_file->local_fp = NULL;
01125 
01126   return inet_file;
01127 }

RCS_EXPORT char* inet_file_gets char *    str,
int    maxlen,
INET_FILE   inet_file
 

Definition at line 1131 of file inetfile.cc.

01132 {
01133   unsigned long bytes_to_copy;
01134   char *next_line;
01135   if (NULL == str || NULL == inet_file)
01136     {
01137       return NULL;
01138     }
01139   if (NULL != inet_file->local_fp)
01140     {
01141       return fgets (str, maxlen, inet_file->local_fp);
01142     }
01143   bytes_to_copy = 0;
01144   next_line = strchr (inet_file->current_line, '\n');
01145   if (next_line != NULL)
01146     {
01147       bytes_to_copy =
01148         ((unsigned long) next_line) -
01149         ((unsigned long) inet_file->current_line);
01150     }
01151   else
01152     {
01153       bytes_to_copy = strlen (inet_file->current_line);
01154     }
01155   bytes_to_copy =
01156     ((int) bytes_to_copy) > ((int) maxlen - 1) ? maxlen - 1 : bytes_to_copy;
01157   strncpy (str, inet_file->current_line, bytes_to_copy);
01158   str[bytes_to_copy] = 0;
01159   if (next_line != NULL)
01160     {
01161       inet_file->current_line = next_line + 1;
01162     }
01163   else
01164     {
01165       inet_file->current_line = NULL;
01166     }
01167   return str;
01168 }

RCS_EXPORT int inet_file_close INET_FILE   inet_file
 

Definition at line 1171 of file inetfile.cc.

01172 {
01173   if (NULL != inet_file)
01174     {
01175       if (NULL != inet_file->local_fp)
01176         {
01177           fclose (inet_file->local_fp);
01178           inet_file->local_fp = NULL;
01179         }
01180       else if (NULL != inet_file->buffer)
01181         {
01182           HT_FREE (inet_file->buffer);
01183           inet_file->buffer = NULL;
01184         }
01185       delete inet_file;
01186     }
01187   return 0;
01188 }

RCS_EXPORT int inet_file_eof INET_FILE   inet_file
 

Definition at line 1191 of file inetfile.cc.

01192 {
01193   if (NULL == inet_file)
01194     {
01195       return 1;
01196     }
01197   if (NULL != inet_file->local_fp)
01198     {
01199       return feof (inet_file->local_fp);
01200     }
01201   if (NULL == inet_file->current_line || NULL == inet_file->buffer)
01202     {
01203       return 1;
01204     }
01205   return !(*inet_file->current_line);
01206 }

RCS_EXPORT int inet_file_exit  
 

Definition at line 1210 of file inetfile.cc.

01211 {
01212 #ifdef DYNAMICALLY_LOAD_LIBWWW
01213   if (load_libwww_status != 1)
01214     {
01215       return -1;
01216     }
01217 #endif
01218 
01219   /* Clean up the request */
01220   DL (HTRequest_delete (request));
01221   DL (HTFormat_deleteAll ());
01222 
01223   /* Terminate the Library */
01224   DL (HTLibTerminate ());
01225 
01226   request = NULL;
01227   converters = NULL;
01228   encodings = NULL;
01229   inet_file_initialized = 0;
01230 
01231 #ifdef DYNAMICALLY_LOAD_LIBWWW
01232   if (NULL != libwww_handle)
01233     {
01234       dlclose (libwww_handle);
01235       libwww_handle = NULL;
01236     }
01237 #endif
01238 
01239   return 0;
01240 }

RCS_EXPORT int inet_file_rewind INET_FILE   ifp
 

Definition at line 1243 of file inetfile.cc.

01244 {
01245   if (NULL != ifp->local_fp)
01246     {
01247       rewind ((FILE *) ifp->local_fp);
01248       return 0;
01249     }
01250   else
01251     {
01252       ifp->current_line = ifp->buffer;
01253     }
01254   return 0;
01255 }


Variable Documentation

int inet_file_initialized = 0 [static]
 

Definition at line 11 of file inetfile.cc.

void(* ptr_to_HTMemory_free)(void *) = NULL [static]
 

Definition at line 549 of file inetfile.cc.

HTRequest*(* ptr_to_HTRequest_new)(void) = NULL [static]
 

Definition at line 550 of file inetfile.cc.

BOOL(* ptr_to_HTLibInit)(const char *AppName, const char *AppVersion) = NULL [static]
 

Definition at line 551 of file inetfile.cc.

HTList*(* ptr_to_HTList_new)(void) = NULL [static]
 

Definition at line 553 of file inetfile.cc.

void(* ptr_to_HTTransportInit)(void) = NULL [static]
 

Definition at line 554 of file inetfile.cc.

void(* ptr_to_HTProtocolInit)(void) = NULL [static]
 

Definition at line 555 of file inetfile.cc.

void(* ptr_to_HTNetInit)(void) = NULL [static]
 

Definition at line 556 of file inetfile.cc.

void(* ptr_to_HTConverterInit)(HTList * conversions) = NULL [static]
 

Definition at line 557 of file inetfile.cc.

void(* ptr_to_HTFormat_setConversion)(HTList * list) = NULL [static]
 

Definition at line 558 of file inetfile.cc.

void(* ptr_to_HTEncoderInit)(HTList * encodings) = NULL [static]
 

Definition at line 559 of file inetfile.cc.

void(* ptr_to_HTFormat_setTransferCoding)(HTList * encodings) = NULL [static]
 

Definition at line 560 of file inetfile.cc.

void(* ptr_to_HTMIMEInit)(void) = NULL [static]
 

Definition at line 562 of file inetfile.cc.

HTAtom*(* ptr_to_HTAtom_for)(const char *string) = NULL [static]
 

Definition at line 563 of file inetfile.cc.

void(* ptr_to_HTRequest_setOutputStream)(HTRequest * request, HTStream * output) [static]
 

Definition at line 564 of file inetfile.cc.

void(* ptr_to_HTRequest_setPreemptive)(HTRequest * request, BOOL mode) = NULL [static]
 

Definition at line 566 of file inetfile.cc.

char*(* ptr_to_HTGetCurrentDirectoryURL)(void) = NULL [static]
 

Definition at line 568 of file inetfile.cc.

void(* ptr_to_HTRequest_setOutputFormat)(HTRequest * request, HTFormat format) = NULL [static]
 

Definition at line 569 of file inetfile.cc.

char*(* ptr_to_HTParse)(const char *aName, const char *relatedName, int wanted) = NULL [static]
 

Definition at line 571 of file inetfile.cc.

HTAnchor*(* ptr_to_HTAnchor_findAddress)(const char *address) = NULL [static]
 

Definition at line 573 of file inetfile.cc.

HTChunk*(* ptr_to_HTLoadAnchorToChunk)(HTAnchor * anchor, HTRequest * request) = NULL [static]
 

Definition at line 575 of file inetfile.cc.

char*(* ptr_to_HTChunk_toCString)(HTChunk * ch) = NULL [static]
 

Definition at line 577 of file inetfile.cc.

void(* ptr_to_HTRequest_delete)(HTRequest * request) = NULL [static]
 

Definition at line 578 of file inetfile.cc.

void(* ptr_to_HTFormat_deleteAll)(void) = NULL [static]
 

Definition at line 579 of file inetfile.cc.

BOOL(* ptr_to_HTLibTerminate)(void) = NULL [static]
 

Definition at line 580 of file inetfile.cc.

int load_libwww_status = 0 [static]
 

Definition at line 613 of file inetfile.cc.

void* libwww_handle = NULL [static]
 

Definition at line 796 of file inetfile.cc.

int show_load_libwww_errors = 1
 

Definition at line 797 of file inetfile.cc.

HTRequest* request = NULL [static]
 

Definition at line 917 of file inetfile.cc.

HTList* converters = NULL [static]
 

Definition at line 918 of file inetfile.cc.

HTList* encodings = NULL [static]
 

Definition at line 919 of file inetfile.cc.


Generated on Sun Dec 2 15:57:09 2001 for rcslib by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001