opkg: add support for Tags attribute
authorticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 15 Dec 2008 04:52:05 +0000 (04:52 +0000)
committerticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 15 Dec 2008 04:52:05 +0000 (04:52 +0000)
git-svn-id: http://opkg.googlecode.com/svn/trunk@42 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

libopkg/pkg.c
libopkg/pkg.h
libopkg/pkg_parse.c

index 93fd20a..af2dd83 100644 (file)
@@ -206,6 +206,8 @@ void pkg_deinit(pkg_t *pkg)
      pkg->installed_files_ref_cnt = 1;
      pkg_free_installed_files(pkg);
      pkg->essential = 0;
      pkg->installed_files_ref_cnt = 1;
      pkg_free_installed_files(pkg);
      pkg->essential = 0;
+     free (pkg->tags);
+     pkg->tags = NULL;
 }
 
 int pkg_init_from_file(pkg_t *pkg, const char *filename)
 }
 
 int pkg_init_from_file(pkg_t *pkg, const char *filename)
@@ -522,6 +524,10 @@ char * pkg_formatted_info(pkg_t *pkg )
      strncat(buff ,line, strlen(line));
      free(line);
 
      strncat(buff ,line, strlen(line));
      free(line);
 
+     line = pkg_formatted_field(pkg, "Tags");
+     strncat(buff ,line, strlen(line));
+     free(line);
+
      return buff;
 }
 
      return buff;
 }
 
@@ -937,6 +943,21 @@ char * pkg_formatted_field(pkg_t *pkg, const char *field )
          }
      }
          break;
          }
      }
          break;
+     case 't':
+     case 'T':
+         if (strcasecmp(field, "Tags") == 0) {
+              /* Tags */
+              if (pkg->tags) {
+                   temp = (char *)realloc(temp,strlen(pkg->tags)+8);
+                   if ( temp == NULL ){
+                     fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
+                     return NULL;
+                   }
+                   temp[0]='\0';
+                   snprintf(temp, (strlen(pkg->tags)+8), "Tags: %s\n", pkg->tags);
+              }
+         }
+         break;
      case 'v':
      case 'V': {
          /* Version */
      case 'v':
      case 'V': {
          /* Version */
index ffb969b..0cb9ba1 100644 (file)
@@ -124,6 +124,7 @@ struct pkg
      char *section;
      char *maintainer;
      char *description;
      char *section;
      char *maintainer;
      char *description;
+     char *tags;
      pkg_state_want_t state_want;
      pkg_state_flag_t state_flag;
      pkg_state_status_t state_status;
      pkg_state_want_t state_want;
      pkg_state_flag_t state_flag;
      pkg_state_status_t state_status;
index a8a1f2a..5b321b5 100644 (file)
@@ -282,6 +282,11 @@ int pkg_parse_raw(pkg_t *pkg, char ***raw, pkg_src_t *src, pkg_dest_t *dest)
                pkg->suggests_str = parseDependsString(*lines, &pkg->suggests_count);
            break;
 
                pkg->suggests_str = parseDependsString(*lines, &pkg->suggests_count);
            break;
 
+       case 'T':
+           if(isGenericFieldType("Tags:", *lines))
+               pkg->tags = parseGenericFieldType("Tags", *lines);
+           break;
+
        case 'M':
            if(isGenericFieldType("MD5sum:", *lines))
                pkg->md5sum = parseGenericFieldType("MD5sum", *lines);
        case 'M':
            if(isGenericFieldType("MD5sum:", *lines))
                pkg->md5sum = parseGenericFieldType("MD5sum", *lines);