* Autores: Leandro Lucarella <llucare@fi.uba.ar>
*----------------------------------------------------------------------------
*
- * $Id: vfile.c 748 2004-06-21 00:46:08Z llucare $
+ * $Id$
*
*/
*
*/
-int main(int argc, char* argv[])
+int main()
{
- size_t pagesize = BUFSIZ;
size_t len;
- char* page;
- char* pageout;
- if (argc > 1) pagesize = atoi(argv[1]);
- if (!(page = malloc(pagesize))) return 1;
- if (!(pageout = malloc(pagesize/2+pagesize+1))) /* por si se expande */
+ char buff[2];
+ int c;
+ ZG zg;
+ zg_init(&zg);
+ while ((c = getchar()) != EOF)
{
- free(page);
- return 1;
+ if ((len = zg_group(&zg, buff, c))) fwrite(buff, 1, len, stdout);
}
- while ((len = fread(page, 1, pagesize, stdin)))
- {
- len = zg_group(pageout, page, len);
- fwrite(pageout, 1, len, stdout);
- }
- free(page);
+ /* imprimo si quedó algo en el buffer */
+ if ((len = zg_group_finish(&zg, buff))) fwrite(buff, 1, len, stdout);
return 0;
}