(!sm_ptr->retrying &&
(sm_ptr && !sm_ptr->retrying &&
pacf_get_proxy_addr(MWContext *context, char *list, char **ret_proxy_addr,		    u_long *ret_socks_addr, short *ret_socks_port) {#ifdef MOCHA    Bool rv = FALSE;    char *my_copy, *cur, *p, *addr;    PACF_Type type = PACF_TYPE_INVALID;    PACF_Node *node;    PACF_Node *sm_ptr = NULL;    PACF_Node *went_down = NULL;    time_t now = time(NULL);    time_t smallest = (time_t)0;    int proxy_cnt = 0;    int socks_cnt = 0;    int retry_now = 0;    if (!list || !*list || !ret_proxy_addr || !ret_socks_addr || !ret_socks_port)	return FALSE;    if (*ret_proxy_addr || *ret_socks_addr) {	/*	 * We get called here because this proxy/SOCKS server was down.	 */	went_down = pacf_proxy_is_down(context, *ret_proxy_addr,				       *ret_socks_addr, *ret_socks_port);    }    *ret_proxy_addr = NULL;    *ret_socks_addr = 0;    *ret_socks_port = 0;    cur = my_copy = XP_STRDUP(list);    TRACEMSG(("Getting proxy addr from config list: %s", list));	do {	    p = XP_STRCHR(cur, ';');		if (p) {		    do {				*p++ = '\0';		} while (*p && XP_IS_SPACE(*p));		}		for (addr=cur; *addr && !XP_IS_SPACE(*addr); addr++)			;		if (*addr) {		    do {			*addr++ = '\0';		    } while (*addr &&  XP_IS_SPACE(*addr));		}		type = ((!strcasecomp(cur, "DIRECT")) ? PACF_TYPE_DIRECT  :			(!strcasecomp(cur, "PROXY"))  ? PACF_TYPE_PROXY   :			(!strcasecomp(cur, "SOCKS"))  ? PACF_TYPE_SOCKS   :							PACF_TYPE_INVALID );		if (type == PACF_TYPE_DIRECT)           /* don't use a proxy */		  {		      rv = TRUE;		      break;                            /* done */		  }		else if (type ==  PACF_TYPE_PROXY ||    /* use a proxy or... */       			 type ==  PACF_TYPE_SOCKS )     /* use SOCKS */		  {		      if (type == PACF_TYPE_PROXY)			  proxy_cnt++;		      else			  socks_cnt++;	      node = lookup_create_node(type, addr);		      if (*addr && node) {			  if (node->down_since && node->retrying &&			      now - node->retrying > PACF_RETRY_OK_AFTER)			    {				node->down_since = node->retrying = (time_t)0;			    }			  if (!node->down_since)			    {				if (fill_return_values(type, node,						       ret_proxy_addr,						       ret_socks_addr,						       ret_socks_port))				  {				      rv = TRUE;				      break;				  }			    }			  else if (now - node->last_try >				   (node->retries + 1) * PACF_AUTO_RETRY_AFTER)			    {				node->retries++;				if (fill_return_values(type, node,						       ret_proxy_addr,						       ret_socks_addr,						       ret_socks_port))				  {				      node->retrying = now;				      rv = TRUE;				      break;				  }			    }			  else if (node != went_down &&				   (!smallest || smallest > node->last_try))			    {				smallest = node->last_try;				sm_ptr = node;			    }		      }		  }		else                                    /* invalid entry */		  {		    char *key = NULL;		    if (!pacf_bad_keywords)			{			    pacf_bad_keywords = XP_ListNew();			}		    else			{			    XP_List *ptr = pacf_bad_keywords;			    while ((key = (char *)XP_ListNextObject(ptr)) != NULL) {				if (!strcmp(key, cur))				    break;			    }			}		      if (!key && XP_ListCount(pacf_bad_keywords) < 3)			{			    key = XP_STRDUP(cur);			    XP_ListAddObject(pacf_bad_keywords, key);			    alert2(context, XP_GetString(XP_BAD_KEYWORD_IN_PROXY_AUTOCFG), cur);			}		  }		cur = p;	    } while (cur && *cur);    XP_FREE(my_copy);    if (rv)	  return TRUE;	/* If we didn't return just above here, and we're using a pad pac file,	 * something went wrong with it so disable it for this session and return	 * true so we go direct. */	if(NET_UsingPadPac()) {		net_UsePadPac(FALSE);		return TRUE;	}    if (pacf_do_failover && pacf_direct_until) {	  if (now < pacf_direct_until)	    {		return TRUE;	    }	  else if (!FE_Confirm(context,			       !socks_cnt ? XP_GetString(XP_RETRY_AGAIN_PROXY) :			       !proxy_cnt ? XP_GetString(XP_RETRY_AGAIN_SOCKS) : XP_GetString(XP_RETRY_AGAIN_PROXY_OR_SOCKS)))	    {		pacf_direct_until = now + (++pacf_direct_cnt) * PACF_DIRECT_INTERVAL;		return TRUE;	    }	  else	    {		pacf_direct_until = (time_t)0;		retry_now = 1;	    }	}    if (smallest &&	(retry_now ||	 now - smallest > PACF_MIN_RETRY_AFTER ||	 (!sm_ptr->retrying &&	  now - smallest > PACF_MIN_RETRY_ASK &&	  confirm2(context,		   (!socks_cnt && proxy_cnt==1 ? XP_GetString(XP_PROXY_UNAVAILABLE_TRY_AGAIN) :		    !socks_cnt && proxy_cnt >1 ? XP_GetString(XP_ALL_PROXIES_DOWN_TRY_AGAIN) :		    !proxy_cnt                 ? XP_GetString(XP_ALL_SOCKS_DOWN) :						 XP_GetString(XP_ALL_DOWN_MIX)),		   sm_ptr->addr))) &&	fill_return_values(type, sm_ptr,			   ret_proxy_addr, ret_socks_addr, ret_socks_port))      {	  sm_ptr->retrying = now;	  sm_ptr->retries++;	  return TRUE;      }    else if (pacf_do_failover && FE_Confirm(context,			!pacf_direct_cnt ?			(!socks_cnt ? XP_GetString(XP_OVERRIDE_PROXY) :			 !proxy_cnt ? XP_GetString(XP_OVERRIDE_SOCKS) : XP_GetString(XP_OVERRIDE_MIX)) :			(!socks_cnt ? XP_GetString(XP_STILL_OVERRIDE_PROXY) :			 !proxy_cnt ? XP_GetString(XP_STILL_OVERRIDE_SOCKS) : XP_GetString(XP_STILL_OVERRIDE_SOCKS))))      {	  pacf_direct_until = now + (++pacf_direct_cnt) * PACF_DIRECT_INTERVAL;	  return TRUE;      }    else      {	  return FALSE;      }#else	return FALSE;#endif /* MOCHA */}