pkg_deps.h
1 /*- 2 * Copyright (c) 2015, Vsevolod Stakhov 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * * Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * * Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY AUTHOR ''AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 * DISCLAIMED. IN NO EVENT SHALL AUTHOR BE LIABLE FOR ANY 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 */ 24 25 26 #ifndef LIBPKG_PRIVATE_PKG_DEPS_H_ 27 #define LIBPKG_PRIVATE_PKG_DEPS_H_ 28 29 #include <stdbool.h> 30 31 enum pkg_dep_version_op { 32 VERSION_ANY = 0, 33 VERSION_EQ, 34 VERSION_GE, 35 VERSION_LE, 36 VERSION_LT, 37 VERSION_GT, 38 VERSION_NOT, 39 }; 40 41 enum pkg_dep_flag { 42 PKG_DEP_FLAG_NORMAL = 0, 43 PKG_DEP_FLAG_REQUIRE = (1 << 0), 44 PKG_DEP_FLAG_GLOB = (1 << 1), 45 PKG_DEP_FLAG_REGEXP = (1 << 2) 46 }; 47 48 struct pkg_dep_version_item { 49 char *ver; 50 enum pkg_dep_version_op op; 51 struct pkg_dep_version_item *prev, *next; 52 }; 53 54 struct pkg_dep_option_item { 55 char *opt; 56 bool on; 57 struct pkg_dep_option_item *prev, *next; 58 }; 59 60 struct pkg_dep_formula_item { 61 char *name; 62 unsigned flags; 63 struct pkg_dep_version_item *versions; 64 struct pkg_dep_option_item *options; 65 66 struct pkg_dep_formula_item *prev, *next; 67 }; 68 69 struct pkg_dep_formula { 70 struct pkg_dep_formula_item *items; 71 struct pkg_dep_formula *prev, *next; 72 }; 73 74 75 /* 76 * Convert pkg formula string to the pkg_dep_formula linked list 77 */ 78 struct pkg_dep_formula* pkg_deps_parse_formula(const char *in); 79 80 void pkg_deps_formula_free(struct pkg_dep_formula *f); 81 82 char* pkg_deps_formula_tostring(struct pkg_dep_formula *f); 83 84 enum pkg_dep_version_op pkg_deps_string_toop(const char *in); 85 86 char* pkg_deps_formula_tosql(struct pkg_dep_formula_item *f); 87 88 #endif /* LIBPKG_PRIVATE_PKG_DEPS_H_ */