iasrequest.cpp
// Get a new agent (and discard the old one if there was one)
Get a new agent (and discard the old one if there was one)
Get a new agent ( and discard the old one if there was one )
Agent *IAS_Connection::new_agent()
{
	Agent *newagent= NULL;
	if ( c_agent_name.length() ) {
#ifdef AGENT_WGET
		if ( c_agent_name == AgentWget::name ) {
			try {
				newagent= (Agent *) new AgentWget(this);
			}
			catch (...) {
				if ( newagent != NULL ) delete newagent;
				return NULL;
			}
			return newagent;
		}
#endif
#ifdef AGENT_WINHTTP
		if (c_agent_name == AgentWinHttp::name) {
			try {
				newagent = (Agent *) new AgentWinHttp(this);
			}
			catch (...) {
				if ( newagent != NULL ) delete newagent;
				return NULL;
			}
			return newagent;
		}
#endif
	} else {
#ifdef AGENT_WGET
		if ( newagent == NULL ) {
			if ( debug ) eprintf("+++ Trying agent_wget\n");
			try {
				newagent= (Agent *) new AgentWget(this);
			}
			catch (...) { 
				if ( newagent != NULL ) delete newagent;
				newagent= NULL;
			}
		}
#endif
#ifdef AGENT_WINHTTP
		if (newagent == NULL) {
			if (debug) eprintf("+++ Trying agent_winhttp\n");
			try {
				newagent = (Agent *) new AgentWinHttp(this);
			}
			catch (...) { newagent = NULL; }
		}
#endif
	}
	if ( newagent == NULL ) return NULL;
	if ( newagent->initialize() == 0 ) {
		delete newagent;
		return NULL;
	}
	c_agent= newagent;
	return c_agent;
}
Agent * IAS_Connection :: new_agent ( ) { Agent * newagent = NULL ; if ( c_agent_name . length ( ) ) { #ifdef AGENT_WGET if ( c_agent_name == AgentWget :: name ) { try { newagent = ( Agent * ) new AgentWget ( this ) ; } catch ( ... ) { if ( newagent != NULL ) delete newagent ; return NULL ; } return newagent ; } #endif #ifdef AGENT_WINHTTP if ( c_agent_name == AgentWinHttp :: name ) { try { newagent = ( Agent * ) new AgentWinHttp ( this ) ; } catch ( ... ) { if ( newagent != NULL ) delete newagent ; return NULL ; } return newagent ; } #endif } else { #ifdef AGENT_WGET if ( newagent == NULL ) { if ( debug ) eprintf ( " \n " ) ; try { newagent = ( Agent * ) new AgentWget ( this ) ; } catch ( ... ) { if ( newagent != NULL ) delete newagent ; newagent = NULL ; } } #endif #ifdef AGENT_WINHTTP if ( newagent == NULL ) { if ( debug ) eprintf ( " \n " ) ; try { newagent = ( Agent * ) new AgentWinHttp ( this ) ; } catch ( ... ) { newagent = NULL ; } } #endif } if ( newagent == NULL ) return NULL ; if ( newagent -> initialize ( ) == 0 ) { delete newagent ; return NULL ; } c_agent = newagent ; return c_agent ; }
Get a new agent (and discard the old one if there was one)
Get a new agent ( and discard the old one if there was one )
// If we've requested a specific agent, use that one // Otherwise, take the first available using this hardcoded // order of preference.