int *minorType,
struct rx_opaque **keyMaterial);
+extern int afsconf_GetAllKeys(struct afsconf_dir *,
+ struct afsconf_typedKeyList **);
extern int afsconf_GetKeysByType(struct afsconf_dir *dir,
afsconf_keyType type, int kvno,
struct afsconf_typedKeyList **);
}
int
+afsconf_GetAllKeys(struct afsconf_dir *dir, struct afsconf_typedKeyList **keys)
+{
+ int code;
+ struct afsconf_typedKeyList *retval;
+ struct opr_queue *typeCursor;
+ struct keyTypeList *typeEntry;
+ struct opr_queue *kvnoCursor;
+ struct kvnoList *kvnoEntry;
+ struct opr_queue *subCursor;
+ struct subTypeList *subEntry;
+ int count;
+
+ LOCK_GLOBAL_MUTEX;
+
+ code = _afsconf_Check(dir);
+ if (code)
+ goto out;
+
+ count = 0;
+ /* First, work out how many keys we have in total */
+ for (opr_queue_Scan(&dir->keyList, typeCursor)) {
+ typeEntry = opr_queue_Entry(typeCursor, struct keyTypeList, link);
+ for (opr_queue_Scan(&typeEntry->kvnoList, kvnoCursor)) {
+ kvnoEntry = opr_queue_Entry(kvnoCursor, struct kvnoList, link);
+ for (opr_queue_Scan(&kvnoEntry->subTypeList, subCursor)) {
+ subEntry = opr_queue_Entry(subCursor, struct subTypeList, link);
+ count++;
+ }
+ }
+ }
+
+ /* Allocate space for all of these */
+ retval = malloc(sizeof(struct afsconf_typedKeyList));
+ retval->nkeys = count;
+ retval->keys = calloc(retval->nkeys, sizeof(struct afsconf_typedKey *));
+
+ /* Populate the key list */
+ count = 0;
+ for (opr_queue_Scan(&dir->keyList, typeCursor)) {
+ typeEntry = opr_queue_Entry(typeCursor, struct keyTypeList, link);
+ for (opr_queue_Scan(&typeEntry->kvnoList, kvnoCursor)) {
+ kvnoEntry = opr_queue_Entry(kvnoCursor, struct kvnoList, link);
+ for (opr_queue_Scan(&kvnoEntry->subTypeList, subCursor)) {
+ subEntry = opr_queue_Entry(subCursor, struct subTypeList, link);
+ retval->keys[count] = afsconf_typedKey_get(subEntry->key);
+ count++;
+ }
+ }
+ }
+
+ *keys = retval;
+
+out:
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
+}
+
+int
afsconf_GetKeyByTypes(struct afsconf_dir *dir, afsconf_keyType type,
int kvno, int subType, struct afsconf_typedKey **key)
{
int code;
int i;
- plan(127);
+ plan(134);
/* Create a temporary afs configuration directory */
" ... with the right key in slot 1");
afsconf_PutTypedKeyList(&typedKeyList);
+ /* Check that GetAllKeys works as expected */
+ code = afsconf_GetAllKeys(dir, &typedKeyList);
+ is_int(0, code, "afsconf_GetAllKeys returns success");
+ is_int(5, typedKeyList->nkeys, " ... with the correct number of keys");
+ ok(keyMatches(typedKeyList->keys[0], afsconf_rxkad, 1, 0,
+ "\x10\x10\x10\x10\x10\x10\x10\x10", 8),
+ " ... with right key in slot 0");
+ ok(keyMatches(typedKeyList->keys[1], afsconf_rxkad, 2, 0,
+ "\x30\x30\x30\x30\x30\x30\x30\x30", 8),
+ " ... with right key in slot 1");
+ ok(keyMatches(typedKeyList->keys[2], 1, 1, 0, "\x03", 1),
+ " ... with right key in slot 2");
+ ok(keyMatches(typedKeyList->keys[3], 1, 2, 0, "\x01", 1),
+ " ... with right key in slot 3");
+ ok(keyMatches(typedKeyList->keys[4], 1, 2, 1, "\x02\03", 2),
+ " ... with right key in slot 4");
+
afsconf_Close(dir);
unlinkTestConfig(dirname);