2011-12-03 15:16:57 +05:30
|
|
|
/*-
|
2012-01-19 16:56:40 +05:30
|
|
|
* Copyright (c) 2011-2012 Juan Romero Pardines.
|
2011-12-03 15:16:57 +05:30
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <strings.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "../xbps-bin/defs.h"
|
|
|
|
|
2012-08-01 11:55:15 +05:30
|
|
|
static int
|
|
|
|
repo_longest_pkgver(struct xbps_handle *xhp,
|
|
|
|
struct xbps_rpool_index *rpi,
|
|
|
|
void *arg,
|
|
|
|
bool *done)
|
|
|
|
{
|
|
|
|
size_t *len = arg, olen = 0;
|
|
|
|
|
|
|
|
(void)done;
|
|
|
|
|
|
|
|
if (*len == 0) {
|
|
|
|
*len = find_longest_pkgver(xhp, rpi->repo);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
olen = find_longest_pkgver(xhp, rpi->repo);
|
|
|
|
if (olen > *len)
|
|
|
|
*len = olen;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
repo_find_longest_pkgver(struct xbps_handle *xhp)
|
|
|
|
{
|
|
|
|
size_t len = 0;
|
|
|
|
|
|
|
|
xbps_rpool_foreach(xhp, repo_longest_pkgver, &len);
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2011-12-03 15:16:57 +05:30
|
|
|
int
|
2012-06-14 11:52:11 +05:30
|
|
|
repo_pkg_list_cb(struct xbps_handle *xhp,
|
|
|
|
struct xbps_rpool_index *rpi,
|
|
|
|
void *arg,
|
|
|
|
bool *done)
|
2011-12-03 15:16:57 +05:30
|
|
|
{
|
|
|
|
struct list_pkgver_cb lpc;
|
2012-08-01 11:55:15 +05:30
|
|
|
struct repo_search_data *rsd = arg;
|
2011-12-03 15:16:57 +05:30
|
|
|
|
|
|
|
(void)done;
|
2012-08-01 11:55:15 +05:30
|
|
|
if (rsd->arg && strcmp(rpi->uri, rsd->arg))
|
2012-06-01 18:32:06 +05:30
|
|
|
return 0;
|
|
|
|
|
2011-12-03 15:16:57 +05:30
|
|
|
lpc.check_state = false;
|
|
|
|
lpc.state = 0;
|
2012-08-01 11:55:15 +05:30
|
|
|
lpc.pkgver_len = rsd->pkgver_len;
|
|
|
|
lpc.maxcols = rsd->maxcols;
|
2012-05-29 19:47:48 +05:30
|
|
|
|
2012-06-14 11:52:11 +05:30
|
|
|
(void)xbps_callback_array_iter(xhp, rpi->repo, list_pkgs_in_dict, &lpc);
|
2012-07-31 21:20:50 +05:30
|
|
|
|
2011-12-03 15:16:57 +05:30
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-14 11:52:11 +05:30
|
|
|
repo_list_uri_cb(struct xbps_handle *xhp,
|
|
|
|
struct xbps_rpool_index *rpi,
|
|
|
|
void *arg,
|
|
|
|
bool *done)
|
2011-12-03 15:16:57 +05:30
|
|
|
{
|
2012-06-14 11:52:11 +05:30
|
|
|
(void)xhp;
|
2011-12-03 15:16:57 +05:30
|
|
|
(void)arg;
|
|
|
|
(void)done;
|
|
|
|
|
2012-06-01 18:32:06 +05:30
|
|
|
printf("%s (%zu packages)\n", rpi->uri,
|
|
|
|
(size_t)prop_array_count(rpi->repo));
|
2011-12-03 15:16:57 +05:30
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-14 11:52:11 +05:30
|
|
|
repo_search_pkgs_cb(struct xbps_handle *xhp,
|
|
|
|
struct xbps_rpool_index *rpi,
|
|
|
|
void *arg,
|
|
|
|
bool *done)
|
2011-12-03 15:16:57 +05:30
|
|
|
{
|
2011-12-22 14:03:54 +05:30
|
|
|
struct repo_search_data *rsd = arg;
|
2011-12-03 15:16:57 +05:30
|
|
|
(void)done;
|
|
|
|
|
2012-06-14 11:52:11 +05:30
|
|
|
(void)xbps_callback_array_iter(xhp, rpi->repo, show_pkg_namedesc, rsd);
|
2012-07-31 21:20:50 +05:30
|
|
|
|
2011-12-03 15:16:57 +05:30
|
|
|
return 0;
|
|
|
|
}
|