Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 93471
Collapse All | Expand All

(-)KeyRing/keyring.c.original (-8 / +64 lines)
Lines 160-165 Link Here
160
160
161
static int keyring_find(int unique_id);
161
static int keyring_find(int unique_id);
162
162
163
int plugin_unpack_cai_from_ai(struct CategoryAppInfo *cai, unsigned char *ai_raw, int len);
164
163
/****************************** Main Code *************************************/
165
/****************************** Main Code *************************************/
164
static int pack_KeyRing(struct KeyRing *kr, unsigned char *buf, int buf_size,
166
static int pack_KeyRing(struct KeyRing *kr, unsigned char *buf, int buf_size,
165
			int *wrote_size)
167
			int *wrote_size)
Lines 1348-1364 Link Here
1348
1350
1349
   /* This gets the application specific data out of the database for us.
1351
   /* This gets the application specific data out of the database for us.
1350
    * We still need to write a function to unpack it from its blob form. */
1352
    * We still need to write a function to unpack it from its blob form. */
1353
1354
   memset (&ai, 0, sizeof (ai));
1351
   
1355
   
1352
   jp_get_app_info("Keys-Gtkr", &buf, &buf_size);
1356
   jp_get_app_info("Keys-Gtkr", &buf, &buf_size);
1353
1357
1354
   /* This call should work, but the appinfo is too small, so we do it */
1358
   plugin_unpack_cai_from_ai (&ai, buf, buf_size);
1355
   /* Keyring is not using a legal category app info structure */
1356
   /* unpack_CategoryAppInfo(&ai, buf, buf_size+4); */
1357
   
1358
   /* I'm going to be lazy and only get the names, since that's all I use */
1359
   for (i=0; i<NUM_KEYRING_CAT_ITEMS; i++) {
1360
      memcpy(&ai.name[i][0], buf+i*16+2, 16);
1361
   }
1362
1359
1363
   free(buf);
1360
   free(buf);
1364
   
1361
   
Lines 2238-2240 Link Here
2238
2235
2239
   return EXIT_SUCCESS;
2236
   return EXIT_SUCCESS;
2240
}
2237
}
2238
2239
/* Stolen from pilot-link and modified slightly. */
2240
int plugin_unpack_cai_from_ai(struct CategoryAppInfo *ai, unsigned char *record, int len)
2241
{
2242
	int 	i, rec;
2243
2244
	if (len < 2 + 16 * 16 + 16 + 2)
2245
		return 0;
2246
	rec = get_short(record);
2247
	for (i = 0; i < 16; i++) {
2248
		if (rec & (1 << i))
2249
			ai->renamed[i] = 1;
2250
		else
2251
			ai->renamed[i] = 0;
2252
	}
2253
	record += 2;
2254
	for (i = 0; i < 16; i++) {
2255
		memcpy(ai->name[i], record, 16);
2256
		record += 16;
2257
	}
2258
	memcpy(ai->ID, record, 16);
2259
	record += 16;
2260
	ai->lastUniqueID = get_byte(record);
2261
	record += 2;
2262
2263
	return 2 + 16 * 16 + 16 + 2;
2264
}
2265
2266
int plugin_pack_cai_into_ai(struct CategoryAppInfo *ai, unsigned char *record, int len)
2267
{
2268
	int 	i, rec;
2269
	
2270
	unsigned char *start = record;
2271
2272
	if (!record) {
2273
		return 2 + 16 * 16 + 16 + 2;
2274
	}
2275
	if (len < (2 + 16 * 16 + 16 + 2))
2276
		return 0;	/* not enough room */
2277
	rec = 0;
2278
	for (i = 0; i < 16; i++) {
2279
		if (ai->renamed[i])
2280
			rec |= (1 << i);
2281
	}
2282
	set_short(record, rec);
2283
	record += 2;
2284
	for (i = 0; i < 16; i++) {
2285
		memcpy(record, ai->name[i], 16);
2286
		record += 16;
2287
	}
2288
	memcpy(record, ai->ID, 16);
2289
	record += 16;
2290
	set_byte(record, ai->lastUniqueID);
2291
	record++;
2292
	set_byte(record, 0);		/* gapfill */
2293
	record++;
2294
2295
	return (record - start);
2296
}

Return to bug 93471