Dear List readers,
I discovered the new 'pjl_ready_msg' to set the ready msg of hp
printers - nice stuff !
This should be also possible for the JOB display message - so
I implemented this with the appended patch, which unifies
the building of the DISPLAY string. Maybe there are other places
(while doing accounting?) to insert this. Works rather nicely
here, now.
One thing which would be very helpfull to use the 32 chars
display of my hp4050 would be a formatting sequence to
cut out the last n chars of a string - the first N chars works
good with the following formatting:
\%N.Ns{var}
I tried several variations with no success - is it possible
with the current code ?
Some comments on the processing of the status messages from the
printer:
1) Is it possible to extract PJL and PS status together ? At the
moment it look like this is not possible together, and my
printer delivers sometimes nice page counts during processing
of a pjl encapsulated ps job.
2) Is it possible to get the full status returns from the printers
at stderr, separated from the normal ifhp output which goes
to the status file (or to a separate file) ? Is it possible to
redirect only debug messages
to stderr ?
In my opinion that would be nice options, as the "lpq -l" output
looks rather ugly with debugging enabled.
Many thanks for all the work on ifhp - it can do rather impressive
things already.
Greetings
Hermann
--
Bildverarbeitungsgruppe des Interdiziplinaeren Zentrums fuer
wissenschaftliches Rechnen, Universitaet Heidelberg
INF 368; 69120 Heidelberg; Tel: (06221)54-8826, -6314 Fax: -8850
Email: [EMAIL PROTECTED]
--- ifhp-3.4.3/src/ifhp.c.orig Thu Nov 30 19:09:44 2000
+++ ifhp-3.4.3/src/ifhp.c Tue Dec 19 18:35:16 2000
@@ -2453,6 +2453,49 @@
return(1);
}
+/* by hlauer:
+ * Use a common subroutine to build DISPLAY part - the job start
+ * could use this too.
+ * if console@, returns an empty string
+ */
+
+static char *Pjl_displaystring(void)
+{
+ static char buffer[SMALLBUFFER];
+ char *s, name[SMALLBUFFER];
+
+ buffer[0]=0;
+ s="";
+ if( Pjl != 0 && Pjl_console != 0 ){
+ if( Pjl_ready_msg ){
+ DEBUG2("Pjl_console: pjl_ready_msg '%s'", Pjl_ready_msg);
+ s = Fix_option_str( Pjl_ready_msg, 0, 1, 1);
+ if( s ){
+ SNPRINTF(name,sizeof(name)) "%s", s);
+ free(s); s = 0;
+ s = name;
+ }
+ }
+ if( !s ) s = Loweropts['n'-'a']; /* try to get user or jobname */
+ if( !s ) s = Upperopts['J'-'A'];
+ if( !s ){
+ s = name;
+ SNPRINTF(name,sizeof(name)) "PID %d", getpid());
+ }
+ if( Pjl_display_size > 0 && strlen(s) > Pjl_display_size ){
+ if( s != name){ /* Avoid changing option space */
+ SNPRINTF(name,sizeof(name)) "%s", s);
+ s=name;
+ }
+ if(sizeof(name)>Pjl_display_size) s[Pjl_display_size] = 0;
+ }
+ SNPRINTF(buffer, sizeof(buffer)) " DISPLAY = \"%s\" ",s);
+/* is the space after the closing " needed ? */
+ return buffer;
+ }
+ return s;
+}
+
/*
* int Pjl_job()
* - put out the JOB START string
@@ -2482,16 +2525,9 @@
SNPRINTF(Jobname, sizeof(Jobname)) "PID %d", getpid() );
SNPRINTF(buffer, sizeof(buffer)) Jobstart_str, Jobname );
- if( Pjl_console ){
- DEBUG2("Pjl_job: pjl_console '%d'", Pjl_console );
- s = Loweropts['n'-'a'];
- if( !s ) s = Upperopts['J'-'A'];
- if( !s ) s = "????";
- if( s ){
- len = strlen(buffer);
- SNPRINTF(buffer+len, sizeof(buffer)-len) Job_display, s );
- }
- }
+ s=Pjl_displaystring();
+ len = strlen(buffer);
+ SNPRINTF(buffer+len, sizeof(buffer)-len) "%s", s );
if( (s = Find_exists_value( &Zopts, "startpage", Value_sep))
|| (s = Find_exists_value( &Topts, "startpage", Value_sep)) ){
@@ -2544,37 +2580,19 @@
* console@ disables or erases messages on console
*/
- char *PJL_RDYMSG_str = "@PJL RDYMSG DISPLAY = \"%s\" ";
+ char *PJL_RDYMSG_str = "@PJL RDYMSG%s";
void Pjl_console_msg( int start )
{
- char *s, buffer[SMALLBUFFER], name[SMALLBUFFER];
+ char *s, buffer[SMALLBUFFER];
DEBUG2("Pjl_console: flag %d, start %d, ", Pjl_console, start );
if( Pjl == 0 || Pjl_console == 0 ){
return;
}
- s = 0;
- if( start ){
- if( Pjl_ready_msg ){
- DEBUG2("Pjl_console: pjl_ready_msg '%s'", Pjl_ready_msg);
- s = Fix_option_str( Pjl_ready_msg, 0, 1, 1);
- if( s ){
- SNPRINTF(name,sizeof(name)) "%s", s);
- free(s); s = 0;
- s = name;
- }
- }
- if( !s ) s = Loweropts['n'-'a'];
- if( !s ) s = Upperopts['J'-'A'];
- if( !s ){
- s = name;
- SNPRINTF(name,sizeof(name)) "PID %d", getpid());
- }
- if( Pjl_display_size > 0 && strlen(s) > Pjl_display_size )
s[Pjl_display_size] = 0;
- } else {
- s = "";
- }
+ s = " DISPLAY = \"\" ";
+ if( start ) s = Pjl_displaystring();
+
DEBUG2("Pjl_console: console msg '%s'", s);
SNPRINTF(buffer, sizeof(buffer)) PJL_RDYMSG_str, s );
Put_pjl( buffer );
@@ -2940,16 +2958,11 @@
Put_outbuf_str( PJL_str );
if( use_job ){
SNPRINTF(buffer, sizeof(buffer)) Jobstart_str, Jobname );
- if( Pjl_console ){
- DEBUG2("Pjl_job: pjl_console '%d'", Pjl_console );
- s = Loweropts['n'-'a'];
- if( !s ) s = Upperopts['J'-'A'];
- if( !s ) s = "????";
- if( s ){
- len = strlen(buffer);
- SNPRINTF(buffer+len, sizeof(buffer)-len)
Job_display, s );
- }
- }
+
+ s=Pjl_displaystring();
+ len = strlen(buffer);
+ SNPRINTF(buffer+len, sizeof(buffer)-len) "%s", s );
+
Put_pjl(buffer);
Put_pjl( PJL_USTATUS_JOB_str );
Pjl_eoj();