/***********************************************
 * released under (E) licensing ...            *
 *        (E) RULES AND REGULATIONS            *
 * permission to use/rewrite/add     : granted *
 * permission to trojan/steal        : denied  *
 * permission to use illegally       : denied  *
 * permission to use on /dev/urandom : denied  *
 ***********************************************/
/* contact el8@press.co.jp for full license    */
/* code copyrighted by ~el8 -- don't infringe! */

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

struct letterpeople
{
  char a;
  char b;
};

struct wordz
{
  char *a;
  char *b;
};

struct letterpeople leterz[] = {
  {'a', '4'},
  {'e', '3'},
  {'i', '1'},
  {'o', '0'},
  {'s', '5'},
  {'A', '4'},
  {'O', '0'},
  {0, 0}
};

struct wordz w0rdz[] = {
  {"with", "w/"},
  {"without", "w/o"},
  {"fuck", "fuq"},
  {"fucking", "fuqn"},
  {"shit", "shyt"},
  {"looser", "nigr"},
  {0, 0}
};

int
leet (char *str, int type)
{
  int x, y, nword = 1, z = 0, j = 0;

  if (type == 1)
    {
/* lame elite leet talker */
      for (x = 0; x < strlen (str); x++)
        {
          if (str[x] == ' ')
            {
              nword = 1;
              continue;
            }

          if (str[x] == 'u')
            {
              if (!z)
                {
                  if (!nword)
                    {
                      str[x] = 'U';
                      z += 1;
                      continue;
                    }
                }
              else
                z += 1;
            }

          if (z == 5)
            z = 0;              /* leniant */

          if ((str[x] == 's' || str[x] == 'S')
              && (!isalpha (str[x + 1]) || str[x + 1] == '\0'))
            {
              if (!j)
                {
                  if (!nword)
                    {
                      str[x] = 'z';
                      j += 1;
                      continue;
                    }
                }
              else
                j += 1;
            }

          if (j == 2)
            j = 0;

          for (y = 0; y < sizeof (leterz); y++)
            {
              if (str[x] == leterz[y].a)
                {
                  if (isdigit (str[x - 1]) || isdigit (str[x + 1]))
                    break;
                  if (nword)
                    break;
                  if (str[x + 1] == ' ')
                    break;
                  if (!isalpha (str[x - 1]) || !isalpha (str[x + 1]))
                    break;
                  if (x == strlen (str) - 2)
                    break;
                  if (isupper (str[x - 1]) && islower (str[x + 1]))
                    break;
                  if (str[x] == 'e' || str[x] == 'E')
                    {
                      if (str[x + 1] == 'e' || str[x + 1] == 'E')
                        {
                          str[x + 1] = '4';
                          x += 1;
                          break;
                        }
                    }
                  str[x] = leterz[y].b;
                }
            }
          nword = 0;
        }
      printf ("%s", str);
    }
  return 1;
}

int
warez_talker (char *str, int type)
{
  int x, y = 0, z;

  if (type == 1)
    {
/* lame elite warez talker */
      for (x = 0; x < strlen (str); x++)
        {
          if (y == 0)
            {                   /* make upper */
              str[x] = toupper (str[x]);
              y += 1;
            }
          else
            {
/* make lower */
              str[x] = tolower (str[x]);
              y = 0;
            }
        }
      printf ("%s", str);
    }

  return 1;
}

int
main (int argc, char *argv[])
{
  char buff[255];

  while (31337)
    {
      bzero (&buff, sizeof (buff));
      if (fgets (buff, (sizeof (buff) - 1), stdin) == NULL)
        break;
      leet (buff, 1);           /* leet */
      leet (buff, 2);           /* more leet */
      warez_talker (buff, 1);   /* leet */
    }

  return 0x7a69;
}


syntax highlighted by Code2HTML, v. 0.9.1