summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/Makefile.am1
-rw-r--r--lib/libalpm/alpm.h1
-rw-r--r--lib/libalpm/db.c27
-rw-r--r--lib/libalpm/dload.c91
-rw-r--r--lib/libalpm/handle.c1
-rw-r--r--lib/libalpm/po/POTFILES.in2
-rw-r--r--lib/libalpm/server.c89
-rw-r--r--lib/libalpm/server.h39
-rw-r--r--lib/libalpm/sync.c1
9 files changed, 38 insertions, 214 deletions
diff --git a/lib/libalpm/Makefile.am b/lib/libalpm/Makefile.am
index 15e27bc4..b1d38ad4 100644
--- a/lib/libalpm/Makefile.am
+++ b/lib/libalpm/Makefile.am
@@ -36,7 +36,6 @@ libalpm_la_SOURCES = \
md5.h md5.c \
package.h package.c \
remove.h remove.c \
- server.h server.c \
sync.h sync.c \
trans.h trans.c \
util.h util.c
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index a6807191..d605004f 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -45,7 +45,6 @@ typedef struct __pmdb_t pmdb_t;
typedef struct __pmpkg_t pmpkg_t;
typedef struct __pmdelta_t pmdelta_t;
typedef struct __pmgrp_t pmgrp_t;
-typedef struct __pmserver_t pmserver_t;
typedef struct __pmtrans_t pmtrans_t;
typedef struct __pmsyncpkg_t pmsyncpkg_t;
typedef struct __pmdepend_t pmdepend_t;
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index 9dce4aff..e82592a7 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -41,7 +41,6 @@
#include "log.h"
#include "util.h"
#include "error.h"
-#include "server.h"
#include "dload.h"
#include "handle.h"
#include "cache.h"
@@ -192,14 +191,9 @@ int SYMEXPORT alpm_db_setserver(pmdb_t *db, const char *url)
}
if(url && strlen(url)) {
- pmserver_t *server;
- if((server = _alpm_server_new(url)) == NULL) {
- /* pm_errno is set by _alpm_server_new */
- return(-1);
- }
- db->servers = alpm_list_add(db->servers, server);
- _alpm_log(PM_LOG_DEBUG, "adding new server to database '%s': protocol '%s', server '%s', path '%s'\n",
- db->treename, server->s_url->scheme, server->s_url->host, server->s_url->doc);
+ db->servers = alpm_list_add(db->servers, strdup(url));
+ _alpm_log(PM_LOG_DEBUG, "adding new server URL to database '%s': %s\n",
+ db->treename, url);
} else {
FREELIST(db->servers);
_alpm_log(PM_LOG_DEBUG, "serverlist flushed for '%s'\n", db->treename);
@@ -317,8 +311,7 @@ const char SYMEXPORT *alpm_db_get_name(const pmdb_t *db)
*/
const char SYMEXPORT *alpm_db_get_url(const pmdb_t *db)
{
- char path[PATH_MAX];
- pmserver_t *s;
+ char *url;
ALPM_LOG_FUNC;
@@ -326,10 +319,9 @@ const char SYMEXPORT *alpm_db_get_url(const pmdb_t *db)
ASSERT(handle != NULL, return(NULL));
ASSERT(db != NULL, return(NULL));
- s = (pmserver_t*)db->servers->data;
+ url = (char*)db->servers->data;
- snprintf(path, PATH_MAX, "%s://%s%s", s->s_url->scheme, s->s_url->host, s->s_url->doc);
- return strdup(path);
+ return(url);
}
@@ -451,17 +443,12 @@ pmdb_t *_alpm_db_new(const char *dbpath, const char *treename)
void _alpm_db_free(pmdb_t *db)
{
- alpm_list_t *tmp;
-
ALPM_LOG_FUNC;
/* cleanup pkgcache */
_alpm_db_free_pkgcache(db);
/* cleanup server list */
- for(tmp = db->servers; tmp; tmp = alpm_list_next(tmp)) {
- _alpm_server_free(tmp->data);
- }
- alpm_list_free(db->servers);
+ FREELIST(db->servers);
FREE(db->path);
FREE(db);
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index 313bbbcf..b9672e3a 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -34,48 +34,37 @@
#include "util.h"
#include "error.h"
#include "handle.h"
-#include "server.h"
-/* remove filename info from "s_url->doc" and return it */
-static char *strip_filename(pmserver_t *server)
+/* Return a 'struct url' for this server, for downloading 'filename'. */
+static struct url *url_for_file(const char *url, const char *filename)
{
- char *p = NULL, *fname = NULL;
- if(!server) {
- return(NULL);
+ struct url *ret = NULL;
+ char *buf = NULL;
+ int len;
+
+ /* print url + filename into a buffer */
+ len = strlen(url) + strlen(filename) + 2;
+ CALLOC(buf, len, sizeof(char), RET_ERR(PM_ERR_MEMORY, NULL));
+ snprintf(buf, len, "%s/%s", url, filename);
+
+ ret = downloadParseURL(buf);
+ FREE(buf);
+ if(!ret) {
+ _alpm_log(PM_LOG_ERROR, _("url '%s' is invalid\n"), buf);
+ RET_ERR(PM_ERR_SERVER_BAD_URL, NULL);
}
- p = strrchr(server->s_url->doc, '/');
- if(p && *(++p)) {
- fname = strdup(p);
- _alpm_log(PM_LOG_DEBUG, "stripping '%s' from '%s'\n",
- fname, server->s_url->doc);
- *p = 0;
+ /* if no URL scheme specified, assume HTTP */
+ if(strlen(ret->scheme) == 0) {
+ _alpm_log(PM_LOG_WARNING, _("url scheme not specified, assuming HTTP\n"));
+ strcpy(ret->scheme, SCHEME_HTTP);
+ }
+ /* add a user & password for anonymous FTP */
+ if(strcmp(ret->scheme,SCHEME_FTP) == 0 && strlen(ret->user) == 0) {
+ strcpy(ret->user, "anonymous");
+ strcpy(ret->pwd, "libalpm@guest");
}
- /* s_url->doc now contains ONLY path information. return value
- * if the file information from the original URL */
- return(fname);
-}
-
-
-/* Return a 'struct url' for this server, for downloading 'filename'. */
-static struct url *url_for_file(pmserver_t *server, const char *filename)
-{
- struct url *ret = NULL;
- char *doc = NULL;
- int doclen = 0;
-
- doclen = strlen(server->s_url->doc) + strlen(filename) + 2;
- CALLOC(doc, doclen, sizeof(char), RET_ERR(PM_ERR_MEMORY, NULL));
-
- snprintf(doc, doclen, "%s/%s", server->s_url->doc, filename);
- ret = downloadMakeURL(server->s_url->scheme,
- server->s_url->host,
- server->s_url->port,
- doc,
- server->s_url->user,
- server->s_url->pwd);
- FREE(doc);
return(ret);
}
@@ -150,7 +139,7 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath,
}
for(i = servers; i && !done; i = i->next) {
- pmserver_t *server = i->data;
+ const char *server = i->data;
/* get each file in the list */
for(lp = files; lp; lp = lp->next) {
@@ -393,43 +382,23 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath,
*/
char SYMEXPORT *alpm_fetch_pkgurl(const char *url)
{
- pmserver_t *server;
+ /* TODO this method will not work at all right now */
char *filename, *filepath;
const char *cachedir;
ALPM_LOG_FUNC;
- if(strstr(url, "://") == NULL) {
- _alpm_log(PM_LOG_DEBUG, "Invalid URL passed to alpm_fetch_pkgurl\n");
- return(NULL);
- }
-
- server = _alpm_server_new(url);
- if(!server) {
- return(NULL);
- }
-
- /* strip path information from the filename */
- filename = strip_filename(server);
- if(!filename) {
- _alpm_log(PM_LOG_ERROR, _("URL does not contain a file for download\n"));
- return(NULL);
- }
+ filename = NULL;
/* find a valid cache dir to download to */
cachedir = _alpm_filecache_setup();
- /* TODO this seems like needless complexity just to download one file */
- alpm_list_t *servers = alpm_list_add(NULL, server);
-
/* download the file */
- if(_alpm_download_single_file(filename, servers, cachedir, 0, NULL)) {
+ if(_alpm_download_single_file(NULL, NULL, cachedir, 0, NULL)) {
_alpm_log(PM_LOG_WARNING, _("failed to download %s\n"), url);
return(NULL);
}
- _alpm_log(PM_LOG_DEBUG, "successfully downloaded %s\n", filename);
- alpm_list_free(servers);
- _alpm_server_free(server);
+ _alpm_log(PM_LOG_DEBUG, "successfully downloaded %s\n", url);
/* we should be able to find the file the second time around */
filepath = _alpm_filecache_find(filename);
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index aaadd86d..899ac88c 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -39,7 +39,6 @@
#include "error.h"
#include "trans.h"
#include "alpm.h"
-#include "server.h"
/* global var for handle (private to libalpm) */
pmhandle_t *handle = NULL;
diff --git a/lib/libalpm/po/POTFILES.in b/lib/libalpm/po/POTFILES.in
index 80130f24..35bd864b 100644
--- a/lib/libalpm/po/POTFILES.in
+++ b/lib/libalpm/po/POTFILES.in
@@ -10,6 +10,7 @@ lib/libalpm/conflict.c
lib/libalpm/db.c
lib/libalpm/delta.c
lib/libalpm/deps.c
+lib/libalpm/dload.c
lib/libalpm/error.c
lib/libalpm/group.c
lib/libalpm/handle.c
@@ -17,7 +18,6 @@ lib/libalpm/log.c
lib/libalpm/md5.c
lib/libalpm/package.c
lib/libalpm/remove.c
-lib/libalpm/server.c
lib/libalpm/sync.c
lib/libalpm/trans.c
lib/libalpm/util.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 <vmiklos@frugalware.org>
- *
- * 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 <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-
-#include <stdlib.h>
-#include <errno.h>
-#include <time.h>
-#include <string.h>
-#include <limits.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <download.h>
-
-/* 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: */
diff --git a/lib/libalpm/server.h b/lib/libalpm/server.h
deleted file mode 100644
index b84b90b6..00000000
--- a/lib/libalpm/server.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * server.h
- *
- * Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
- *
- * 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 <http://www.gnu.org/licenses/>.
- */
-#ifndef _ALPM_SERVER_H
-#define _ALPM_SERVER_H
-
-#include "alpm_list.h"
-#include "alpm.h"
-
-#include <time.h>
-#include <download.h>
-
-/* Servers */
-struct __pmserver_t {
- /* useless abstraction now? */
- struct url *s_url;
-};
-
-pmserver_t *_alpm_server_new(const char *url);
-void _alpm_server_free(pmserver_t *server);
-
-#endif /* _ALPM_SERVER_H */
-
-/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 707bc8e3..f6097420 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -44,7 +44,6 @@
#include "util.h"
#include "handle.h"
#include "alpm.h"
-#include "server.h"
#include "dload.h"
#include "delta.h"