-char *pkg_state_want_to_str(pkg_state_want_t sw)
-{
- int i;
-
- for (i=0; i < ARRAY_SIZE(pkg_state_want_map); i++) {
- if (pkg_state_want_map[i].value == sw) {
- return xstrdup(pkg_state_want_map[i].str);
- }
- }
-
- fprintf(stderr, "%s: ERROR: Illegal value for state_want: %d\n",
- __FUNCTION__, sw);
- return xstrdup("<STATE_WANT_UNKNOWN>");
-}
-
-pkg_state_want_t pkg_state_want_from_str(char *str)
-{
- int i;
-
- for (i=0; i < ARRAY_SIZE(pkg_state_want_map); i++) {
- if (strcmp(str, pkg_state_want_map[i].str) == 0) {
- return pkg_state_want_map[i].value;
- }
- }
-
- fprintf(stderr, "%s: ERROR: Illegal value for state_want string: %s\n",
- __FUNCTION__, str);
- return SW_UNKNOWN;
-}
-
-char *pkg_state_flag_to_str(pkg_state_flag_t sf)
-{
- int i;
- int len = 3; /* ok\000 is minimum */
- char *str = NULL;
-
- /* clear the temporary flags before converting to string */
- sf &= SF_NONVOLATILE_FLAGS;
-
- if (sf == 0) {
- return xstrdup("ok");
- } else {
-
- for (i=0; i < ARRAY_SIZE(pkg_state_flag_map); i++) {
- if (sf & pkg_state_flag_map[i].value) {
- len += strlen(pkg_state_flag_map[i].str) + 1;
- }
- }
- str = xmalloc(len);
- str[0] = 0;
- for (i=0; i < ARRAY_SIZE(pkg_state_flag_map); i++) {
- if (sf & pkg_state_flag_map[i].value) {
- strcat(str, pkg_state_flag_map[i].str);
- strcat(str, ",");
- }
- }
- len = strlen(str);
- str[len-1] = 0; /* squash last comma */
- return str;
- }
-}
-
-pkg_state_flag_t pkg_state_flag_from_str(const char *str)
-{
- int i;
- int sf = SF_OK;
-
- if (strcmp(str, "ok") == 0) {
- return SF_OK;
- }
- for (i=0; i < ARRAY_SIZE(pkg_state_flag_map); i++) {
- const char *sfname = pkg_state_flag_map[i].str;
- int sfname_len = strlen(sfname);
- if (strncmp(str, sfname, sfname_len) == 0) {
- sf |= pkg_state_flag_map[i].value;
- str += sfname_len;
- if (str[0] == ',') {
- str++;
- } else {
- break;
- }
- }
- }
-
- return sf;
-}
-
-char *pkg_state_status_to_str(pkg_state_status_t ss)
-{
- int i;
-
- for (i=0; i < ARRAY_SIZE(pkg_state_status_map); i++) {
- if (pkg_state_status_map[i].value == ss) {
- return xstrdup(pkg_state_status_map[i].str);
- }
- }
-
- fprintf(stderr, "%s: ERROR: Illegal value for state_status: %d\n",
- __FUNCTION__, ss);
- return xstrdup("<STATE_STATUS_UNKNOWN>");
-}
-
-pkg_state_status_t pkg_state_status_from_str(const char *str)
-{
- int i;
-
- for (i=0; i < ARRAY_SIZE(pkg_state_status_map); i++) {
- if (strcmp(str, pkg_state_status_map[i].str) == 0) {
- return pkg_state_status_map[i].value;
- }
- }
-
- fprintf(stderr, "%s: ERROR: Illegal value for state_status string: %s\n",
- __FUNCTION__, str);
- return SS_NOT_INSTALLED;
-}
-
-int pkg_arch_supported(opkg_conf_t *conf, pkg_t *pkg)