From f159203f6fb217bb7bed5ffea8c2518325a9ec12 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 22 Jan 2008 22:49:45 -0600 Subject: Remove pmserver_t abstraction Remove what was a pretty weird abstraction in the libalpm backend. Instead of parsing server URLs as we get them (of which we don't usually use more than a handful anyway), wait until they are actually used, which allows us to store them as a simple string list instead. This allows us to remove a lot of code, and will greatly simplify the continuing refactoring of the download code. Signed-off-by: Dan McGee --- lib/libalpm/server.c | 89 ---------------------------------------------------- 1 file changed, 89 deletions(-) delete mode 100644 lib/libalpm/server.c (limited to 'lib/libalpm/server.c') diff --git a/lib/libalpm/server.c b/lib/libalpm/server.c deleted file mode 100644 index d15f96a3..00000000 --- a/lib/libalpm/server.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * server.c - * - * Copyright (c) 2006 by Miklos Vajna - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* libalpm */ -#include "server.h" -#include "alpm_list.h" -#include "error.h" -#include "log.h" -#include "alpm.h" -#include "util.h" -#include "handle.h" -#include "package.h" - -pmserver_t *_alpm_server_new(const char *url) -{ - struct url *u; - pmserver_t *server; - - ALPM_LOG_FUNC; - - CALLOC(server, 1, sizeof(pmserver_t), RET_ERR(PM_ERR_MEMORY, NULL)); - - u = downloadParseURL(url); - if(!u) { - _alpm_log(PM_LOG_ERROR, _("url '%s' is invalid, ignoring\n"), url); - RET_ERR(PM_ERR_SERVER_BAD_URL, NULL); - } - if(strlen(u->scheme) == 0) { - _alpm_log(PM_LOG_WARNING, _("url scheme not specified, assuming http\n")); - strcpy(u->scheme, "http"); - } - - if(strcmp(u->scheme,"ftp") == 0 && strlen(u->user) == 0) { - strcpy(u->user, "anonymous"); - strcpy(u->pwd, "libalpm@guest"); - } - - /* remove trailing slashes, just to clean up the rest of the code */ - for(int i = strlen(u->doc) - 1; u->doc[i] == '/'; --i) - u->doc[i] = '\0'; - - server->s_url = u; - - return server; -} - -void _alpm_server_free(pmserver_t *server) -{ - ALPM_LOG_FUNC; - - if(server == NULL) { - return; - } - - /* free memory */ - downloadFreeURL(server->s_url); - FREE(server); -} - -/* vim: set ts=2 sw=2 noet: */ -- cgit v1.2.3-24-g4f1b