Beispiel #1
0
int main()
{
    HTList * converters = HTList_new();		/* List of converters */
    HTList * encodings = HTList_new();		/* List of encoders */

    /* Set up the application's event loop. We use the 
       example event loop that comes with the Library.  */
    HTEventInit();

    /* Initialize libwww core */
    HTLibInit("TestApp", "1.0");

    /* Turn on TRACE so we can see what is going on */
    HTSetTraceMessageMask("sop");

    /* Register the default set of transport protocols */
    HTTransportInit();

    /* Register the default set of protocol modules */
    HTProtocolInit();

    /* Register the default set of BEFORE and AFTER filters */
    HTNetInit();

    /* Register the default set of converters */
    HTConverterInit(converters);
    HTFormat_setConversion(converters);

    /* Register the default set of transfer encoders and decoders */
    HTTransferEncoderInit(encodings);
    HTFormat_setTransferCoding(encodings);

    /* Register the default set of file suffix bindings */
    HTFileInit();

    /* Register the default set of MIME header parsers */
    HTMIMEInit();

    /* Register the default set of Icons for directory listings */
    HTIconInit(NULL);

    /* Register the default set of messages and dialog functions */
    HTAlertInit();

    /* Terminate the Library */
    HTLibTerminate();
    return 0;
}
Beispiel #2
0
void DL_InitDownload()
{
	if ( dl_initialized )
	{
		return;
	}

	/* Initiate W3C Reference Library with a client profile */
	HTProfile_newNoCacheClient( PRODUCT_NAME, PRODUCT_VERSION );

	// if you leave the default (interactive)
	// then prompts can happen:
	// This file already exists - replace existing file? (y/n) Can't open output file
	// and cause a www download to fail
	HTAlertInit();
	HTAlert_setInteractive( YES );

	/* And the traces... */
#ifdef _DEBUG
	// see HTHome.c, you can specify the flags - empty string gets you all traces
	HTSetTraceMessageMask( "" );
#endif

	/* Need our own trace and print functions */
	HTPrint_setCallback( Com_VPrintf );
	HTTrace_setCallback( Com_VPrintf );

	/* Add our own filter to terminate the application */
	HTNet_addAfter( terminate_handler, NULL, NULL, HT_ALL, HT_FILTER_LAST );

	HTAlert_add( HTAlertCallback_progress, HT_A_PROGRESS );
	HTAlert_add( HTAlertCallback_confirm, HT_A_CONFIRM );
	HTAlert_add( HTAlertCallback_prompt, HT_A_PROMPT | HT_A_SECRET | HT_A_USER_PW );

	Com_DPrintf(_( "Client download subsystem initialized\n" ));
	dl_initialized = 1;
}
Beispiel #3
0
PRIVATE void client_profile (const char * AppName, const char * AppVersion,
			     BOOL preemptive, BOOL cache, BOOL HTMLParser)
{
    /* If the Library is not already initialized then do it */
    if (!HTLib_isInitialized()) HTLibInit(AppName, AppVersion);

    /* Register the default set of messages and dialog functions */
    HTAlertInit();
    HTAlert_setInteractive(YES);

    if (!converters) {
      converters = HTList_new();
      /* Register the default set of converters */
      HTConverterInit(converters);
      /* Register the default libwww HTML parser */
      if (HTMLParser) HTMLInit(converters);
      /* Set the converters as global converters for all requests */
      HTFormat_setConversion(converters);
    }

    if (!transfer_encodings) {
      transfer_encodings = HTList_new();
      /* Register the default set of transfer encoders and decoders */
      HTTransferEncoderInit(transfer_encodings);
      HTFormat_setTransferCoding(transfer_encodings);
    }

    if (!content_encodings) {
      content_encodings = HTList_new();
      /* Register the default set of content encoders and decoders */
      HTContentEncoderInit(content_encodings);
      if (HTList_count(content_encodings) > 0)
	HTFormat_setContentCoding(content_encodings);
      else {
	HTList_delete(content_encodings);
	content_encodings = NULL;
      }
    }

    /* Register the default set of transport protocols */
    HTTransportInit();

    /* Register the default set of application protocol modules */
    if (preemptive)
	HTProtocolPreemptiveInit();
    else
	HTProtocolInit();

    /* Initialize suffix bindings for local files */
    HTBind_init();

    /* Set max number of sockets we want open simultanously */ 
    HTNet_setMaxSocket(32);

    /* The persistent cache does not work in preemptive mode */
    if (cache) HTCacheInit(NULL, 20);

    /* Register the default set of BEFORE and AFTER filters */
    HTNetInit();

    /* Set up the default set of Authentication schemes */
    HTAAInit();

    /* Get any proxy or gateway environment variables */
    HTProxy_getEnvVar();

    /* Register the default set of MIME header parsers */
    HTMIMEInit();

    /* Register the default set of file suffix bindings */
    HTFileInit();

    /* Register the default set of Icons for directory listings */
    HTIconInit(NULL);
}