Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

insult generator

Name: Anonymous 2012-10-12 4:00


/*
 * File: prog-utils/insult-gen.c
 *
 * Purpose: Aid the generation of text insults
 *
 * Contributors:
 *  Anonymous-san
 *
*/

/*
prog-utils/insult-gen
Copyright (C) 2012  Anonymous-san

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.

     You should have received a copy of the GNU General Public License
     along with this program.  If not, see <http://www.gnu.org/licenses/>;.
*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <time.h>
#include <assert.h>

#define ASIZE(x) sizeof(x)/sizeof(x[0])

static const char * Modifiers[] =
{
  "homo",
  "sperg",
  "piss",
  "shit",
  "toilet",
  "dick",
  "cum",
  "urethra",
  "unemployed",
  "butt",
  "sick",
  "ass",
  "massive"
};

static const char * AdjectiveIdentifiers[] =
{
  "-mongling",
  "-bonering",
  "-flipping",
  "-nigging",
  "-aspergerian",
  "-talmudic",
  "anal",
  "-freudian"
};

static const char * NounIdentifiers[] =
{
  "anus",
  "faggot",
  "fag",
  "nigger",
  "sniffer",
  "lover",
  "kike",
  "penis",
  "cunt",
  "pig",
  "lord",
  "master",
  "scrubber",
  "midget",
  "jigaboo",
  "freetard",
  "culver",
  "pedo",
  "jew",
  "muslim",
  "stallmanite",
  "lisper"
};

static const char * VerbIdentifiers[] =
//not really verbs, but go back to your hugbox, aspie
{
  "sniffer",
  "licker",
  "wiper",
  "scratcher",
  "fucker",
  "flipper",
  "smoker"
};

//Program Options
static uint32_t ProgramOptions = 0;
static const uint32_t iNoRepeats = 0x01;

static uint32_t iAmountToGenerate = 5;

//end Program Options

void random_gen(char *, uint32_t n);

int main(int argc, char ** argv)
{
  char ** pArgv = argv;
  srand(time(0));

  while(*pArgv != NULL)
  {
    if(!strcmp(*pArgv, "--help")
      || !strcmp(*pArgv, "-h"))
    {
      puts("Options:\n"
      "--specify-amount #  How many insults you want to generate"
      " where # is an integer\n"
      "--feeling-lucky  Are you?\n"
      "--no-repeats  Will make sure output is not repeated\n"
      "\ninsult-gen is free software (i.e., abandonware)\n"
      "insult-gen is part of prog-utils\n");
     
      return 0;
    }
    else if(!strcmp(*pArgv, "--feeling-lucky"))
    {
      if(rand() % 2)
        goto win;
      while(1)
lose:
        puts("faggot!");
win:
      ;
    }
    else if(!strcmp(*pArgv, "--specify-amount"))
    {
      assert(*++pArgv);
      iAmountToGenerate = atoi(*pArgv);
    }
    else if(!strcmp(*pArgv, "--no-repeats"))
    {
      //Warning: quadratic complexity
      ProgramOptions |= iNoRepeats;

      //you know what, fuck this
      //just pipe to "uniq"
    }
    ++pArgv;
  }

  char * str = malloc(100);
  for(uint32_t k = 0; k < iAmountToGenerate; ++k)
  {
    random_gen(str, 100);
    puts(str);
  }
  free(str);

  return 0;
}

void random_gen
(
  char * dest,
  uint32_t n
)
{
  uint16_t l = 0;
  const char * szFirstComponent = Modifiers[rand() % (ASIZE(Modifiers))];
  const char * szMiddleComponent = (rand() % 7) > 5 ?
    AdjectiveIdentifiers[rand() % ASIZE(AdjectiveIdentifiers)]
    : NULL;
  const char * szSecondComponent = (rand() % 7) <= 5 ?
    NounIdentifiers[rand() % ASIZE(NounIdentifiers)]
    : VerbIdentifiers[rand() % ASIZE(VerbIdentifiers)];
 
  if(szMiddleComponent != NULL)
    goto middle_component_present;

middle_component_absent:
  assert(strlen(szFirstComponent) + strlen(szSecondComponent)
    < n);

  memcpy(dest, szFirstComponent, l = strlen(szFirstComponent));
  memcpy(dest + l, szSecondComponent, l += strlen(szSecondComponent));
  *(dest + l) = 0;
  goto end;
middle_component_present:
  assert(strlen(szFirstComponent) + strlen(szSecondComponent)
    + strlen(szMiddleComponent) < n);

  memcpy(dest, szFirstComponent, l = strlen(szFirstComponent));
  memcpy(dest + l, szMiddleComponent, l += strlen(szMiddleComponent));
  *(dest + l++) = '-';
  memcpy(dest + l, szSecondComponent, l+= strlen(szSecondComponent));
  *(dest + l) = 0;
end:
  ;
}

Name: Anonymous 2012-10-12 21:10

>>31
how do you multiline quote? the piece of shit won't work with the [o] trick

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List