Remove unused callbacks, a legacy of the now removed ipkg API.
[project/opkg-lede.git] / libopkg / libopkg.c
1 /* opkglib.c - the opkg package management system
2
3 Florina Boor
4
5 Copyright (C) 2003 kernel concepts
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 "includes.h"
19 #include "libopkg.h"
20
21 #include "args.h"
22 #include "opkg_conf.h"
23 #include "opkg_cmd.h"
24 #include "file_util.h"
25
26 #include "opkg_message.h"
27 #include "opkg_error.h"
28
29 /* This is used for backward compatibility */
30 int
31 opkg_op (int argc, char *argv[])
32 {
33 int err, optind;
34 args_t args;
35 char *cmd_name;
36 opkg_cmd_t *cmd;
37 opkg_conf_t opkg_conf;
38
39 args_init (&args);
40
41 optind = args_parse (&args, argc, argv);
42 if (optind == argc || optind < 0)
43 {
44 args_usage ("opkg must have one sub-command argument");
45 }
46
47 cmd_name = argv[optind++];
48 /* Pigi: added a flag to disable the checking of structures if the command does not need to
49 read anything from there.
50 */
51 if ( !strcmp(cmd_name,"print-architecture") ||
52 !strcmp(cmd_name,"print_architecture") ||
53 !strcmp(cmd_name,"print-installation-architecture") ||
54 !strcmp(cmd_name,"print_installation_architecture") )
55 args.nocheckfordirorfile = 1;
56
57 /* Pigi: added a flag to disable the reading of feed files if the command does not need to
58 read anything from there.
59 */
60 if ( !strcmp(cmd_name,"flag") ||
61 !strcmp(cmd_name,"configure") ||
62 !strcmp(cmd_name,"remove") ||
63 !strcmp(cmd_name,"files") ||
64 !strcmp(cmd_name,"search") ||
65 !strcmp(cmd_name,"compare_versions") ||
66 !strcmp(cmd_name,"compare-versions") ||
67 !strcmp(cmd_name,"list_installed") ||
68 !strcmp(cmd_name,"list-installed") ||
69 !strcmp(cmd_name,"status") )
70 args.noreadfeedsfile = 1;
71
72
73 err = opkg_conf_init (&opkg_conf, &args);
74 args_deinit (&args);
75 if (err)
76 {
77 print_error_list();
78 free_error_list();
79 return err;
80 }
81
82 cmd = opkg_cmd_find (cmd_name);
83 if (cmd == NULL)
84 {
85 fprintf (stderr, "%s: unknown sub-command %s\n", argv[0],
86 cmd_name);
87 args_usage (NULL);
88 }
89
90 if (cmd->requires_args && optind == argc)
91 {
92 fprintf (stderr,
93 "%s: the ``%s'' command requires at least one argument\n",
94 __FUNCTION__, cmd_name);
95 args_usage (NULL);
96 }
97
98 err = opkg_cmd_exec (cmd, &opkg_conf, argc - optind, (const char **) (argv + optind), NULL);
99
100 opkg_conf_deinit (&opkg_conf);
101
102 return err;
103 }