queue: new file

pull/36/head
William Pitcock 2012-07-29 03:49:56 -05:00
parent 91271e56c6
commit 698358e9d4
4 changed files with 39 additions and 19 deletions

View File

@ -11,7 +11,7 @@ pkgconfigdir = @PKGCONFIGDIR@
CC = @CC@
PROG = pkgconf@EXEEXT@
SRCS = main.c pkg.c bsdstubs.c getopt_long.c fragment.c argvsplit.c fileio.c tuple.c dependency.c
SRCS = main.c pkg.c bsdstubs.c getopt_long.c fragment.c argvsplit.c fileio.c tuple.c dependency.c queue.c
OBJS = ${SRCS:.c=.o}
CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@

18
main.c
View File

@ -223,24 +223,6 @@ check_uninstalled(pkg_t *pkg, void *data, unsigned int flags)
*retval = EXIT_SUCCESS;
}
typedef struct pkg_queue_ {
struct pkg_queue_ *prev, *next;
char *package;
} pkg_queue_t;
static pkg_queue_t *
pkg_queue_push(pkg_queue_t *parent, const char *package)
{
pkg_queue_t *pkgq = calloc(sizeof(pkg_queue_t), 1);
pkgq->package = strdup(package);
pkgq->prev = parent;
if (pkgq->prev != NULL)
pkgq->prev->next = pkgq;
return pkgq;
}
int
pkg_queue_walk(pkg_queue_t *head)
{

8
pkg.h
View File

@ -72,6 +72,11 @@ struct pkg_tuple_ {
char *value;
};
typedef struct pkg_queue_ {
struct pkg_queue_ *prev, *next;
char *package;
} pkg_queue_t;
#define PKG_PROPF_NONE 0x0
#define PKG_PROPF_VIRTUAL 0x1
@ -166,4 +171,7 @@ void pkg_tuple_define_global(const char *kv);
/* main.c */
extern FILE *error_msgout;
/* queue.c */
pkg_queue_t *pkg_queue_push(pkg_queue_t *parent, const char *package);
#endif

30
queue.c Normal file
View File

@ -0,0 +1,30 @@
/*
* queue.c
* compilation of a list of packages into a world dependency set
*
* Copyright (c) 2012 pkgconf authors (see AUTHORS).
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* This software is provided 'as is' and without any warranty, express or
* implied. In no event shall the authors be liable for any damages arising
* from the use of this software.
*/
#include "pkg.h"
#include "bsdstubs.h"
pkg_queue_t *
pkg_queue_push(pkg_queue_t *parent, const char *package)
{
pkg_queue_t *pkgq = calloc(sizeof(pkg_queue_t), 1);
pkgq->package = strdup(package);
pkgq->prev = parent;
if (pkgq->prev != NULL)
pkgq->prev->next = pkgq;
return pkgq;
}