static char *SccsId = "@(#)BSROTATE.c 4.1 (TU-Delft) 05/24/90";
/**********************************************************

Name/Version      : libfunc/4.1

Language          : C
Operating system  : UNIX SYSTEM V
Host machine      : GOULD

Author(s)         : O. Hol
Creation date     : 18-Feb-1988
Modified by       : 
Modification date : 


        Delft University of Technology
        Department of Electrical Engineering
        Network Theory Section
        Mekelweg 4 - P.O.Box 5031
        2600 GA DELFT
        The Netherlands

        Phone : 015 - 786234

        COPYRIGHT (C) 1988 , All rights reserved
**********************************************************/
#include <stdio.h>

char * adm_bsalloc();

/*  BSROTATE() : bit string is rotated in direction left or right */

char * BSROTATE(s,direction)
char  s[];
char   direction;
{
    char	*res;
    int	 	i;

    res = adm_bsalloc ( strlen(s) + 1, 'p' );

    switch ( direction ) {
	case ('l') :
	    for (i = 0 ; i < (strlen(s)-1) ; i++ )
		res[i]=s[i+1];
	    res[i]=s[0];
	    res[i+1]='\0';
	    break;
	case ('r') :
	    for (i = 0 ; i < (strlen(s)-1) ; i++ )
		res[i+1]=s[i];
	    res[0]=s[i];
	    res[i+1]='\0';
	    break;
	default :
	    fprintf (stderr, "ERROR: illegal direction in BSROTATE \n");
	    return(NULL);
    }

    return (res);
}
