home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
dsque.exe
/
DSSUBJOB.C
< prev
next >
Wrap
Text File
|
1994-10-25
|
7KB
|
264 lines
/****************************************************************************
** File: DSSUBJOB.C
**
** Desc: This program sumbits 3 letter DOS commands to a queue for servicing
** by JSERVER.EXE.
**
**
**
** 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.
**
** Programmers:
**
** Ini Who Firm
** -----------------------------------------------------------------------
** KLB Karl Bunnell Novell Developer Support.
**
** History:
**
** When Who What
** -----------------------------------------------------------------------
** 10-24-94 klb First code.
*/
/****************************************************************************
** Include headers, macros, function prototypes, etc.
*/
/*------------------------------------------------------------------------
** Prototypes
*/
void createDSQueue(char * queueName);
void addOrDeleteInDSQueue(char * queueName);
void createDSQueueServer(char * queueServerName);
/*------------------------------------------------------------------------
** MACROS
*/
#define NWDOS
/*------------------------------------------------------------------------
** ANSI
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <conio.h>
#include <io.h>
/*------------------------------------------------------------------------
** NetWare
*/
#include <nwnet.h>
#include <nwcalls.h>
#include <nwlocale.h>
/*------------------------------------------------------------------------
** Globals
*/
void main()
{
NWDSCCODE dscCode;
NWCCODE cCode;
NWCONN_HANDLE connHandle;
NWOBJ_ID servID;
NWOBJ_ID queueID;
NWFILE_HANDLE filehandle;
NWDSContextHandle dContext;
char inBuf[255];
size_t buflen;
char queueName[MAX_DN_CHARS];
char queueServerName[MAX_DN_CHARS];
NWQueueJobStruct jobStructure;
DWORD flags;
LCONV lconvInfo;
char far *countryPtr;
cCode = NWCallsInit(NULL,NULL);
if (cCode)
{
printf("\nCall to NWCallsInit failed!! Error code %04X\n", cCode);
exit(1);
}
countryPtr = 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);
if(cCode)
{
printf("NWInitUnicodeTables() = %04X\n",cCode);
NWFreeUnicodeTables();
exit(1);
}
dContext = NWDSCreateContext();
if(dContext == ERR_CONTEXT_CREATION)
{
printf("NWDSCreateContext() = %04X\n",dContext);
goto _FreeUnicodeTables;
}
/*----------------------------------------------------------------
** Get the current directory context flags so we can modify them.
*/
dscCode= NWDSGetContext(
/* Contxt Handle */ dContext,
/* Key */ DCK_FLAGS,
/* Context Flags */ &flags
);
if (dscCode< 0)
{
printf("NWDSGetContext returned: %04X\n", cCode);
goto _FreeContext;
}
/*-------------------------------------------------------------------
** Turn typeless naming on.
** Turn canonicalize names off. This means we will get full names.
*/
flags |= DCV_TYPELESS_NAMES;
flags &= ~DCV_CANONICALIZE_NAMES;
/*----------------------------------------------------------------
** Set the directory context flags so they take effect.
*/
dscCode= NWDSSetContext(
/* Context Handle */ dContext,
/* Key */ DCK_FLAGS,
/* Set Flag Value */ &flags
);
if (dscCode< 0)
{
printf("NWDSSetContext returned: %04X\n", cCode);
goto _FreeContext;
}
cCode = NWGetDefaultConnectionID(&connHandle);
if(cCode)
{
printf("Call to NWGetDefaultConnectionID failed!! Error Code %04X\n", cCode);
exit(2);
}
printf("\nA Queue Name is required for this operation!\n");
printf("\nQueue Distinguished Name: ");
gets(queueName);
cCode = NWDSMapNameToID(
/* Context */ dContext,
/* Conn Handle */ connHandle,
/* Object name */ queueName,
/* Queue ID */ &queueID
);
if(cCode)
{
printf("Call to NWMapNameToID failed!! Error Code %04X\n", cCode);
exit(1);
}
printf("\nA Queue Server Name is required for this operation!\n");
printf("\nQueue Server Distinguished Name: ");
gets(queueServerName);
cCode = NWDSMapNameToID(
/* Context */ dContext,
/* Conn Handle */ connHandle,
/* Object name */ queueServerName,
/* Queue ID */ &servID
);
if(cCode)
{
printf("Call to NWMapNameToID failed!! Error Code %04X\n", cCode);
exit(1);
}
jobStructure.targetServerID = servID;
memset(jobStructure.targetExecutionTime,0xFF,6);
jobStructure.jobType = 1234;
jobStructure.jobControlFlags = 0x08;
cCode = NWCreateQueueFile2(
/* Conn Handle */ connHandle,
/* Queue ID */ queueID,
/* Pass Job Struc*/ &jobStructure,
/* File Handle */ &filehandle
);
if(cCode)
{
printf("Call to NWCreateQueueFile2 failed!! Error Code %04X\n", cCode);
exit(4);
}
printf("Please input a three character DOS command :");
scanf("%s",inBuf);
buflen = strlen(inBuf);
write(filehandle,inBuf,buflen);
cCode = NWCloseFileAndStartQueueJob2(
/* Connection Handle */ connHandle,
/* queue ID */ queueID,
/* JobNumber */ jobStructure.jobNumber,
/* File Handle */ filehandle
);
if(cCode)
{
printf("Call to NWCloseFileAndStartQueueJob2 failed!! Error Code %04X\n", cCode);
exit(5);
}
_FreeContext:
NWDSFreeContext(dContext);
_FreeUnicodeTables:
NWFreeUnicodeTables();
}