/* convert a UI to a URL, returns allocated string */ char *convertUIToURL(struct iurlinfo *ui) { char * login; char * finalPrefix; char * url; if (!strcmp(ui->prefix, "/")) finalPrefix = "/."; else finalPrefix = ui->prefix; login = ""; login = getLoginName(login, ui); url = malloc(strlen(finalPrefix) + 25 + strlen(ui->address) + strlen(login)); sprintf(url, "%s://%s%s/%s", ui->protocol == URL_METHOD_FTP ? "ftp" : "http", login, ui->address, finalPrefix); return url; }
std::string SIPAccount::getFromUri (void) const { char uri[PJSIP_MAX_URL_SIZE]; std::string scheme; std::string transport; std::string username = _username; std::string hostname = _hostname; // UDP does not require the transport specification if (_transportType == PJSIP_TRANSPORT_TLS) { scheme = "sips:"; transport = ";transport=" + std::string (pjsip_transport_get_type_name (_transportType)); } else { scheme = "sip:"; transport = ""; } // Get login name if username is not specified if (_username.empty()) { username = getLoginName(); } // Get machine hostname if not provided if (_hostname.empty()) { hostname = getMachineName(); } int len = pj_ansi_snprintf (uri, PJSIP_MAX_URL_SIZE, "<%s%s@%s%s>", scheme.c_str(), username.c_str(), hostname.c_str(), transport.c_str()); return std::string (uri, len); }
char * mountUrlImage(struct installMethod * method, char * location, struct loaderData_s * loaderData, moduleInfoSet modInfo, moduleList modLoaded, moduleDeps * modDeps) { int rc; char * url, *p; struct iurlinfo ui; char needsSecondary = ' '; int dir = 1; char * login; char * finalPrefix; char * cdurl; enum { URL_STAGE_MAIN, URL_STAGE_SECOND, URL_STAGE_FETCH, URL_STAGE_DONE } stage = URL_STAGE_MAIN; enum urlprotocol_t proto = !strcmp(method->name, "FTP") ? URL_METHOD_FTP : URL_METHOD_HTTP; /* JKFIXME: we used to do another ram check here... keep it? */ memset(&ui, 0, sizeof(ui)); while (stage != URL_STAGE_DONE) { switch(stage) { case URL_STAGE_MAIN: if ((loaderData->method == METHOD_FTP || loaderData->method == METHOD_HTTP) && loaderData->methodData) { url = ((struct urlInstallData *)loaderData->methodData)->url; logMessage(INFO, "URL_STAGE_MAIN - url is %s", url); if (!url) { logMessage(ERROR, "missing url specification"); loaderData->method = -1; break; } /* explode url into ui struct */ convertURLToUI(url, &ui); /* ks info was adequate, lets skip to fetching image */ stage = URL_STAGE_FETCH; dir = 1; break; } else if (urlMainSetupPanel(&ui, proto, &needsSecondary)) { return NULL; } /* got required information from user, proceed */ stage = (needsSecondary != ' ') ? URL_STAGE_SECOND : URL_STAGE_FETCH; dir = 1; break; case URL_STAGE_SECOND: rc = urlSecondarySetupPanel(&ui, proto); if (rc) { stage = URL_STAGE_MAIN; dir = -1; } else { stage = URL_STAGE_FETCH; dir = 1; } break; case URL_STAGE_FETCH: if (FL_TESTING(flags)) { stage = URL_STAGE_DONE; dir = 1; break; } #ifdef ROCKS /* * before we start the web server, make sure /tmp/rocks.conf * exists */ if (access("/tmp/rocks.conf", F_OK) != 0) { writeAvalancheInfo(NULL, NULL); } start_httpd(); #endif /* ROCKS */ /* ok messy - see if we have a stage2 on local CD */ /* before trying to pull one over network */ cdurl = findAnacondaCD(location, modInfo, modLoaded, *modDeps, 0); if (cdurl) { logMessage(INFO, "Detected stage 2 image on CD"); winStatus(50, 3, _("Media Detected"), _("Local installation media detected..."), 0); sleep(3); newtPopWindow(); stage = URL_STAGE_DONE; dir = 1; } else { /* need to find stage 2 on remote site */ if (loadUrlImages(&ui)) { stage = URL_STAGE_MAIN; dir = -1; if (loaderData->method >= 0) { loaderData->method = -1; } } else { stage = URL_STAGE_DONE; dir = 1; } } break; case URL_STAGE_DONE: break; } } login = ""; login = getLoginName(login, ui); if (!strcmp(ui.prefix, "/")) finalPrefix = "/."; else finalPrefix = ui.prefix; url = malloc(strlen(finalPrefix) + 25 + strlen(ui.address) + strlen(login)); /* sanitize url so we dont have problems like bug #101265 */ /* basically avoid duplicate /'s */ if (ui.protocol == URL_METHOD_HTTP) { for (p=finalPrefix; *p == '/'; p++); finalPrefix = p; } sprintf(url, "%s://%s%s/%s", ui.protocol == URL_METHOD_FTP ? "ftp" : "http", login, ui.address, finalPrefix); return url; }