/* * efe - Trafansfoformafa tefextofo a foformafatofo "Efe" * * Sifimifirafal afal cofomafandofo BSD 'pig', efes ifigufuafalmefentefe * ufutifil pafarafa gefeneferafar refepofortefes mefensufuafalefes * * Afaufutofor: Nafahufuafal defe Rafazafa-Mefexificafanafa * (Tefecufuhtlifi Nafahufuafal) * * Grafacifiafas y safalufudofos a: nafaufuj * Pofor ayufudafarmefe afa cofomprefendefer efestefe * efextafa~ofo lefengufuafajefe * * Ufusofo: efe [OPCION] * * Ofopcifiofonefes: --help, --info * */ #include #include #include #include #define BUFFERSIZE 1024 #define GNUEXT 0 #ifdef GNUEXT void uso(void) __attribute__ ((noreturn)); #else void uso(void); #endif void efeizar(char *, int); static char info[] = "\x65\x66\x65\x20\x76\x20\x31\x2E\x30\x20\x20\x28\x30\x34\x2F\x32\x30\x30\x31\x29\x0D\x0A\x52\x61\x7A\x61\x2D\x4D\x65\x78\x69\x63\x61\x6E\x61\x20\x54\x65\x61\x6D"; int main(int argc, char * argv[]) { char buffer[BUFFERSIZE]; register int len; int ch; if(argv[1] != NULL) { if((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0)) { uso(); } else if((strcmp(argv[1], "-i") == 0) || (strcmp(argv[1], "--info") == 0)) { printf("%s\n", info); exit(EXIT_SUCCESS); } else { puts("Argumento incorrecto.\n -h o --help para ayuda"); exit(EXIT_FAILURE); } } for(len = 0; (ch = getchar()) != EOF;) { if(isalpha(ch)) { if(len >= sizeof(buffer)) { puts("\nERROR: buffer sobrecargado"); exit(EXIT_FAILURE); } buffer[len++] = ch; continue; } if(len != 0) { efeizar(buffer, len); len = 0; } putc(ch, stdout); } exit(EXIT_SUCCESS); } void efeizar(char * buffer, int len) { register int cnt; /* * A todas las vocales se les a~ade 'f' seguida de la misma vocal. * La 'y' no se considera vocal, ni la 'u' en 'qu'. * Segun yo eso es todo; y si no, es culpa de nauj ;) * */ for(cnt = 0; cnt < len; cnt++) { if((buffer[cnt] == 'u') && (buffer[cnt - 1] == 'q')) { printf("%c", buffer[cnt]); continue; } if(strchr("aeiouAEIOU", buffer[cnt]) != NULL) { printf("%cf%c", buffer[cnt], buffer[cnt]); continue; } else { printf("%c", buffer[cnt]); } } } void uso(void) { puts(" Uso: efe [OPCION] Transformar texto a formato \'Efe\' -h, --help desplegar esta ayuda -i, --info desplegar informacion de alta importancia Lee texto de stdin y lo envia transformado a stdout. Se puede usar redireccion, por supuesto: efe < archivo_entrada [> archivo_salida] Errores del algoritmo efeizador reportarlos a: nahual@raza-mexicana.org "); exit(EXIT_SUCCESS); } /***************************************************************************** efe - Reformats input as Pig Latin spanish counterpart 'Efe' Copyright (C) 2001 Nahual/Raza-Mexicana 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 2 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, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Contact: nahual@raza-mexicana.org ******************************************************************************/