Text-Markdown-Discount
view release on metacpan or search on metacpan
discount-2.2.7d/theme.c view on Meta::CPAN
argv += hoptind(&blob);
if ( argc > 0 ) {
int added_text=0;
if ( (source = malloc(strlen(argv[0]) + strlen("/index.text") + 1)) == 0 )
fail("out of memory allocating name buffer");
strcpy(source,argv[0]);
if ( (stat(source, &sourceinfo) == 0) && S_ISDIR(sourceinfo.st_mode) )
strcat(source, "/index");
if ( !freopen(source, "r", stdin) ) {
strcat(source, ".text");
added_text = 1;
if ( !freopen(source, "r", stdin) )
fail("can't open either %s or %s", argv[0], source);
}
if ( !output_file ) {
char *p, *q;
if ( (output_file = malloc(strlen(source) + strlen(".html") + 1)) == 0 )
fail("out of memory allocating output file name buffer");
strcpy(output_file, source);
if (( p = strchr(output_file, '/') ))
q = strrchr(p+1, '.');
else
q = strrchr(output_file, '.');
if ( q )
*q = 0;
else
q = output_file + strlen(output_file);
strcat(q, ".html");
}
}
if ( output_file && strcmp(output_file, "-") ) {
if ( force && notspecial(output_file) )
unlink(output_file);
if ( !freopen(output_file, "w", stdout) ) {
fail("can't write to %s", output_file);
}
}
if ( !pagename )
pagename = source;
if ( (doc = mkd_in(stdin, 0)) == 0 )
fail("can't read %s", source ? source : "stdin");
if ( fstat(fileno(stdin), &sourceinfo) == 0 )
infop = &sourceinfo;
#if HAVE_GETPWUID
me = getpwuid(infop ? infop->st_uid : getuid());
if ( (root = strdup(me->pw_dir)) == 0 )
fail("out of memory");
#endif
if ( !mkd_compile(doc, flags) )
fail("couldn't compile input");
if ( tmplfile )
spin(tmplfile,doc,stdout);
else
mkd_generatehtml(doc, stdout);
mkd_cleanup(doc);
exit(0);
}
( run in 0.420 second using v1.01-cache-2.11-cpan-39bf76dae61 )