inc/textOut.h File Reference

#include "pipeline.h"

Include dependency graph for textOut.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define textOutCompressNone   "none"
#define textOutCompressBzip2   "bzip2"
#define textOutCompressCompress   "compress"
#define textOutCompressGzip   "gzip"
#define textOutCompressZip   "zip"
#define textOutCompressMenuContents
#define textOutCompressValuesContents

Functions

pipelinetextOutInit (char *fileName, char *compressType)
void textOutClose (struct pipeline **pCompressPipeline)


Define Documentation

#define textOutCompressBzip2   "bzip2"

Definition at line 10 of file textOut.h.

Referenced by cleanEnvVars(), getCompressor(), and getCompressSuffix().

#define textOutCompressCompress   "compress"

Definition at line 11 of file textOut.h.

Referenced by cleanEnvVars(), getCompressor(), and getCompressSuffix().

#define textOutCompressGzip   "gzip"

Definition at line 12 of file textOut.h.

Referenced by cleanEnvVars(), getCompressor(), and getCompressSuffix().

#define textOutCompressMenuContents

Value:

{ "plain text",\
                                       "gzip compressed (.gz)",\
                                       "bzip2 compressed (.bz2)",\
                                       "LZW compressed (.Z)",\
                                       "zip compressed (.zip)",\
                                       NULL\
                                     }

Definition at line 18 of file textOut.h.

#define textOutCompressNone   "none"

Definition at line 9 of file textOut.h.

Referenced by textOutInit().

#define textOutCompressValuesContents

Value:

Definition at line 26 of file textOut.h.

#define textOutCompressZip   "zip"

Definition at line 13 of file textOut.h.

Referenced by cleanEnvVars(), getCompressor(), and getCompressSuffix().


Function Documentation

void textOutClose ( struct pipeline **  pCompressPipeline  ) 

Definition at line 152 of file textOut.c.

References pipelineFree(), and pipelineWait().

00155 {
00156 if (pCompressPipeline && *pCompressPipeline)
00157     {
00158     fflush(stdout);
00159     fclose(stdout);
00160     pipelineWait(*pCompressPipeline);
00161     pipelineFree(pCompressPipeline);
00162     }
00163 }

Here is the call graph for this function:

struct pipeline* textOutInit ( char *  fileName,
char *  compressType 
) [read]

Definition at line 104 of file textOut.c.

References cleanEnvVars(), endsWith(), errnoAbort(), getCompressor(), getCompressSuffix(), isEmpty, pipelineFd(), pipelineOpen1(), pipelineWrite, pushAbortHandler(), pushWarnHandler(), sameWord, textOutAbortHandler(), textOutCompressNone, textOutWarnHandler(), and trimSpaces().

00110 {
00111 struct pipeline *compressPipeline = NULL;
00112 
00113 trimSpaces(fileName);
00114 if (isEmpty(fileName))
00115     {
00116     printf("Content-Type: text/plain\n\n");
00117     }
00118 else if (isEmpty(compressType) || sameWord(compressType, textOutCompressNone))
00119     {
00120     printf("Content-Type: application/octet-stream\n");
00121     printf("Content-Disposition: attachment; filename=%s\n\n", fileName);
00122     }
00123 else
00124     {
00125     char *suffix = getCompressSuffix(compressType);
00126 
00127     printf("Content-Type: application/x-%s\n", compressType);
00128     if (endsWith(fileName, suffix))
00129         printf("Content-Disposition: attachment; filename=%s\n\n", fileName);
00130     else
00131         printf("Content-Disposition: attachment; filename=%s%s\n\n",
00132                fileName, suffix);
00133 
00134     /* Send the Content header uncompressed! */
00135     fflush(stdout);
00136 
00137     /* Make sure no environment variables interfere with compressor. */
00138     cleanEnvVars(compressType);
00139 
00140     /* Redirect stdout to compressor pipeline object. */
00141     compressPipeline = pipelineOpen1(getCompressor(compressType),
00142                                      pipelineWrite, NULL, NULL);
00143     if (-1 == dup2(pipelineFd(compressPipeline), STDOUT_FILENO))
00144         errnoAbort("dup2(pipelineFd %d, stdout %d) failed in textOpen()",
00145                    pipelineFd(compressPipeline), STDOUT_FILENO);
00146     }
00147 pushWarnHandler(textOutWarnHandler);
00148 pushAbortHandler(textOutAbortHandler);
00149 return(compressPipeline);
00150 }

Here is the call graph for this function:


Generated on Tue Dec 25 19:17:17 2007 for blat by  doxygen 1.5.2