diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2023-11-26 20:01:37 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2023-11-26 20:01:37 +0000 |
commit | eb31c65537daa22720c05d821d9a7f9ff0869d8e (patch) | |
tree | a8085feedd5711d4fcbe14d1e5a65a5c9d6e8c0f /editor | |
parent | b06d16dfbbb18ad8389123b247a3b25106affc0f (diff) | |
download | netpbm-mirror-eb31c65537daa22720c05d821d9a7f9ff0869d8e.tar.gz netpbm-mirror-eb31c65537daa22720c05d821d9a7f9ff0869d8e.tar.xz netpbm-mirror-eb31c65537daa22720c05d821d9a7f9ff0869d8e.zip |
cleanup - make internal 'pbmtext' for title take input from Standard Input instead of command line
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4790 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'editor')
-rw-r--r-- | editor/specialty/pnmindex.c | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/editor/specialty/pnmindex.c b/editor/specialty/pnmindex.c index f5b7306c..da974993 100644 --- a/editor/specialty/pnmindex.c +++ b/editor/specialty/pnmindex.c @@ -32,6 +32,7 @@ #include "shhopt.h" #include "mallocvar.h" #include "nstring.h" +#include "pm_system.h" #include "pnm.h" struct CmdlineInfo { @@ -340,23 +341,44 @@ static void makeTitle(const char * const title, unsigned int const rowNumber, bool const blackBackground, - const char * const tempDir) { + const char * const dirNm) { +/*---------------------------------------------------------------------------- + Create a PBM file containing the text 'title'. + + If 'blackBackground' is true, make it white on black; otherwise, black + on white. + Name the file like a thumbnail row file for row number 'rowNumber', + in directory named 'dirNm'. +-----------------------------------------------------------------------------*/ const char * const invertStage = blackBackground ? "| pnminvert " : ""; - const char * const titleToken = shellQuote(title); const char * fileName; + FILE * outFP; + struct bufferDesc titleBuf; + const char * shellCommand; + int termStatus; - fileName = rowFileName(tempDir, rowNumber); - - /* This quoting is not adequate. We really should do this without - a shell at all. - */ - systemf("pbmtext %s %s > %s", - titleToken, invertStage, fileName); + titleBuf.size = strlen(title); + titleBuf.buffer = (unsigned char *)title; + titleBuf.bytesTransferredP = NULL; + fileName = rowFileName(dirNm, rowNumber); + outFP = pm_openw(fileName); pm_strfree(fileName); - pm_strfree(titleToken); + + pm_asprintf(&shellCommand, "pbmtext %s", invertStage); + + pm_system2(&pm_feed_from_memory, &titleBuf, + &pm_accept_to_filestream, outFP, + shellCommand, &termStatus); + + pm_strfree(shellCommand); + + if (termStatus != 0) + pm_error("Failed to generate title image"); + + pm_close(outFP); } |