}   if (db_type != NULL && *db_type != '\0') { if (db_type != SMDB_TYPE_DEFAULT && strcmp(db_type, "hash") != 0 && strcmp(db_type, "btree") != 0 && strcmp(db_type, "dbm") != 0) { fprintf(stderr, "praliases: Skipping non-file based alias type %s\n", db_type); return; }
praliases(filename, argc, argv)	char *filename;	int argc;	char **argv;{	int result;	char *colon;	char *db_name;	char *db_type;	SMDB_DATABASE *database = NULL;	SMDB_CURSOR *cursor = NULL;	SMDB_DBENT db_key, db_value;	SMDB_DBPARAMS params;	SMDB_USER_INFO user_info;	colon = strchr(filename, PATH_SEPARATOR);	if (colon == NULL)	{		db_name = filename;		db_type = SMDB_TYPE_DEFAULT;	}	else	{		*colon = '\0';		db_name = colon + 1;		db_type = filename;	}	/* clean off arguments */	for (;;)	{		while (isascii(*db_name) && isspace(*db_name))			db_name++;		if (*db_name != '-')			break;		while (*db_name != '\0' &&		       !(isascii(*db_name) && isspace(*db_name)))			db_name++;	}	if (*db_name == '\0' || (db_type != NULL && *db_type == '\0'))	{		if (colon != NULL)			*colon = ':';		fprintf(stderr,	"praliases: illegal alias specification: %s\n",			filename);		goto fatal;	}	memset(&params, '\0', sizeof params);	params.smdbp_cache_size = 1024 * 1024;	user_info.smdbu_id = RunAsUid;	user_info.smdbu_group_id = RunAsGid;	strlcpy(user_info.smdbu_name, RunAsUserName, SMDB_MAX_USER_NAME_LEN);	result = smdb_open_database(&database, db_name, O_RDONLY, 0,				    SFF_ROOTOK, db_type, &user_info, &params);	if (result != SMDBE_OK)	{		fprintf(stderr, "praliases: %s: open: %s\n",			db_name, errstring(result));		goto fatal;	}	if (argc == 0)	{		memset(&db_key, '\0', sizeof db_key);		memset(&db_value, '\0', sizeof db_value);		result = database->smdb_cursor(database, &cursor, 0);		if (result != SMDBE_OK)		{			fprintf(stderr, "praliases: %s: set cursor: %s\n",				db_name, errstring(result));			goto fatal;		}		while ((result = cursor->smdbc_get(cursor, &db_key, &db_value,						   SMDB_CURSOR_GET_NEXT)) ==						   SMDBE_OK)		{#if 0			/* skip magic @:@ entry */			if (db_key.size == 2 &&			    db_key.data[0] == '@' &&			    db_key.data[1] == '\0' &&			    db_value.size == 2 &&			    db_value.data[0] == '@' &&			    db_value.data[1] == '\0')				continue;#endif /* 0 */			printf("%.*s:%.*s\n",			       (int) db_key.size,			       (char *) db_key.data,			       (int) db_value.size,			       (char *) db_value.data);		}		if (result != SMDBE_OK && result != SMDBE_LAST_ENTRY)		{			fprintf(stderr,				"praliases: %s: get value at cursor: %s\n",				db_name, errstring(result));			goto fatal;		}	}	else for (; *argv != NULL; ++argv)	{		memset(&db_key, '\0', sizeof db_key);		memset(&db_value, '\0', sizeof db_value);		db_key.data = *argv;		db_key.size = strlen(*argv) + 1;		if (database->smdb_get(database, &db_key,				       &db_value, 0) == SMDBE_OK)		{			printf("%.*s:%.*s\n",			       (int) db_key.size,			       (char *) db_key.data,			       (int) db_value.size,			       (char *) db_value.data);		}		else			printf("%s: No such key\n", (char *) db_key.data);	} fatal:	if (cursor != NULL)		(void) cursor->smdbc_close(cursor);	if (database != NULL)		(void) database->smdb_close(database);	if (colon != NULL)		*colon = ':';	return;}