hplip/hplip-logdir.patch
2012-10-17 10:05:29 +01:00

328 lines
12 KiB
Diff

diff -up hplip-3.12.10a/fax/backend/hpfax.py.logdir hplip-3.12.10a/fax/backend/hpfax.py
--- hplip-3.12.10a/fax/backend/hpfax.py.logdir 2012-10-17 09:56:43.979656073 +0100
+++ hplip-3.12.10a/fax/backend/hpfax.py 2012-10-17 09:57:33.286890599 +0100
@@ -244,7 +244,7 @@ else:
input_fd = 0
# REVISIT:
- tmp_dir = '/var/log/hp/tmp'
+ tmp_dir = os.environ.get ('TMPDIR', '/var/log/hp/tmp')
pipe_name = os.path.join(tmp_dir, "hpfax-pipe-%d" % job_id)
diff -up hplip-3.12.10a/logcapture.py.logdir hplip-3.12.10a/logcapture.py
--- hplip-3.12.10a/logcapture.py.logdir 2012-10-10 07:14:21.000000000 +0100
+++ hplip-3.12.10a/logcapture.py 2012-10-17 09:56:29.396578082 +0100
@@ -39,7 +39,7 @@ CUPS_BACKUP_FILE='/etc/cups/cupsd.conf_o
LOG_FOLDER_PATH='./'
LOG_FOLDER_NAME='hplip_troubleshoot_logs'
LOG_FILES=LOG_FOLDER_PATH + LOG_FOLDER_NAME
-TMP_DIR='/var/log/hp/tmp'
+TMP_DIR='/var/spool/cups/tmp'
############ enable_log() function ############
#This function changes CUPS conf log level to debug and restarts CUPS service.
@@ -268,7 +268,7 @@ if os.path.exists('/var/log/cups/error_l
log.error("Failed to capture %s log file."%("/var/log/cups/error_log"))
-File_list, File_list_str = utils.expand_list('/var/log/hp/*.log')
+File_list, File_list_str = utils.expand_list('%s/*.log'%TMP_DIR)
if File_list:
sts,out = utils.run('cp -f %s %s'%(File_list_str, LOG_FILES))
if sts != 0:
diff -up hplip-3.12.10a/prnt/filters/hplipjs.c.logdir hplip-3.12.10a/prnt/filters/hplipjs.c
--- hplip-3.12.10a/prnt/filters/hplipjs.c.logdir 2012-10-17 09:58:20.298135510 +0100
+++ hplip-3.12.10a/prnt/filters/hplipjs.c 2012-10-17 09:58:47.431276326 +0100
@@ -275,7 +275,8 @@ int main (int argc, char **argv)
{
fprintf (stderr, "DEBUG: HPLIPJS: argv[%d] = %s\n", i, argv[i]);
}
- snprintf(szPSFile, sizeof(szPSFile), "%s/output.ps","/var/log/hp/tmp");
+ snprintf(szPSFile, sizeof(szPSFile), "%s/output.ps",
+ getenv ("TMPDIR") ? : "/var/log/hp/tmp");
HPFp = fopen (szPSFile, "w");
#endif
diff -up hplip-3.12.10a/prnt/hpcups/HPCupsFilter.cpp.logdir hplip-3.12.10a/prnt/hpcups/HPCupsFilter.cpp
--- hplip-3.12.10a/prnt/hpcups/HPCupsFilter.cpp.logdir 2012-10-17 09:56:29.391578055 +0100
+++ hplip-3.12.10a/prnt/hpcups/HPCupsFilter.cpp 2012-10-17 09:56:29.397578087 +0100
@@ -31,16 +31,24 @@
\*****************************************************************************/
#include "HPCupsFilter.h"
+#include <limits.h>
#include <signal.h>
+#include <stdlib.h>
#include <sys/wait.h>
#include <sys/utsname.h>
#include <time.h>
#define HP_FILE_VERSION_STR "03.09.08.0"
+char *env_tmpdir = NULL;
+
static HPCupsFilter filter;
int main (int argc, char *argv[])
{
+ env_tmpdir = getenv ("TMPDIR");
+ if (!env_tmpdir)
+ env_tmpdir = "/var/log/hp/tmp";
+
openlog("hpcups", LOG_PID, LOG_DAEMON);
if (argc < 6 || argc > 7) {
@@ -583,9 +591,10 @@ int HPCupsFilter::processRasterData(cups
DRIVER_ERROR err;
int ret_status = 0;
- char hpPreProcessedRasterFile[64]; //temp file needed to store raster data with swaped pages.
+ char hpPreProcessedRasterFile[PATH_MAX]; //temp file needed to store raster data with swaped pages.
- strcpy(hpPreProcessedRasterFile, "/var/log/hp/tmp/hplipSwapedPagesXXXXXX");
+ snprintf(hpPreProcessedRasterFile, sizeof (hpPreProcessedRasterFile),
+ "%s/hplipSwapedPagesXXXXXX", env_tmpdir);
while (cupsRasterReadHeader2(cups_raster, &cups_header))
@@ -647,9 +656,9 @@ int HPCupsFilter::processRasterData(cups
if (m_iLogLevel & SAVE_INPUT_RASTERS)
{
- char szFileName[64];
+ char szFileName[PATH_MAX];
memset(szFileName, 0, sizeof(szFileName));
- snprintf (szFileName, sizeof(szFileName), "/var/log/hp/tmp/hpcupsfilterc_%d.bmp", current_page_number);
+ snprintf (szFileName, sizeof(szFileName), "%s/hpcupsfilterc_%d.bmp", env_tmpdir, current_page_number);
if (cups_header.cupsColorSpace == CUPS_CSPACE_RGBW ||
cups_header.cupsColorSpace == CUPS_CSPACE_RGB)
diff -up hplip-3.12.10a/prnt/hpcups/LJZjStream.cpp.logdir hplip-3.12.10a/prnt/hpcups/LJZjStream.cpp
--- hplip-3.12.10a/prnt/hpcups/LJZjStream.cpp.logdir 2012-10-10 07:08:46.000000000 +0100
+++ hplip-3.12.10a/prnt/hpcups/LJZjStream.cpp 2012-10-17 09:56:29.397578087 +0100
@@ -42,9 +42,12 @@
#include "LJZjStream.h"
#include "Utils.h"
#include "hpjbig_wrapper.h"
+#include <limits.h>
#define ZJC_BAND_HEIGHT 100
+extern char *env_tmpdir;
+
LJZjStream::LJZjStream () : Encapsulator ()
{
memset(&m_PM, 0, sizeof(m_PM));
@@ -675,10 +678,10 @@ DRIVER_ERROR LJZjStream::preProcessRaste
cups_raster_t *even_pages_raster=NULL;
cups_raster_t *odd_pages_raster = NULL;
BYTE* pPageDataBuffer = NULL;
- char hpEvenPagesFile[64];
- char hpOddPagesFile[64];
- snprintf(hpEvenPagesFile, sizeof(hpEvenPagesFile), "%s/hplipEvenPagesXXXXXX","/var/log/hp/tmp");
- snprintf(hpOddPagesFile, sizeof(hpOddPagesFile), "%s/hplipOddPagesXXXXXX", "/var/log/hp/tmp");
+ char hpEvenPagesFile[PATH_MAX];
+ char hpOddPagesFile[PATH_MAX];
+ snprintf(hpEvenPagesFile, sizeof(hpEvenPagesFile), "%s/hplipEvenPagesXXXXXX",env_tmpdir);
+ snprintf(hpOddPagesFile, sizeof(hpOddPagesFile), "%s/hplipOddPagesXXXXXX", env_tmpdir);
if (1 != m_pJA->pre_process_raster || !cups_header.Duplex){
return NO_ERROR;
diff -up hplip-3.12.10a/prnt/hpcups/SystemServices.cpp.logdir hplip-3.12.10a/prnt/hpcups/SystemServices.cpp
--- hplip-3.12.10a/prnt/hpcups/SystemServices.cpp.logdir 2012-10-10 07:08:46.000000000 +0100
+++ hplip-3.12.10a/prnt/hpcups/SystemServices.cpp 2012-10-17 09:56:29.397578087 +0100
@@ -30,14 +30,17 @@
#include "CommonDefinitions.h"
#include "SystemServices.h"
+#include <limits.h>
+
+extern char *env_tmpdir;
SystemServices::SystemServices(int iLogLevel, int job_id) : m_iLogLevel(iLogLevel)
{
m_fp = NULL;
if (iLogLevel & SAVE_PCL_FILE)
{
- char fname[64];
- sprintf(fname, "%s/hpcups_job%d.out", "/var/log/hp/tmp",job_id);
+ char fname[PATH_MAX];
+ sprintf(fname, "%s/hpcups_job%d.out", env_tmpdir, job_id);
m_fp = fopen(fname, "w");
chmod(fname, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
}
diff -up hplip-3.12.10a/prnt/hpijs/hpcupsfax.cpp.logdir hplip-3.12.10a/prnt/hpijs/hpcupsfax.cpp
--- hplip-3.12.10a/prnt/hpijs/hpcupsfax.cpp.logdir 2012-10-10 07:08:50.000000000 +0100
+++ hplip-3.12.10a/prnt/hpijs/hpcupsfax.cpp 2012-10-17 09:56:29.397578087 +0100
@@ -29,6 +29,7 @@
POSSIBILITY OF SUCH DAMAGE.
\*****************************************************************************/
+#include <limits.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
@@ -66,6 +67,7 @@ uint16_t (*convert_endian_s)(uint16_t);
static int iLogLevel = 1;
char hpFileName[64] ;
+static char *env_tmpdir;
#define TIFF_HDR_SIZE 8
#define LITTLE_ENDIAN_MODE I
@@ -439,9 +441,9 @@ int ProcessTiffData(int fromFD, int toFD
int bytes_written = 0;
int ret_status = 0;
int bytes_read = 0;
- char hpTiffFileName[64];
+ char hpTiffFileName[PATH_MAX];
long input_file_size = 0;
- snprintf(hpTiffFileName,sizeof(hpTiffFileName), "%s/hpliptiffXXXXXX","/var/log/hp/tmp");
+ snprintf(hpTiffFileName,sizeof(hpTiffFileName), "%s/hpliptiffXXXXXX",env_tmpdir);
fdTiff = mkstemp (hpTiffFileName);
@@ -656,6 +658,10 @@ int main (int argc, char **argv)
/*********** PROLOGUE ***********/
+ env_tmpdir = getenv ("TMPDIR");
+ if (!env_tmpdir)
+ env_tmpdir = "/var/log/hp/tmp";
+
GetLogLevel();
openlog("hpcupsfax", LOG_PID, LOG_DAEMON);
@@ -679,7 +685,7 @@ int main (int argc, char **argv)
i++;
}
- snprintf(hpFileName,sizeof(hpFileName),"%s/hplipfaxLog_XXXXXX","/var/log/hp/tmp");
+ snprintf(hpFileName,sizeof(hpFileName),"%s/hplipfaxLog_XXXXXX",env_tmpdir);
fdFax = mkstemp (hpFileName);
if (fdFax < 0)
diff -up hplip-3.12.10a/prnt/hpijs/hpijs.cpp.logdir hplip-3.12.10a/prnt/hpijs/hpijs.cpp
--- hplip-3.12.10a/prnt/hpijs/hpijs.cpp.logdir 2012-10-17 09:56:29.390578050 +0100
+++ hplip-3.12.10a/prnt/hpijs/hpijs.cpp 2012-10-17 09:56:29.398578093 +0100
@@ -29,6 +29,7 @@
POSSIBILITY OF SUCH DAMAGE.
\*****************************************************************************/
+#include <limits.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
@@ -43,6 +44,8 @@
#include "hpijs.h"
#include "services.h"
+static char *env_tmpdir;
+
extern void SendDbusMessage (const char *dev, const char *printer, int code,
const char *username, const int jobid, const char *title);
@@ -96,8 +99,8 @@ void setLogLevel(UXServices *pSS)
if (pSS->m_iLogLevel & SAVE_PCL_FILE)
{
- char szFileName[64];
- snprintf (szFileName,sizeof(szFileName), "/var/log/hp/tmp/hpijs_%d.out", getpid());
+ char szFileName[PATH_MAX];
+ snprintf (szFileName,sizeof(szFileName), "%s/hpijs_%d.out", env_tmpdir, getpid());
pSS->outfp = fopen (szFileName, "w");
if (pSS->outfp)
@@ -588,6 +591,10 @@ int main (int argc, char *argv[], char *
int ret, n, i, kn=0, width, k_width;
int low_marker = 0;
+ env_tmpdir = getenv ("TMPDIR");
+ if (!env_tmpdir)
+ env_tmpdir = "/var/log/hp/tmp";
+
openlog("hpijs", LOG_PID, LOG_DAEMON);
if (argc > 1)
@@ -627,8 +634,8 @@ int main (int argc, char *argv[], char *
setLogLevel(pSS);
#ifdef CAPTURE
- char szCapOutFile[64];
- snprintf(szCapOutFile, sizeof(szCapOutFile),"%s/capout_XXXXXX","/var/log/hp/tmp");
+ char szCapOutFile[PATH_MAX];
+ snprintf(szCapOutFile, sizeof(szCapOutFile),"%s/capout_XXXXXX",env_tmpdir);
if ((pSS->InitScript(szCapOutFile, TRUE)) != NO_ERROR)
BUG("unable to init capture");
#endif
diff -up hplip-3.12.10a/prnt/hpijs/hpijsfax.cpp.logdir hplip-3.12.10a/prnt/hpijs/hpijsfax.cpp
--- hplip-3.12.10a/prnt/hpijs/hpijsfax.cpp.logdir 2012-10-10 07:08:50.000000000 +0100
+++ hplip-3.12.10a/prnt/hpijs/hpijsfax.cpp 2012-10-17 09:56:29.398578093 +0100
@@ -31,6 +31,7 @@
#ifdef HAVE_LIBHPIP
+#include <limits.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
@@ -270,14 +271,15 @@ int hpijsFaxServer (int argc, char **arg
IP_IMAGE_TRAITS traits;
IP_HANDLE hJob;
- char hpFileName[64];
+ char hpFileName[PATH_MAX];
int fdFax = -1;
BYTE szFileHeader[68];
BYTE szPageHeader[64];
BYTE *p;
unsigned int uiPageNum = 0;
- snprintf(hpFileName,sizeof(hpFileName),"%s/hplipfaxXXXXXX","/var/log/hp/tmp");
+ snprintf(hpFileName,sizeof(hpFileName),"%s/hplipfaxXXXXXX",
+ getenv ("TMPDIR") ? : "/var/log/hp/tmp");
pFaxStruct = new HPIJSFax ();
diff -up hplip-3.12.10a/prnt/hpps/hppsfilter.c.logdir hplip-3.12.10a/prnt/hpps/hppsfilter.c
--- hplip-3.12.10a/prnt/hpps/hppsfilter.c.logdir 2012-10-17 10:00:07.937687485 +0100
+++ hplip-3.12.10a/prnt/hpps/hppsfilter.c 2012-10-17 10:02:28.968378061 +0100
@@ -48,13 +48,14 @@
#define BOD_PJL "@PJL DMINFO ASCIIHEX=\"%s%s\"\012"
#define BOD_DATETIME_FORMAT "%04d%02d%02d%02d%02d%02d"
#define DBG_PSFILE "hpps_job"
-#define DBG_TMP_FOLDER "/var/log/hp/tmp/"
#define LINE_SIZE 258
#define FILE_NAME_SIZE 128
#define SAVE_PS_FILE 2
+static char *env_tmpdir;
+
/* save final output ps file: in cupsd.conf file value #hpLogLevel 15 */
static int g_savepsfile = 0;
@@ -94,7 +95,7 @@ void open_dbg_outfile(char* szjob_id)
if (g_savepsfile & SAVE_PS_FILE)
{
char sfile_name[FILE_NAME_SIZE] = {0};
- sprintf(sfile_name, "%s/%s_%d.out",DBG_TMP_FOLDER,DBG_PSFILE, szjob_id);
+ sprintf(sfile_name, "%s/%s_%d.out",env_tmpdir,DBG_PSFILE, szjob_id);
g_fp_outdbgps= fopen(sfile_name, "w");
chmod(sfile_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
}
@@ -163,7 +164,11 @@ int main (int argc, char **argv)
{
cups_file_t *fp_input = NULL; /* input file: stdin or physical file */
char line[LINE_SIZE] = {0};
-
+
+ env_tmpdir = getenv ("TMPDIR");
+ if (!env_tmpdir)
+ env_tmpdir = "/var/log/hp/tmp/";
+
get_LogLevel();
setbuf (stderr, NULL);
fprintf (stderr, "HP PS filter starting : %s \n", *argv);