/*
 *     $Filename: expandalias $
 *     $Revision: 1.4 $
 *     $Date: 1993/10/06 12:19:18 $
 *
 *     Just a small set of subroutines to control the alias-expand-
 *     routines.
 *
 *     © Copyright 1993 Peter Simons, Germany
 *       All Rights Reserved
 *
 *     $Id: expandalias.c,v 1.4 1993/10/06 12:19:18 simons Exp simons $
 *
 * ------------------------------ log history ----------------------------
 * $Log: expandalias.c,v $
 * Revision 1.4  1993/10/06  12:19:18  simons
 * Changed format of RCS-Header.
 *
 * Revision 1.3  1993/09/02  03:57:45  simons
 * The alias-handling isn't included here directly, but linked with the
 * uucp.lib.
 *
 * Revision 1.2  1993/08/28  18:41:27  simons
 * Renamed ExtractAliases() to ExpandAliases() and modified the routines
 * in minor ways.
 *
 * Revision 1.1  1993/08/28  18:25:35  simons
 * Initial revision
 */


/**************************************************************************
 *                                                                        *
 * Sektion: Macros, Definitions, Includes, Structures                     *
 *                                                                        *
 **************************************************************************/

/************************************* Includes ***********/
#include <stdlib.h>

/************************************* Defines ************/
#define MAX_RECEIPIENTS 256     /* max. number of receipients */

/************************************* Prototypes *********/
void LoadAliases(void);
int UserAliasList(char const * , int (* )(char const * , long , int ), long , int );
void callBack(char *, long, int);
char **ExtractAliases(char **);

/************************************* global Variables ***/
        static char **new_receipients;
        static const char __RCSId[] = "$Id: expandalias.c,v 1.4 1993/10/06 12:19:18 simons Exp simons $";


/**************************************************************************
 *                                                                        *
 * Sektion: Unterprogramme                                                *
 *                                                                        *
 **************************************************************************/

char **ExpandAliases(char *receipients[])
{
        char **new_receipients2;

        if (*receipients == NULL)
                return NULL;

        if ((new_receipients = malloc(sizeof(char *[MAX_RECEIPIENTS]))) == NULL)
                return NULL;

        new_receipients2 = new_receipients;
        LoadAliases();
        while (*receipients != NULL) {
                UserAliasList(*receipients, (int (*)(char *, long, int)) callBack, 0L, 1);
                receipients++;
        }
        *new_receipients = NULL;
        return new_receipients2;
}

void callBack(char *name, long dummy, int show)
{
        switch(name[0]) {
        case '|': case '>': case '<':
                break;
        case '\\':
                ++name;
        default:
                *new_receipients = name;
                new_receipients++;
                break;
        }
}

