+int UserBySponsor(int argc, char **argv)
+{
+ char buf[BUFSIZ], temp_buf[BUFSIZ], *type, *name;
+ struct mqelem *top;
+
+ type = strdup("USER");
+ if (GetTypeFromUser("Type of sponsor", "search_ace_type", &type) == SUB_ERROR)
+ return DM_NORMAL;
+
+ sprintf(buf, "Name of %s", type);
+ name = strdup(user);
+ if (GetValueFromUser(buf, &name) == SUB_ERROR)
+ return DM_NORMAL;
+
+ switch (YesNoQuestion("Do you want a recursive search (y/n)", FALSE))
+ {
+ case TRUE:
+ sprintf(temp_buf, "R%s", type); /* "USER to "RUSER", etc. */
+ free(type);
+ type = strdup(temp_buf);
+ break;
+ case FALSE:
+ break;
+ default:
+ return DM_NORMAL;
+ }
+
+ top = GetUserBySponsor(type, name);
+ Loop(top, PrintLogin);
+
+ FreeQueue(top);
+ return DM_NORMAL;
+}
+
+static void PrintLogin(char **info)
+{
+ char buf[BUFSIZ];
+
+ sprintf(buf, "Login: %s", info[U_NAME]);
+ Put_message(buf);
+}
+
+struct mqelem *GetUserBySponsor(char *type, char *name)
+{
+ char *args[2];
+ struct mqelem *elem = NULL;
+ int status;
+
+ args[0] = type;
+ args[1] = name;
+ if ((status = do_mr_query("get_user_account_by_sponsor", 2, args, StoreInfo,
+ &elem)))
+ {
+ com_err(program_name, status, " in get_user_account_by_sponsor");
+ return NULL;
+ }
+ return QueueTop(elem);
+}