blob: 1d22f0e8c1fcd2f0618c2c90c8b6c8a7ea7cf953 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
string.txt
Scott Bronson
bronson@trestle.com
This describes the format of RPM_I18NSTRING_TYPE or RPM_STRING_ARRAY_TYPE,
I could not find this documented anywhere except the source of rpmlib.
This memory block consists of count charptrs pointing to strings further
along in the block. A brief example for a count of 2 (as returned by
headerGetEntry), using typedef to illustrate the structure:
count = 2;
typedef struct block { # beginning of malloc'd block
char *c1 = &s1; # points to s1 below
char *c2 = &s2; # points to s2 below
char s1[] = "data for string 1";
char s2[] = "data for string 2";
} # end of malloc'd block
And, if count were three, this would be the result:
count = 2;
typedef struct block { # beginning of malloc'd block
char *c1 = &s1; # points to s1 below
char *c2 = &s2; # points to s2 below
char *c3 = &s3; # points to s2 below
char s1[] = "data for string 1";
char s2[] = "data for string 2";
char s3[] = "data for string 3";
} # end of malloc'd block
Therefore, to print out all the strings in one of these blocks in order...
(p and count are values returned by rpmlib)
for( i=0; i<count; i++ ) {
printf( "String %d: %s\n", i, *((char**)p+i) );
}
|