Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor work #540

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions bin/xbps-alternatives/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

#include <xbps.h>

#include "macro.h"

static void __attribute__((noreturn))
usage(bool fail)
{
Expand Down Expand Up @@ -228,9 +230,9 @@ main(int argc, char **argv)
memset(&xh, 0, sizeof(xh));
xh.state_cb = state_cb;
if (rootdir)
xbps_strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
if (confdir)
xbps_strlcpy(xh.confdir, confdir, sizeof(xh.confdir));
strlcpy(xh.confdir, confdir, sizeof(xh.confdir));

xh.flags = flags;

Expand Down
25 changes: 14 additions & 11 deletions bin/xbps-checkvers/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,24 @@
*
*/

#include <sys/stat.h>

#include <assert.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <getopt.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <dirent.h>
#include <limits.h>
#include <sys/stat.h>
#include <assert.h>

#include <xbps.h>

#include "macro.h"

#define GOT_PKGNAME_VAR 0x1
#define GOT_VERSION_VAR 0x2
#define GOT_REVISION_VAR 0x4
Expand Down Expand Up @@ -110,10 +113,10 @@ rcv_init(rcv_t *rcv, const char *prog)
assert(rcv->cache);

if (rcv->xbps_conf != NULL) {
xbps_strlcpy(rcv->xhp.confdir, rcv->xbps_conf, sizeof(rcv->xhp.confdir));
strlcpy(rcv->xhp.confdir, rcv->xbps_conf, sizeof(rcv->xhp.confdir));
}
if (rcv->rootdir != NULL) {
xbps_strlcpy(rcv->xhp.rootdir, rcv->rootdir, sizeof(rcv->xhp.rootdir));
strlcpy(rcv->xhp.rootdir, rcv->rootdir, sizeof(rcv->xhp.rootdir));
}
if (xbps_init(&rcv->xhp) != 0)
abort();
Expand Down Expand Up @@ -817,8 +820,8 @@ main(int argc, char **argv)
if ((p = strrchr(argv[i], '/')) && (strcmp(p, "/template")) == 0) {
tmpl = argv[i];
} else {
xbps_strlcat(tmp, argv[i], sizeof tmp);
xbps_strlcat(tmp, "/template", sizeof tmp);
strlcat(tmp, argv[i], sizeof tmp);
strlcat(tmp, "/template", sizeof tmp);
tmpl = tmp;
}
rcv_process_file(&rcv, tmpl, rcv_check_version);
Expand Down
27 changes: 15 additions & 12 deletions bin/xbps-create/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,30 @@
* (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 <sys/types.h>
#include <sys/mman.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <stdio.h>
#include <sys/types.h>

#include <assert.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <ftw.h>
#include <getopt.h>
#include <libgen.h>
#include <locale.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <stdarg.h>
#include <errno.h>
#include <assert.h>
#include <unistd.h>
#include <getopt.h>
#include <ftw.h>
#include <fcntl.h>
#include <libgen.h>
#include <locale.h>
#include <dirent.h>

#include <xbps.h>

#include "macro.h"
#include "queue.h"

#ifdef __clang__
Expand Down
4 changes: 2 additions & 2 deletions bin/xbps-dgraph/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,9 +598,9 @@ main(int argc, char **argv)
/* Initialize libxbps */
memset(&xh, 0, sizeof(xh));
if (rootdir != NULL)
xbps_strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
if (confdir)
xbps_strlcpy(xh.confdir, confdir, sizeof(xh.confdir));
strlcpy(xh.confdir, confdir, sizeof(xh.confdir));

xh.flags = flags;
if ((rv = xbps_init(&xh)) != 0)
Expand Down
26 changes: 14 additions & 12 deletions bin/xbps-fbulk/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,26 @@
* Only one attempt is made to build any given package, no matter how many
* other packages depend on it.
*/
#define _DEFAULT_SOURCE
#define _BSD_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <dirent.h>
#include <assert.h>
#include <libgen.h>
#include <limits.h>
#include <errno.h>
#include <fcntl.h>

#include <sys/file.h>
#include <sys/stat.h>
#include <sys/wait.h>

#include <assert.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <libgen.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include <xbps.h>

#include "macro.h"
#include "uthash.h"

#ifndef __arraycount
Expand Down
8 changes: 5 additions & 3 deletions bin/xbps-install/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
#include <getopt.h>

#include <xbps.h>

#include "defs.h"
#include "macro.h"

static void __attribute__((noreturn))
usage(bool fail)
Expand Down Expand Up @@ -214,11 +216,11 @@ main(int argc, char **argv)
xh.fetch_cb = fetch_file_progress_cb;
xh.fetch_cb_data = &xfer;
if (rootdir)
xbps_strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
if (cachedir)
xbps_strlcpy(xh.cachedir, cachedir, sizeof(xh.cachedir));
strlcpy(xh.cachedir, cachedir, sizeof(xh.cachedir));
if (confdir)
xbps_strlcpy(xh.confdir, confdir, sizeof(xh.confdir));
strlcpy(xh.confdir, confdir, sizeof(xh.confdir));
xh.flags = flags;
if (flags & XBPS_FLAG_VERBOSE)
xh.unpack_cb = unpack_progress_cb;
Expand Down
7 changes: 5 additions & 2 deletions bin/xbps-install/state_cb.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <syslog.h>
#include <assert.h>

#include <xbps.h>

#include "defs.h"
#include "macro.h"

int
state_cb(const struct xbps_state_cb_data *xscd, void *cbdata UNUSED)
Expand Down
1 change: 1 addition & 0 deletions bin/xbps-install/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ exec_transaction(struct xbps_handle *xhp, unsigned int maxcols, bool yes, bool d
trans->d = xhp->transd;
trans->iter = xbps_array_iter_from_dict(xhp->transd, "packages");
assert(trans->iter);
/* XXX: assert with side effect */

/*
* dry-run mode, show what would be done but don't run anything.
Expand Down
9 changes: 6 additions & 3 deletions bin/xbps-pkgdb/check.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,19 @@
*/

#include <sys/param.h>
#include <stdio.h>

#include <assert.h>
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <assert.h>

#include <xbps.h>

#include "defs.h"
#include "macro.h"

static int
pkgdb_cb(struct xbps_handle *xhp UNUSED,
Expand Down
9 changes: 2 additions & 7 deletions bin/xbps-pkgdb/check_pkg_unneeded.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,12 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <unistd.h>
#include <sys/param.h>

#include <xbps.h>

#include "defs.h"
#include "macro.h"

/*
* Checks package integrity of an installed package.
Expand Down
11 changes: 6 additions & 5 deletions bin/xbps-pkgdb/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <stdio.h>
#include <errno.h>
#include <getopt.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
#include <errno.h>

#include <xbps.h>

#include "defs.h"

static void __attribute__((noreturn))
Expand Down Expand Up @@ -143,9 +144,9 @@ main(int argc, char **argv)

memset(&xh, 0, sizeof(xh));
if (rootdir)
xbps_strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
if (confdir)
xbps_strlcpy(xh.confdir, confdir, sizeof(xh.confdir));
strlcpy(xh.confdir, confdir, sizeof(xh.confdir));
xh.flags = flags;

if ((rv = xbps_init(&xh)) != 0) {
Expand Down
10 changes: 7 additions & 3 deletions bin/xbps-query/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,18 @@
*/

#include <sys/types.h>
#include <stdio.h>

#include <assert.h>
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <assert.h>

#include <xbps.h>

#include "defs.h"
#include "macro.h"

struct list_pkgver_cb {
unsigned int pkgver_len;
Expand Down
11 changes: 6 additions & 5 deletions bin/xbps-query/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <errno.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <errno.h>

#include <xbps.h>

#include "defs.h"

static void __attribute__((noreturn))
Expand Down Expand Up @@ -240,11 +241,11 @@ main(int argc, char **argv)
* Initialize libxbps.
*/
if (rootdir)
xbps_strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
if (cachedir)
xbps_strlcpy(xh.cachedir, cachedir, sizeof(xh.cachedir));
strlcpy(xh.cachedir, cachedir, sizeof(xh.cachedir));
if (confdir)
xbps_strlcpy(xh.confdir, confdir, sizeof(xh.confdir));
strlcpy(xh.confdir, confdir, sizeof(xh.confdir));

xh.flags = flags;

Expand Down
14 changes: 8 additions & 6 deletions bin/xbps-query/ownedby.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,20 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <dirent.h>
#include <errno.h>
#include <fnmatch.h>
#include <dirent.h>
#include <assert.h>
#include <regex.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <xbps.h>

#include "defs.h"
#include "macro.h"

struct ffdata {
bool rematch;
Expand Down
Loading