1 /* release_parse.c - the opkg package management system
3 Copyright (C) 2010,2011 Javier Palacios
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2, or (at
8 your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
21 #include "release_parse.h"
22 #include "libbb/libbb.h"
23 #include "parse_util.h"
26 release_parse_line(void *ptr, const char *line, uint mask)
28 release_t *release = (release_t *) ptr;
31 unsigned int count = 0;
33 static int reading_md5sums = 0;
35 static int reading_sha256sums = 0;
40 if (is_field("Architectures", line)) {
41 release->architectures = parse_list(line, &release->architectures_count, ' ', 0);
46 if (is_field("Codename", line)) {
47 release->name = parse_simple("Codename", line);
49 else if (is_field("Components", line)) {
50 release->components = parse_list(line, &release->components_count, ' ', 0);
55 if (is_field("Date", line)) {
56 release->datestring = parse_simple("Date", line);
61 if (is_field("MD5sum", line)) {
63 if (release->md5sums == NULL) {
64 release->md5sums = xcalloc(1, sizeof(cksum_list_t));
65 cksum_list_init(release->md5sums);
67 goto dont_reset_flags;
73 if (is_field("SHA256", line)) {
74 reading_sha256sums = 1;
75 if (release->sha256sums == NULL) {
76 release->sha256sums = xcalloc(1, sizeof(cksum_list_t));
77 cksum_list_init(release->sha256sums);
79 goto dont_reset_flags;
85 if (reading_md5sums) {
86 list = parse_list(line, &count, ' ', 1);
87 cksum_list_append(release->md5sums, list);
88 goto dont_reset_flags;
91 else if (reading_sha256sums) {
92 list = parse_list(line, &count, ' ', 1);
93 cksum_list_append(release->sha256sums, list);
94 goto dont_reset_flags;
105 reading_sha256sums = 0;
114 release_parse_from_stream(release_t *release, FILE *fp)
118 const size_t len = 4096;
121 ret = parse_from_stream_nomalloc(release_parse_line, release, fp, 0, &buf, len);