HTPostFormAbsolute()

I'm trying to write a simple program using HTPostFormAbsolute(),
but it doesn't work. What's wrong? Please help me.

libwww ver. 5.1b
OS: SGI IRIX 6.2

Kenichi Mori

----------------------------------------------------------------------

/*
**	CGI POST method test
*/

#include "WWWLib.h"
#include "WWWInit.h"

/**********************************************************************/
/*  set output file to a request  */

PUBLIC FILE *setHTLoadToFile( HTRequest * request, const char * filename )
{
  if ( filename && request ) {
    FILE * fp = NULL;
    
    /* Check if file exists. If so then ask user if we can replace it */
    if (access(filename, F_OK) != -1) {
      HTAlertCallback * prompt = HTAlert_find(HT_A_CONFIRM);
      if (prompt) {
	if ((*prompt)(request, HT_A_CONFIRM, HT_MSG_FILE_REPLACE, NULL,
		      NULL, NULL) != YES)
	  return NULL;
      }
    }
    
    /* If replace then open the file */
    if ((fp = fopen(filename, "wb")) == NULL) {
      HTRequest_addError(request, ERR_NON_FATAL, NO, HTERR_NO_FILE, 
			 (char *) filename, strlen(filename),
			 "HTLoadToFile"); 
      return NULL;
    }
    
    /* Set the output stream and start the request */
    HTRequest_setOutputFormat(request, WWW_SOURCE);
    HTRequest_setOutputStream(request, HTFWriter_new(request, fp, NO));
    
    /*	return HTLoadAbsolute(url, request); */
    return  fp;
    }

    return NULL;
}

/**********************************************************************/

void set_trace()
{
  WWWTRACE = SHOW_ALL_TRACE;
  WWWTRACE &= ~SHOW_MEM_TRACE;
}

/**********************************************************************/

int main (int argc, char ** argv)
{
  char *url =
    "http://mu.www.media.mit.edu/groups/mu/demo/moriken/post-query";
  HTRequest * request;

  HTProfile_newPreemptiveClient("TestApp", "1.0");

  if ( argc == 2 ) {
    url = argv[1];
    fprintf( stderr, "URL = %s\n", url );
  }

  set_trace();
  
  request = HTRequest_new();

  {
    char *filename = "post3.res";
    HTParentAnchor  *anc;		/*  postform  */

    if (url && *url && filename && *filename) {
      HTAssocList *assoc = HTAssocList_new();
      HTAssocList_addObject( assoc, "entry1", "aaa" );

      setHTLoadToFile( request, filename );
      anc = HTPostFormAbsolute( assoc, url, request ); 
    }else
      printf("Bad parameters - please try again\n");
  }

  HTProfile_delete();
  return 0;
}

Received on Friday, 30 May 1997 21:12:39 UTC