diff options
author | ticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2008-12-14 23:52:05 (EST) |
---|---|---|
committer | ticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2008-12-14 23:52:05 (EST) |
commit | dba0a0abdfbd89539090ccb41590e48fefc49c9b (patch) | |
tree | 528aae271d4af2a4a16a4ec397ebbb2fb4f44896 | |
parent | d281eab6487605176bd20efcfe21dabbd1514735 (diff) |
opkg: add support for Tags attribute
git-svn-id: http://opkg.googlecode.com/svn/trunk@42 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
-rw-r--r-- | libopkg/pkg.c | 21 | ||||
-rw-r--r-- | libopkg/pkg.h | 1 | ||||
-rw-r--r-- | libopkg/pkg_parse.c | 5 |
3 files changed, 27 insertions, 0 deletions
diff --git a/libopkg/pkg.c b/libopkg/pkg.c index 93fd20a..af2dd83 100644 --- a/libopkg/pkg.c +++ b/libopkg/pkg.c @@ -206,6 +206,8 @@ void pkg_deinit(pkg_t *pkg) 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) @@ -522,6 +524,10 @@ char * pkg_formatted_info(pkg_t *pkg ) strncat(buff ,line, strlen(line)); free(line); + line = pkg_formatted_field(pkg, "Tags"); + strncat(buff ,line, strlen(line)); + free(line); + return buff; } @@ -937,6 +943,21 @@ char * pkg_formatted_field(pkg_t *pkg, const char *field ) } } 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 */ diff --git a/libopkg/pkg.h b/libopkg/pkg.h index ffb969b..0cb9ba1 100644 --- a/libopkg/pkg.h +++ b/libopkg/pkg.h @@ -124,6 +124,7 @@ struct pkg 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; diff --git a/libopkg/pkg_parse.c b/libopkg/pkg_parse.c index a8a1f2a..5b321b5 100644 --- a/libopkg/pkg_parse.c +++ b/libopkg/pkg_parse.c @@ -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; + case 'T': + if(isGenericFieldType("Tags:", *lines)) + pkg->tags = parseGenericFieldType("Tags", *lines); + break; + case 'M': if(isGenericFieldType("MD5sum:", *lines)) pkg->md5sum = parseGenericFieldType("MD5sum", *lines); |