tmp = (char *)emalloc (strlen (filename) + 17); sprintf (tmp, "%s.h", filename); headerfile = efopen (tmp, "w"); fileuppr = strdup (filename);
asprintf (&tmp, "%s.h", filename); if (tmp == NULL) err (1, "malloc"); eefopen (tmp, "w", &headerfile); free (tmp);  fileuppr = estrdup (filename);
init_generate (char *filename){     char *tmp;     char *fileuppr;     func_list = listnew ();     tmp = (char *)emalloc (strlen (filename) + 17);     sprintf (tmp, "%s.h", filename);     headerfile = efopen (tmp, "w");     fileuppr = strdup (filename);     strupr (fileuppr);     fprintf (headerfile, "/* Generated from %s.xg */\n", filename);     fprintf (headerfile, "#ifndef _%s_\n"	      "#define _%s_\n\n", fileuppr, fileuppr);     free (fileuppr);          sprintf (tmp, "%s.ydr.c", filename);     ydrfile = efopen (tmp, "w");     fprintf (ydrfile, "/* Generated from %s.xg */\n", filename);     fprintf (ydrfile, "#include <%s.h>\n\n", filename);     fprintf (ydrfile, "#include <stdio.h>\n");     fprintf (ydrfile, "#include <stdlib.h>\n");     fprintf (ydrfile, "#include <sys/types.h>\n");     fprintf (ydrfile, "#include <netinet/in.h>\n");     fprintf (ydrfile, "#include <roken.h>\n");     fprintf (ydrfile, "#ifndef HAVE_BCOPY\n"	      "#define bcopy(a,b,c) memcpy((b),(a),(c))\n"	      "#endif /* !HAVE_BCOPY */\n\n");     sprintf (tmp, "%s.cs.c", filename);     clientfile = efopen (tmp, "w");     fprintf (clientfile, "/* Generated from %s.xg */\n", filename);     fprintf (clientfile, "#include \"%s.h\"\n\n", filename);     fprintf (clientfile, "#include \"%s.cs.h\"\n\n", filename);     fprintf (clientfile, "#include <stdio.h>\n");     fprintf (clientfile, "#include <stdlib.h>\n");     fprintf (clientfile, "#include <sys/types.h>\n");     fprintf (clientfile, "#include <netinet/in.h>\n");     fprintf (clientfile, "#include <roken.h>\n");     fprintf (clientfile, "#ifndef HAVE_BCOPY\n"	      "#define bcopy(a,b,c) memcpy((b),(a),(c))\n"	      "#endif /* !HAVE_BCOPY */\n\n");     sprintf (tmp, "%s.ss.c", filename);     serverfile = efopen (tmp, "w");     fprintf (serverfile, "/* Generated from %s.xg */\n", filename);     fprintf (serverfile, "#include \"%s.h\"\n\n", filename);     fprintf (serverfile, "#include \"%s.ss.h\"\n\n", filename);     fprintf (serverfile, "#include <stdio.h>\n");     fprintf (serverfile, "#include <stdlib.h>\n");     fprintf (serverfile, "#include <sys/types.h>\n");     fprintf (serverfile, "#include <netinet/in.h>\n");     fprintf (serverfile, "#include <roken.h>\n");     fprintf (serverfile, "#ifndef HAVE_BCOPY\n"	      "#define bcopy(a,b,c) memcpy((b),(a),(c))\n"	      "#endif /* !HAVE_BCOPY */\n\n");     sprintf (tmp, "%s.cs.h", filename);     clienthdrfile = efopen (tmp, "w");     fprintf (clienthdrfile, "/* Generated from %s.xg */\n", filename);     sprintf (tmp, "%s.ss.h", filename);     serverhdrfile = efopen (tmp, "w");     fprintf (serverhdrfile, "/* Generated from %s.xg */\n", filename);     fprintf (serverhdrfile, "#include <rx/rx.h>\n");     free (tmp);}