home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
prtown.exe
/
PRTOWNER.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-01-23
|
7KB
|
237 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: PRTOWNER.C
**
** Desc: Allows the user to find out who owns printjobs in the 4.X
** print queue and what the printjob number is (same number that
** shows up in pconsole).
**
** Programmers:
** Ini Who Firm
** ------------------------------------------------------------------
** ARM A. Ray Maxwell Novell Developer Support.
**
** History:
**
** ------------------------------------------------------------------
** 01-20-95 ARM First code.
*/
/****************************************************************************
** Include headers, macros, function prototypes, etc.
*/
/*------------------------------------------------------------------------
** Macros
*/
#define NWDOS
/*------------------------------------------------------------------------
** ANSI
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h> /* getche() */
#include <mem.h> /* setmem() */
/*------------------------------------------------------------------------
** NetWare
*/
#include <nwnet.h>
#include <nwcalls.h>
#include <nwlocale.h>
extern unsigned _stklen = (1024 * 8);
/****************************************************************************
** Function main() contains the entire program.
**
*/
void main(void)
{
NWDSContextHandle dContext;
NWDSCCODE ccode;
NWCONN_HANDLE connHandle;
NWOBJ_ID objectID;
NWQueueJobStruct job;
NWNUM startPosition=0;
QueueJobListReply jobList;
char *ptr;
char objectName[MAX_DN_CHARS],
queueName[128],
userName[128];
char ch;
WORD listNumber=0;
LCONV lconvInfo;
ccode = NWCallsInit(NULL,NULL);
printf("NWCallsInit() = %04X\n",ccode);
if(ccode)
exit(1);
NWLsetlocale(LC_ALL, "");
printf("\nNWLsetl.. OK");
NWLlocaleconv(&lconvInfo);
printf("\nCountry ID = %03d, Code Page = %04d\n",
lconvInfo.country_id, lconvInfo.code_page);
ccode = NWInitUnicodeTables(lconvInfo.country_id, lconvInfo.code_page);
printf("NWInitUnicodeTables() = %04X\n",ccode);
if(ccode){
NWFreeUnicodeTables();
exit(1);
}
dContext = NWDSCreateContext();
printf("NWDSCreateContext() = %04X\n",dContext);
if(dContext == ERR_CONTEXT_CREATION){
NWFreeUnicodeTables();
NWDSFreeContext(dContext);
exit(1);
}
queueName[0] = '\0';
printf("\nQueue Name: ");
setmem(&job,sizeof(NWQueueJobStruct),'\0');
setmem(&jobList,sizeof(QueueJobListReply),'\0');
ptr = queueName;
do{
ch = getche();
*ptr = ch;
ptr++;
} while (ch != '\r');
ptr = ptr - 1;
*ptr = '\0';
printf("\nAttempting Change User password... \n");
ccode = NWGetNearestDirectoryService(
/* > Connection Handle */ &connHandle
);
printf("\nNWGetNearestDirectoryService returned: %04X\n", ccode);
ccode=NWDSMapNameToID(
/* > NWDSContextHandle */ dContext,
/* > connection handle */ connHandle,
/* > object name */ queueName,
/* < pointer to objectID */ &objectID);
if(ccode){
printf("NWDSMapNameToID returned: %04X\n",ccode);
NWFreeUnicodeTables();
exit(1);
}
ccode=NWGetQueueJobList2(
/* > connection Handle */ connHandle,
/* > bindery object ID */ objectID,
/* > position of netx job */ startPosition,
/* < pointer to array of job nums */ &jobList);
if(ccode){
printf("NWDGetQueueJobList2 returned: %04X\n",ccode);
NWFreeUnicodeTables();
exit(1);
}
if(jobList.totalQueueJobs == 0)
printf("No jobs in queue: program terminated\n");
else
/*-------------------------------------------------------------------
** Read throught the queue jobs in the queue and report back the sub-
** mitters name and the job number.
*/
do{
ccode=NWReadQueueJobEntry2(
/* > connection handle */ connHandle,
/* > objectID */ objectID,
/* > jobNumber */ jobList.jobNumberList[listNumber],
/* < NWQueueJobStruct */ &job);
if(ccode){
printf("NWReadQueueJobEntry2 returned: %04X\n",ccode);
NWFreeUnicodeTables();
exit(1);
}
ccode=NWDSMapIDToName(
/* > context */ dContext,
/* > connection handle */ connHandle,
/* > object ID */ job.clientID,
/* < pointer object distinguished name */ userName);
if(ccode){
printf("NWDSMapIDToName returned: %04X\n",ccode);
NWFreeUnicodeTables();
exit(1);
}
printf(" Jobnumber: %08lX \n",jobList.jobNumberList[listNumber]);
printf(" User submitting job: %s\n",userName);
listNumber++;
}while(listNumber<jobList.totalQueueJobs);
NWFreeUnicodeTables();
NWDSFreeContext(dContext);
}