home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
prtinf.exe
/
RDINFO.C
< prev
next >
Wrap
Text File
|
1995-07-25
|
10KB
|
280 lines
/****************************************************************************
** DISCLAIMER
**
** Novell, Inc. makes no representations or warranties with respect to
** any NetWare software, and specifically disclaims any express or
** implied warranties of merchantability, title, or fitness for a
** particular purpose.
**
** Distribution of any NetWare software is forbidden without the
** express written consent of Novell, Inc. Further, Novell reserves
** the right to discontinue distribution of any NetWare software.
**
** Novell is not responsible for lost profits or revenue, loss of use
** of the software, loss of data, costs of re-creating lost data, the
** cost of any substitute equipment or program, or claims by any party
** other than you. Novell strongly recommends a backup be made before
** any software is installed. Technical support for this software
** may be provided at the discretion of Novell.
****************************************************************************
**
** File: QINFO.C
**
** Desc: This program will read a print queue for jobs and then print
** out some information that is seen on the screen in pconsole.
** NOTE: This code is used principally to show how the job number is
** derived in pconsole and also to show the job status.
**
** Parameter descriptions: > input
** < output
**
**
** Programmers:
** Ini Who Firm
** ------------------------------------------------------------------
** ARM A. Ray Maxwell Novell Developer Support.
**
** History:
**
** ------------------------------------------------------------------
** 07-25-95 ARM First code.
*/
/***************************************************************************
** Include headers, macros, function prototypes, etc.
*/
/*------------------------------------------------------------------
** ANSI
*/
#include <stdlib.h> /* exit(), atol() */
#include <stdio.h>
#include <string.h> /* strupr(), strcpy */
/*------------------------------------------------------------------
** NetWare
*/
#include <nwcalls.h>
/*------------------------------------------------------------------
**Defines
*/
#define NWDOS
#define OPEN 1
#define HELD 2
#define ACTIVE 3
#define READY 4
#define WAITING 5
/*------------------------------------------------------------------
** Prototypes
*/
int GetJobStatus(BYTE JobControlFlags,
BYTE targetTime[],
long serverID,
NWCONN_HANDLE connHandle);
/*------------------------------------------------------------------
** Global Variables
*/
/*========================================================
This structure is overlayed on the QMS
NWQueueJobStruct.clientRecordArea to define a print job.
It is not used in any of the print services APIs.
(Formerly called NWPS_PJob.)
NOTE: This structure is defined in the NWPS_JOB.H header file and
is included here to show the devoloper how it can be used.
========================================================*/
typedef struct {
BYTE versionNumber;
BYTE tabSize;
WORD numberOfCopies;
WORD printControlFlags;
WORD maxLinesPerPage;
WORD maxCharsPerLine;
BYTE formName[13];
BYTE reserve[9];
BYTE bannerNameField[13];
BYTE bannerFileField[13];
BYTE headerFileName[14];
BYTE directoryPath[80];
} NWPS_ClientRecord;
/****************************************************************************
** Program Start
*/
void main(int argc, char *argv[])
{
QueueJobListReply job;
NWCONN_NUM connNumber;
NWNUM startPosition = 0;
NWQueueJobStruct queueJob;
NWCONN_HANDLE connHandle;
NWOBJ_ID queObjectID;
NWCCODE ccode;
NWPS_ClientRecord *clientRecord;
char server[50];
char queObjectName[50];
char statusString[8];
int i;
int status;
if(argc != 3) {
printf("Usage: QINFO <servername> <queue name>\n");
exit(1);
}
strcpy(server, strupr(argv[1]));
strcpy(queObjectName, strupr(argv[2]));
ccode = NWCallsInit(NULL, NULL);
if(ccode)
{
printf("NWCallsInit failed %X\n",ccode);
exit(1);
}
ccode = NWGetConnectionHandle(
/* > servername */ server,
/* Novell Reserved1 */ 0,
/* < connection Handle */ &connHandle,
/* Novell Reserved2 */ NULL);
if(ccode)
{
printf("NWGetConnectionHandle failed: %X\n",ccode);
exit(1);
}
ccode = NWGetConnectionNumber(connHandle,&connNumber);
if(ccode)
{
printf("NWGetConnectionNumber failed: %X\n",ccode);
exit(1);
}
ccode = NWGetObjectID(
/* > connection Handle */ connHandle,
/* > connection Handle */ queObjectName,
/* > Pointer to name of object */ OT_PRINT_QUEUE,
/* < Pointer to the found object ID*/ &queObjectID);
if(ccode)
{
printf("NWGetObjectID failed: %X\n",ccode);
exit(1);
}
ccode = NWGetQueueJobList2(
/* > connection Handle */ connHandle,
/* > bindery object ID */ queObjectID,
/* > position of next job */ startPosition,
/* < Pointer to array of job nums */ &job);
if(ccode)
{
printf("NWGetQueueJobList2 failed: %X\n",ccode);
exit(1);
}
printf("Print Job Status\n\n");
printf("Seq BannerName Description Form Status Job\n");
clientRecord=(NWPS_ClientRecord *) queueJob.clientRecordArea;
for(i=0;i<job.totalQueueJobs;i++)
{
ccode = NWReadQueueJobEntry2(
/* > connection Handle */ connHandle,
/* > bindery object ID of queue */ queObjectID,
/* > Number of Job being read */ job.jobNumberList[i],
/* < Pointer to NWQueueJobStruct */ &queueJob);
if (ccode)
{
printf("NWReadQeueueJobEntry2 failed: %X\n",ccode);
exit(1);
}
status=GetJobStatus(queueJob.jobControlFlags,
queueJob.targetExecutionTime,
queueJob.servicingServerID,
connHandle);
switch(status)
{
case OPEN : strcpy(statusString,"OPEN");
break;
case HELD : strcpy(statusString,"HELD");
break;
case ACTIVE : strcpy(statusString,"ACTIVE");
break;
case READY : strcpy(statusString,"READY");
break;
case WAITING : strcpy(statusString,"WAITING");
break;
default : break;
}
/*-----------------------------------------------------------------------
** Note the jobNumber is WordSwapped and then printed with %5u.
*/
printf("%d %s %s %d %s %5u\n",
queueJob.jobPosition,
clientRecord->bannerNameField,
queueJob.jobDescription,
queueJob.jobType,
statusString,
NWWordSwap(queueJob.jobNumber));
}
}
/***************************************************************************
** Get the job status
*/
int GetJobStatus(BYTE jobControlFlags,
BYTE targetTime[],
long serverID,
NWCONN_HANDLE connHandle)
{
BYTE currentTime[7]; /* Current time from server */
int status, /* Status of this job */
printNow; /* To be printed as soon as possible? */
/*-----------------------------------------------------------------------
** Is the job still open?
*/
if (jobControlFlags & QF_ENTRY_OPEN)
status = OPEN;
/*-----------------------------------------------------------------------
** Is the job on hold?
*/
else if (jobControlFlags & (QF_OPERATOR_HOLD | QF_USER_HOLD))
status = HELD;
/*-----------------------------------------------------------------------
** Is the job active?
*/
else if (serverID != 0L)
status = ACTIVE;
/*-----------------------------------------------------------------------
The job is either ready or waiting. Assume its ready unless
there is a target time and that time has not arrived yet.
*/
else
{
status = READY;
printNow = memcmp(targetTime, "\xff\xff\xff\xff\xff\xff", 6 ) == 0;
if (!printNow)
{
NWGetFileServerDateAndTime(connHandle, currentTime);
if (memcmp(currentTime, targetTime, (WORD)6) < 0)
status = WAITING;
}
}
return (status);
}