/** * aim_cloneconn - clone an aim_conn_t * @sess: session containing parent * @src: connection to clone * * A new connection is allocated, and the values are filled in * appropriately. Note that this function sets the new connnection's * ->priv pointer to be equal to that of its parent: only the pointer * is copied, not the data it points to. * * This function returns a pointer to the new aim_conn_t, or %NULL on * error */ faim_internal aim_conn_t *aim_cloneconn(aim_session_t *sess, aim_conn_t *src) { aim_conn_t *conn; if (!(conn = aim_conn_getnext(sess))) return NULL; conn->fd = src->fd; conn->type = src->type; conn->subtype = src->subtype; conn->seqnum = src->seqnum; conn->priv = src->priv; conn->internal = src->internal; conn->lastactivity = src->lastactivity; conn->forcedlatency = src->forcedlatency; conn->sessv = src->sessv; aim_clonehandlers(sess, conn, src); if (src->inside) { /* * XXX should clone this section as well, but since currently * this function only gets called for some of that rendezvous * crap, and not on SNAC connections, its probably okay for * now. * */ } return conn; }
/** * aim_newconn - Open a new connection * @sess: Session to create connection in * @type: Type of connection to create * @dest: Host to connect to (in "host:port" syntax) * * Opens a new connection to the specified dest host of specified * type, using the proxy settings if available. If @host is %NULL, * the connection is allocated and returned, but no connection * is made. * * FIXME: Return errors in a more sane way. * */ faim_export aim_conn_t *aim_newconn(aim_session_t *sess, int type, const char *dest) { aim_conn_t *connstruct; fu16_t port = FAIM_LOGIN_PORT; char *host; int i, ret; if (!(connstruct = aim_conn_getnext(sess))) return NULL; connstruct->sessv = (void *)sess; connstruct->type = type; if (!dest) { /* just allocate a struct */ connstruct->fd = -1; connstruct->status = 0; return connstruct; } /* * As of 23 Jul 1999, AOL now sends the port number, preceded by a * colon, in the BOS redirect. This fatally breaks all previous * libfaims. Bad, bad AOL. * * We put this here to catch every case. * */ for(i = 0; i < (int)strlen(dest); i++) { if (dest[i] == ':') { port = atoi(&(dest[i+1])); break; } } host = (char *)malloc(i+1); strncpy(host, dest, i); host[i] = '\0'; if ((ret = aim_proxyconnect(sess, host, port, &connstruct->status)) < 0) { connstruct->fd = -1; connstruct->status = (errno | AIM_CONN_STATUS_CONNERR); free(host); return connstruct; } else connstruct->fd = ret; free(host); return connstruct; }
/** * aim_newconn - Open a new connection * @sess: Session to create connection in * @type: Type of connection to create * @dest: Host to connect to (in "host:port" syntax) * * Opens a new connection to the specified dest host of specified * type, using the proxy settings if available. If @host is %NULL, * the connection is allocated and returned, but no connection * is made. * * FIXME: Return errors in a more sane way. * */ aim_conn_t *aim_newconn(aim_session_t *sess, int type, const char *dest) { aim_conn_t *connstruct; guint16 port = AIM_LOGIN_PORT; char *host; int i; if (!(connstruct = aim_conn_getnext(sess))) return NULL; connstruct->sessv = (void *)sess; connstruct->type = type; if (!dest) { /* just allocate a struct */ connstruct->fd = -1; connstruct->status = 0; return connstruct; } /* * As of 23 Jul 1999, AOL now sends the port number, preceded by a * colon, in the BOS redirect. This fatally breaks all previous * libfaims. Bad, bad AOL. * * We put this here to catch every case. * */ for(i = 0; i < (int)strlen(dest); i++) { if (dest[i] == ':') { port = atoi(&(dest[i+1])); break; } } host = (char *)g_malloc(i+1); strncpy(host, dest, i); host[i] = '\0'; connstruct->fd = proxy_connect(host, port, NULL, NULL); g_free(host); return connstruct; }