/* @(#) $Id: manage_agents.h,v 1.12 2006/07/24 20:19:55 dcid Exp $ */

/* Copyright (C) 2003-2006 Daniel B. Cid <dcid@ossec.net>
 * All rights reserved.
 *
 * This program is a free software; you can redistribute it
 * and/or modify it under the terms of the GNU General Public
 * License (version 2) as published by the FSF - Free Software
 * Foundation
 */


#include "shared.h"
#include "sec.h"


/** Prototypes **/

/* Read any input from the user (stdin) */
char *read_from_user();

/* Add or remove an agent */
int add_agent();
int remove_agent();

/* Extract or import a key */
int k_extract();
int k_import();

/* Validation functions */
int OS_IsValidName(char *u_name);
int OS_IsValidID(char *id);
int IDExist(char *id);
int NameExist(char *u_name);

/* Print available agents */
int print_agents();
int list_agents();
    
/* clear a line */
char *chomp(char *str);


/* Shared variables */
int time1;
int time2;
int time3;
int rand1;
int rand2;
fpos_t fp_pos;


/* Internal defines */
#define USER_SIZE       514
#define FILE_SIZE       257
#define STR_SIZE        66

/* Internal strings */
#define QUIT                "\\q"

/* Print agents */
#define PRINT_AVAILABLE     "\nAvailable agents: \n"
#define PRINT_AGENT         "   ID: %s, Name: %s, IP: %s\n"

/* Add new agent */
#define ADD_NEW         "\n- Adding a new agent"\
                        " (use '\\q' to return to the main menu).\n"\
                        "  Please provide the following:\n"
#define ADD_NAME        "   * A name for the new agent: "
#define ADD_IP          "   * The IP Address of the new agent: "
#define ADD_ID          "   * An ID for the new agent[%s]: "
#define AGENT_INFO      "Agent information:\n   ID:%s\n   Name:%s\n   " \
                        "IP Address:%s\n\n"
#define ADD_CONFIRM     "Confirm adding it?(y/n): "
#define AGENT_ADD       "Agent added.\n"
#define ADDED           "Added.\n"
#define ADD_NOT         "Not Adding ..\n"
#define PRESS_ENTER     "** Press ENTER to return to the main menu.\n"

/* Add errors */
#define ADD_ERROR_ID    "\n** ID '%s' already present. Starting over again.\n"
#define ADD_ERROR_NAME  "\n** Name '%s' already present. Please enter a new name.\n"
#define IP_ERROR        "\n** Invalid IP '%s'. Please enter a valid IP Address.\n"
#define NO_AGENT        "\n** No agent available. You need to add one first.\n"
#define NO_ID           "\n** Invalid ID '%s' given. ID is not present.\n"
#define NO_KEY          "\n** Invalid authentication key. Starting over again.\n"
#define INVALID_ID      "\n** Invalid ID '%s' given. ID must be numeric (max 5 digits).\n"
#define INVALID_NAME    "\n** Invalid name '%s' given. Name must contain only alphanumeric characters (min=2, max=32).\n"

/* Remove agent */
#define REMOVE_ID       "Provide the ID of the agent to be removed (or '\\q' to quit): "
#define REMOVE_CONFIRM  "Confirm deleting it?(y/n): "
#define REMOVE_DONE     "Agent '%s' removed.\n"
#define REMOVE_NOT      "Not removing ..\n"

/* Import agent */    
#define IMPORT_KEY      "\n* Provide the Key generated by the server.\n" \
                        "* The best approach is to cut and paste it.\n" \
                        "*** OBS: Do not include spaces or new lines.\n\n" \
                        "Paste it here (or '\\q' to quit): "
    
/* extract key */    
#define EXTRACT_KEY     "Provide the ID of the agent to extract " \
                        "the key (or '\\q' to quit): "
#define EXTRACT_MSG     "\nAgent key information for '%s' is: \n%s\n" \
                        "\n** Press ENTER to return to the main menu.\n"
   
/* Commom errors */
#define ERROR_KEYS      "Unable to handle keys file. Exiting.\n"
#define EXTRACT_ERROR   "Unable to extract agent key.\n"
#define INPUT_LARGE     ARGV0": Input too large. Not adding it.\n"
#define EXIT            "\n" ARGV0 ": Exiting ..\n"

#define BANNER          "\n****************************************" \
                        "\n* %s %s Agent manager.       *" \
                        "\n* The following options are available: *" \
                        "\n****************************************\n"
    
#define BANNER_OPT      "   (A)dd an agent (A).\n" \
                        "   (E)xtract key for an agent (E).\n" \
                        "   (L)ist already added agents (L).\n" \
                        "   (R)emove an agent (R).\n" \
                        "   (Q)uit.\n" \
                        "Choose your action: A,E,L,R or Q: "

#define BANNER_CLIENT   "   (I)mport key from the server (I).\n" \
                        "   (Q)uit.\n" \
                        "Choose your action: I or Q: "
                        
/* EOF */
