• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/opkg-lede/tests/opkg_hash_test.c

  1 /* opkg_hash_test.c - the itsy package management system
  2 
  3    Carl D. Worth
  4 
  5    Copyright (C) 2001 University of Southern California
  6 
  7    This program is free software; you can redistribute it and/or
  8    modify it under the terms of the GNU General Public License as
  9    published by the Free Software Foundation; either version 2, or (at
 10    your option) any later version.
 11 
 12    This program is distributed in the hope that it will be useful, but
 13    WITHOUT ANY WARRANTY; without even the implied warranty of
 14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 15    General Public License for more details.
 16 */
 17 
 18 #include <libopkg/opkg.h>
 19 
 20 #include <libopkg/hash_table.h>
 21 #include <libopkg/opkg_utils.h>
 22 #include <libopkg/pkg_hash.h>
 23 
 24 int main(int argc, char *argv[])
 25 {
 26         opkg_conf_t conf;
 27         hash_table_t *hash = &conf.pkg_hash;
 28         pkg_vec_t *pkg_vec;
 29 
 30         if (argc < 3) {
 31                 fprintf(stderr,
 32                         "Usage: %s <pkgs_file1> <pkgs_file2> [pkg_name...]\n",
 33                         argv[0]);
 34                 exit(1);
 35         }
 36         pkg_hash_init("test", hash, 1024);
 37 
 38         pkg_hash_add_from_file(&conf, argv[1], NULL, NULL, 0, NULL, NULL);
 39         pkg_hash_add_from_file(&conf, argv[2], NULL, NULL, 0, NULL, NULL);
 40 
 41         if (argc < 4) {
 42                 pkg_print_info(pkg_hash_fetch_by_name_version
 43                                (hash, "libc6", "2.2.3-2"), stdout);
 44                 /*      for(i = 0; i < pkg_vec->len; i++)
 45                    pkg_print(pkg_vec->pkgs[i], stdout);
 46                  */
 47         } else {
 48                 int i, j, k;
 49                 char **unresolved;
 50 
 51                 pkg_vec_t *dep_vec;
 52                 for (i = 3; i < argc; i++) {
 53                         pkg_vec = pkg_vec_fetch_by_name(hash, argv[i]);
 54                         if (pkg_vec == NULL) {
 55                                 fprintf(stderr,
 56                                         "*** WARNING: Unknown package: %s\n\n",
 57                                         argv[i]);
 58                                 continue;
 59                         }
 60 
 61                         for (j = 0; j < pkg_vec->len; j++) {
 62                                 pkg_print_info(pkg_vec->pkgs[j], stdout);
 63                                 dep_vec = pkg_vec_alloc();
 64                                 pkg_hash_fetch_unsatisfied_dependencies(&conf,
 65                                                                         pkg_vec->
 66                                                                         pkgs[j],
 67                                                                         dep_vec,
 68                                                                         &unresolved);
 69                                 if (dep_vec) {
 70                                         fprintf(stderr,
 71                                                 "and the unsatisfied dependencies are:\n");
 72                                         for (k = 0; k < dep_vec->len; k++) {
 73                                                 fprintf(stderr,
 74                                                         "%s version %s\n",
 75                                                         dep_vec->pkgs[k]->name,
 76                                                         dep_vec->pkgs[k]->
 77                                                         version);
 78                                         }
 79                                 }
 80 
 81                                 fputs("", stdout);
 82 
 83                         }
 84                 }
 85         }
 86 
 87         pkg_hash_deinit(hash);
 88 
 89         return 0;
 90 }
 91 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt