main: implement --define-variable
parent
97afd424b1
commit
7ae5ccd177
5
main.c
5
main.c
|
@ -452,6 +452,7 @@ usage(void)
|
||||||
|
|
||||||
printf("\nquerying specific pkg-config database fields:\n\n");
|
printf("\nquerying specific pkg-config database fields:\n\n");
|
||||||
|
|
||||||
|
printf(" --define-variable=varname=value define variable 'varname' as 'value'\n");
|
||||||
printf(" --variable=varname print specified variable entry to stdout\n");
|
printf(" --variable=varname print specified variable entry to stdout\n");
|
||||||
printf(" --cflags print required CFLAGS to stdout\n");
|
printf(" --cflags print required CFLAGS to stdout\n");
|
||||||
printf(" --cflags-only-I print required include-dir CFLAGS to stdout\n");
|
printf(" --cflags-only-I print required include-dir CFLAGS to stdout\n");
|
||||||
|
@ -506,6 +507,7 @@ main(int argc, char *argv[])
|
||||||
{ "no-uninstalled", no_argument, &want_no_uninstalled, 25, },
|
{ "no-uninstalled", no_argument, &want_no_uninstalled, 25, },
|
||||||
{ "keep-system-cflags", no_argument, &want_keep_system_cflags, 26, },
|
{ "keep-system-cflags", no_argument, &want_keep_system_cflags, 26, },
|
||||||
{ "keep-system-libs", no_argument, &want_keep_system_libs, 26, },
|
{ "keep-system-libs", no_argument, &want_keep_system_libs, 26, },
|
||||||
|
{ "define-variable", required_argument, NULL, 27, },
|
||||||
{ NULL, 0, NULL, 0 }
|
{ NULL, 0, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -525,6 +527,9 @@ main(int argc, char *argv[])
|
||||||
case 11:
|
case 11:
|
||||||
maximum_traverse_depth = atoi(optarg);
|
maximum_traverse_depth = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 27:
|
||||||
|
pkg_tuple_define_global(optarg);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
1
pkg.h
1
pkg.h
|
@ -169,5 +169,6 @@ void pkg_tuple_free(pkg_tuple_t *head);
|
||||||
void pkg_tuple_add_global(const char *key, const char *value);
|
void pkg_tuple_add_global(const char *key, const char *value);
|
||||||
char *pkg_tuple_find_global(const char *key);
|
char *pkg_tuple_find_global(const char *key);
|
||||||
void pkg_tuple_free_global(void);
|
void pkg_tuple_free_global(void);
|
||||||
|
void pkg_tuple_define_global(const char *kv);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
16
tuple.c
16
tuple.c
|
@ -52,6 +52,22 @@ pkg_tuple_free_global(void)
|
||||||
pkg_tuple_free(pkg_global_var);
|
pkg_tuple_free(pkg_global_var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pkg_tuple_define_global(const char *kv)
|
||||||
|
{
|
||||||
|
char *workbuf = strdup(kv);
|
||||||
|
char *value;
|
||||||
|
|
||||||
|
value = strchr(workbuf, '=');
|
||||||
|
if (value == NULL)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
*value++ = '\0';
|
||||||
|
pkg_tuple_add_global(workbuf, value);
|
||||||
|
out:
|
||||||
|
free(workbuf);
|
||||||
|
}
|
||||||
|
|
||||||
pkg_tuple_t *
|
pkg_tuple_t *
|
||||||
pkg_tuple_add(pkg_tuple_t *parent, const char *key, const char *value)
|
pkg_tuple_add(pkg_tuple_t *parent, const char *key, const char *value)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue