
/*  File   : strntrans.c
    Author : Richard A. O'Keefe.
    Updated: 2 June 1984
    Defines: strntrans()

    strntrans(dst, src, len, from, to)
    Moves characters from src to dst, translating characters in from[]
    to the corresponding characters in to[], until either len characters
    have been moved or a NUL has been moved.  If fewer than len characters
    are moved, the remainder of dst will be filled with NULs, much like
    strncpy and family.  No value is returned.

    Apology: in the previous distribution of this package, strntrans was
    defined the way memtrans is now defined.  This is more consistent with
    the general naming conventions.
*/

#include "stdio.h"
#include "_str2map.h"

#define NUL '\0'

char *strntrans(dst, src, len, from, to)
register char *dst, *src;
int len;
char *from, *to;
{
    char *result;

    _str2map(0, from, to);
    while (--len >= 0 && (*dst++ = _map_vec[*src++]))
       ;
    result = dst - 1;
    while (--len >= 0)
       *dst++ = NUL;

    return result;
}

