/*
 * Description: All bytes between thresholds mapped to a bottom byte
 * Usage: bottom l h b
 * Parameter l: lowest byte value to map
 * Parameter h: highest byte value to map
 * Parameter b: bottom byte
 * Copyright: Daniel Tisza, 2010
 * All rights reserved
 */

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[])
{
  int c;
  int l;
  int h;
  int b;

  if (argc != 4) /* validate argument count */
  {
    return 0;
  }

  l = (int)*argv[1];
  h = (int)*argv[2];
  b = (int)*argv[3];
  
  while ( (c = getchar()) != EOF) /* for all input characters */
  {
    if (c >= l && c <= h) /* byte in interval */
    {
      c = b;
    }
    printf("%c", c);
  }
}

