/* Test-Suite for pfinger * * Copyright (C) 2001 Michael Baumer * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #include #include #include "statusdb.h" #include "log.h" #include "finger.h" #include "compat.h" #include "parser.h" #define NUM_CLIENTS 256 #define NUM_USER 128 char users[NUM_USER][5]; int user_idle[NUM_USER]; int user_host[NUM_USER]; int user_login_t[NUM_USER]; int cur_host; Node mynode; fingerconf config; int debug; int db_insertlist(db_entry *list) { int i; int j; i = 0; while(list->next) { /* Iterate over list and compare with saved values */ for (j=0; jlogin_user, users[j])) break; if (j==NUM_USER) log(LOG_ERR, "User %d not found in users[]", list->login_user); else { /* Compare */ if (list->idle_time != user_idle[j]) log(LOG_ERR, "Idle times do not match: %d vs. %d (user: %s)", list->idle_time, user_idle[j], list->login_user); if (strcmp(list->hostname, config.clients[user_host[j]])) log(LOG_ERR, "Hosts do not match: %s vs. %s (user: %s)", list->hostname, config.clients[user_host[j]], list->login_user); if (list->login_time != user_login_t[j]) log(LOG_ERR, "login times do not match: %d vs. %d (user: %s)", list->login_time, user_login_t[j], list->login_user); } list = list->next; i++; } if (ichild->value, users[i]); /* idle time */ idle = rand() % 1000; sprintf(mynode.child->child->next->value, "%d", idle); /* login time */ login_t = time(NULL)-(rand() % 10000); sprintf(mynode.child->child->next->next->value, "%d", login_t); /* host name */ sprintf(mynode.child->child->next->next->next->value, "%s", config.clients[cur_host]); /* save values for most active user/host for later check */ if (user_idle[i] > idle) { user_idle[i] = idle; user_login_t[i] = login_t; user_host[i] = cur_host; } handle_online_user(&mynode); } return 1; } void create_logins() { int i, j; char login[5]; strcpy(login, "aaaa"); for (i=0; i user -> login * utctime * ... */ void create_node() { Node *node; /* top node */ strcpy(mynode.id, "online_reply"); mynode.child = (Node *)calloc(1, (sizeof(Node))); node = mynode.child; /* user node */ strcpy(node->id, "user"); node->child = (Node *)calloc(1, (sizeof(Node))); node = node->child; /* field nodes */ /* the first one is the login name */ strcpy(node->id, "login"); node->value = (char *)calloc(1, 256); node->next = (Node *)calloc(1, (sizeof(Node))); node = node->next; /* the second is the idle time */ strcpy(node->id, "idle"); node->value = (char *)calloc(1, 256); node->next = (Node *)calloc(1, (sizeof(Node))); node = node->next; /* the third is the login time */ strcpy(node->id, "utctime"); node->value = (char *)calloc(1, 256); node->next = (Node *)calloc(1, (sizeof(Node))); node = node->next; /* the 4th is the host name */ strcpy(node->id, "host"); node->value = (char *)calloc(1, 256); } void init_clients() { char host[5]; int i; config.clients = (char **)malloc(NUM_CLIENTS*sizeof(void *)); strcpy(host, "aaaa"); for (i=0; i