示例#1
0
/*	-----------------------------------------------		*/
private	int	invoke_soap_request( char * action, char * host, char * wsdl, char * filename )
{
	struct	rest_header * hptr;
	struct	rest_response * rptr;
	struct	xml_element * eptr;

	if ( check_verbose() )
		printf("SOAP API REQUEST POST %s %s \n",host, filename);

	if ( check_verbose() )
		printf("SOAP ACTION %s \n",action);

	if (!( hptr = rest_create_header( "soapAction", action )))
		return( 0 );
	else if (!( rptr = rest_client_post_request( host, default_tls(), get_default_agent(), filename, hptr ) ))
		return( 0 );
	else
	{
		if ( check_verbose() )
			printf("SOAP API RESPONSE %u %s \n",rptr->status, (rptr->message ? rptr->message : "NO MESSAGE"));
		if (( rptr->body )
		&&  ((eptr = document_parse_file( rptr->body )) != (struct xml_element *) 0))
		{
			if ( check_verbose() )
				document_show_element( eptr, 0 );
			eptr = document_drop( eptr );
		}
		liberate_rest_response( rptr );
		return( 0 );
	}
}
/*intercepts*/
int pthread_create (pthread_t* thread,
		    __const pthread_attr_t* attr, 
		    void *(*start) (void *), 
		    void *arg) {

  static int (*real_create)(pthread_t * , pthread_attr_t *, void * (*start)(void *), void *) = NULL; /*function pointer to real create function*/
  
  if (!real_create)
    real_create = dlsym(RTLD_NEXT, "pthread_create");
  if(!first_call)
    {
      set_follow();
      check_verbose();
      int got_sched = get_schedule();
      if(!got_sched)
	{
	  fprintf(stderr, "Failed to find the schedule! .... tool will now exit\n");
	  exit(1);
	}
      first_call = 1;
      if(VERBOSE) {
	fprintf(stderr, "Schedule length is: %d\n", schedule_length());
      }
      if(got_sched == 1) {
	fprintf(stderr, "Schedule to be followed:\n");
	output_schedule();
      }
      mutex_lock(&id_lock);
      put_instrumented_id(pthread_self(), 0);
      mutex_unlock(&id_lock);
      if(RECORD_MODE || MONITOR_MODE) {
	fprintf(stderr, "Creating monitor thread ... \n");
	real_create(&monitor_thread, NULL, monitor_progress, NULL);
      }
    }

  /*set up the thread arguments*/
  params* args = malloc(sizeof(params));
  args->thread_id = current_id;
  args->other_args = arg;
  args->function = start;

  current_id++;
  int rc;
  if(no_follow()) {
	return real_create(thread, NULL, start, args);
	}
  if(VERBOSE) {
    printf("Current schedule step: %d\n", schedule[step]);
  }
  /*Run the thread wrapped in another thread*/
  rc = real_create(thread, NULL, run_thread, args);
  step_and_notify();
  if(!no_follow()) {  
    wait();
  }
  
  return rc;
}
void dbg_maskstderr(int mask, char *fmt, ...) 
{
  /*    va_list ap;*/

    if (check_verbose() & mask) {
      vafprintf(stderr, fmt);
      /*    va_start(ap, fmt);
        vfprintf(stderr,fmt,ap);
        va_end(ap);*/
    }
}
int dbg_isverbose(void)
{
    return(check_verbose());
}