#include <ctype.h>
#include <getopt.h>
#include <stdio.h>
#include <string.h>
#include <locale.h>
#include <alpm.h>
#include <alpm_list.h>
#ifdef HAVE_LANGINFO_H
#include <langinfo.h>
#endif
#define LINE_MAX 512
typedef struct tdepth {
struct tdepth *prev;
struct tdepth *next;
int level;
} tdepth;
struct graph_style {
const char *provides;
const char *tip;
const char *last;
const char *limb;
int indent;
};
#define UTF_V "\342\224\202"
#define UTF_VR "\342\224\234"
#define UTF_H "\342\224\200"
#define UTF_UR "\342\224\224"
static struct graph_style graph_utf8 = {
" provides",
UTF_VR UTF_H,
UTF_UR UTF_H,
UTF_V " ",
2
};
static struct graph_style graph_default = {
" provides",
"|-",
"`-",
"|",
2
};
static struct graph_style graph_linear = {
"",
"",
"",
"",
0
};
struct color_choices {
const char *branch1;
const char *branch2;
const char *leaf1;
const char *leaf2;
const char *off;
};
static struct color_choices use_color = {
"\033[0;33m",
"\033[0;37m",
"\033[1;32m",
"\033[0;32m",
"\033[0m"
};
static struct color_choices no_color = {
"",
"",
"",
"",
""
};
enum {
OP_CONFIG = 1000
};
alpm_handle_t *handle = NULL;
alpm_list_t *walked = NULL;
alpm_list_t *provisions = NULL;
struct color_choices *color = &no_color;
struct graph_style *style = &graph_utf8;
int graphviz = 0;
int max_depth = -1;
int reverse = 0;
int unique = 0;
int searchsyncs = 0;
const char *dbpath = DBPATH;
const char *configfile = CONFFILE;
#ifndef HAVE_STRNDUP
static size_t strnlen(const char *s, size_t max)
{
register const char *p;
for(p = s; *p && max--; ++p);
return (p - s);
}
char *strndup(const char *s, size_t n)
{
size_t len = strnlen(s, n);
char *new = (char *) malloc(len + 1);
if(new == NULL)
return NULL;
new[len] = '\0';
return (char *)memcpy(new, s, len);
}
#endif
static size_t strtrim(char *str)
{
char *end, *pch = str;
if(str == NULL || *str == '\0') {
return 0;
}
while(isspace((unsigned char)*pch)) {
pch++;
}
if(pch != str) {
size_t len = strlen(pch);
if(len) {
memmove(str, pch, len + 1);
} else {
*str = '\0';
}
}
|