home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
xqms1.exe
/
SUBMTJOB.C
next >
Wrap
C/C++ Source or Header
|
1995-08-25
|
7KB
|
248 lines
/**************************************************************************
** File: submtjob.c
**
** Desc: Sample NLM to submit a print job to a queue
**
**
** 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.
**
** QMK386 Options
** none
**
** Programmers:
**
** Ini Who Firm
** ---------------------------------------------------------------------
** DWH Dirk W. Howard Novell Developer Support
**
**
** History:
**
** When Who What
** ---------------------------------------------------------------------
** 8-11-1995 DWH First code.
**
*/
/****************************************************************************
** Include headers, macros, etc.
*/
/*------------------------------------------------------------------------
** ANSI C.
*/
#include <stdlib.h> /* exit() */
#include <stdio.h> /* printf() */
#include <string.h> /* strupr() */
#include <io.h> /* write() */
#include <conio.h> /* clrscr() */
#include <errno.h>
/*------------------------------------------------------------------------
** NetWare Library
*/
#include <nwqueue.h>
#include <nwps_job.h>
#include <nwbindry.h>
#include <nwmisc.h>
/****************************************************************************
** Global variables.
*/
/****************************************************************************
** Main program start.
*/
void main(int argc, char *argv[]){
int ccode;
LONG printQID;
NWQJobRec_t jobInfo;
int jobFile;
NWPS_ClientRecord *psInfo; /* this is the struct pointer for the
clientRecordArea in jobInfo */
char queueName[48];
if (argc < 2){
clrscr();
printf( "USAGE: LOAD %s <queueName>\n", argv[0] );
goto EXIT;
}
strcpy( queueName,strupr( argv[1] ) );
/*------------------------------------------------------------------------
** Get the object ID for the desired print queue to print to.
*/
ccode = GetBinderyObjectID(
/* > objectName */ queueName,
/* > objectType */ OT_PRINT_QUEUE,
/* < objectID */ (long *)&printQID);
switch(ccode)
{
case ESUCCESS:
break;
default:
printf("ERROR: Unknown error GetBinderyObjectID: %d\n", ccode);
goto EXIT;
}
/*------------------------------------------------------------------------
** Fill out jobInfo structure.
*/
memset(&jobInfo, 0x00, sizeof(jobInfo)); /* zero out structure */
/*------------------------------------------------------------------------
** Wildcard: any print server may service this job.
*/
jobInfo.target.id = 0xFFFFFFFFL;
memset(&jobInfo.target.executionTime, 0xFF, 6); /* 0xFFFFFFFFFFFF: ASAP */
jobInfo.job.controlFlags |= 0x10;
/*------------------------------------------------------------------------
** Fill out NetWare Print Server specific information in the clientRecord
** Area of the jobInfo structure.
*/
psInfo = (NWPS_ClientRecord *)(jobInfo.jobServerRecord);
psInfo->versionNumber = 0;
psInfo->tabSize = 8;
psInfo->numberOfCopies = IntSwap(1);
psInfo->printControlFlags = NWPS_JOB_NO_FORMFEED;
psInfo->maxLinesPerPage = IntSwap(66);
psInfo->maxCharsPerLine = IntSwap(132);
psInfo->formName[0] = '\0';
/* psInfo->reserved[9]; */
strcpy(psInfo->bannerNameField,"BannerName");
strcpy(psInfo->bannerFileField,"BannerFile");
strcpy(psInfo->headerFileName, "HeaderName");
psInfo->directoryPath[0] = '\0';
/*------------------------------------------------------------------------
** Create a queue file using the known ID and connection handle
*/
ccode=NWQCreateJob(
/* > queueID */ printQID,
/* <> jobStructure */ &jobInfo,
/* < fileHandle */ &jobFile
);
switch(ccode)
{
case ESUCCESS:
break;
case 0xD3:
printf("ERROR: NO rights to print queue: %s.\n", queueName);
goto EXIT;
default:
printf("ERROR: Unknown error NWCreateQueueFile2: 0x%04X\n", ccode);
goto EXIT;
}
/*------------------------------------------------------------------------
** Print job
*/
write(jobFile,"this is a test",14);
/*------------------------------------------------------------------------
** Close print job now that data has been sent.
*/
ccode=NWQMarkJobForService(
/* > queueID */ printQID,
/* > jobNumber */ jobInfo.job.num,
/* > fileHandle */ jobFile);
switch(ccode)
{
case ESUCCESS:
break;
case 0x99:
printf("ERROR: Queue directory full.\n");
break;
case 0xD0:
printf("ERROR: Queue I/O failure.\n");
break;
case 0xD1:
printf("ERROR: No such queue.\n");
break;
case 0xD2:
printf("ERROR: No queue server.\n");
break;
case 0xD3:
printf("ERROR: NO rights to print in queue.\n");
break;
case 0xD4: /* ERR_QUEUE_FULL */
printf("ERROR: Print queue full.\n");
break;
case 0xD5:
printf("ERROR: Invalid job number specified.\n");
break;
case 0xD6:
printf("ERROR: NO rights to place a job into this queue\n.");
break;
case 0xD7:
printf("ERROR: Queue being serviced now and not accepting jobs\n.");
break;
case 0xD8:
printf("ERROR: Queue currently not active and not accepting jobs\n.");
break;
case 0xD9:
printf("ERROR: The Queue Station is not a Server\n.");
break;
case 0xDA:
printf("ERROR: Queue is currently halted and not accepting jobs\n.");
break;
case 0xDB:
printf("ERROR: Too many servers\n.");
break;
case 0xFF:
printf("ERROR: General failure NWQMarkJobForService\r\n.");
break;
default:
printf("Unknown error NWQMarkJobForService: %d\n", ccode);
break;
}
EXIT:
return;
}