home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
crprnt.exe
/
CRPRINT.C
next >
Wrap
C/C++ Source or Header
|
1995-04-14
|
7KB
|
192 lines
/****************************************************************************
** File:CRPRINT.C
**
** Description:
**
** CRPRINT.C uses many of the NWPSCfg calls to create a printserver,
** queue, and printer in the current context. An operator is added to the
** queue and a person to be notified is added to the printer. A printer configuration
** is added to the printer.
**
** 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
** -----------------------------------------------------------------------
** MDP Marina D Pimentel Novell Developer Support
**
** History:
**
** When Who What
** -----------------------------------------------------------------------
** 04-14-95 MDP First code.
**
*/
/*---------------------------------------------------------------------------
** Include headers, macros, structures, typedefs, etc.
*/
#define NWDOS
#include <stdio.h>
#include <string.h>
#include <nwcalls.h>
#include <nwnet.h>
#include <nwpsrv.h>
#include <stdlib.h>
extern _stklen = (8 * 1024U);
/*---------------------------------------------------------------------------
** Program start.
*/
void main(void)
{
NWDSContextHandle context;
WORD ccode;
char buffer[48];
char pserver[48],
queue[48],
printer[48],
notify[48],
oper[48];
Typed_Name_T *notifyTypedName;
NWPS_Typed_Name notifyType,
operatorType;
WORD printerNum=0xFFFF;
Octet_String_T *octet;
NWPS_PConfig *pconfig;
ccode=NWCallsInit(NULL,NULL);
if(ccode)
printf("NWCallsInit returned a [%x]\n",ccode);
ccode=NWInitUnicodeTables(001,437) ;
if(ccode)
printf("NWInitUnicodeTables returned a [%x]\n",ccode);
context=NWDSCreateContext();
if(context==ERR_CONTEXT_CREATION)
printf("Could not create context\n");
/*----------------------------------------------------------------------------
** NWPSCfgAddPrintServer() adds a print server to the fileserver.
*/
printf("Please enter the name of the printserver you wish to create.\n");
gets(buffer);
strcpy(pserver,strupr(buffer));
ccode=NWPSCfgAddPrintServer(NWPS_DIRECTORY_SERVICE,context,pserver);
if(ccode)
printf("NWPSCfgAddPrintServer returned a [%x]\n",ccode);
/*----------------------------------------------------------------------------
** NWPSCfgAddPrintQueue() adds a print queue to the fileserver.
*/
printf("Please enter the name of the queue you wish to create.\n");
gets(buffer);
strcpy(queue,strupr(buffer));
ccode=NWPSCfgAddPrintQueue(NWPS_DIRECTORY_SERVICE,context,queue,"FELIZ4_SYS" );
if(ccode)
printf("NWPSCfgAddPrintQueue returned a [%x]\n",ccode);
ccode=NWPSCfgAddPrintQueueAttr(NWPS_DIRECTORY_SERVICE,context,queue,NWPS_ATTR_HOST_SER,"FELIZ4");
if(ccode)
printf("NWPSCfgAddPrintQueueAttr returned [%x]\n");
/*----------------------------------------------------------------------------
** NWPSCfgAddPrintQueueAttr() adds a print queue attribute to the print queue.
** In this case, the attribute is the name of a queue operator.
*/
printf("Please enter the name of the queue operator.\n");
gets(buffer);
strcpy(oper,strupr(buffer));
operatorType.objectType=OT_USER;
operatorType.tName=oper;
ccode=NWPSCfgAddPrintQueueAttr(NWPS_DIRECTORY_SERVICE,context,queue,NWPS_ATTR_OPER,&operatorType);
if(ccode)
printf("NWPSCfgAddPrintQueueAttr returned a [%x]\n",ccode);
/*----------------------------------------------------------------------------
** NWPSCfgAddPrinter() adds a printer to the print server. Having set
** printerNum to -1, the printer number that will be returned is the next
** printer number available for that print server.
*/
printf("Please enter the name of the printer you wish to create.\n");
gets(buffer);
strcpy(printer,strupr(buffer));
ccode=NWPSCfgAddPrinter(NWPS_DIRECTORY_SERVICE,context,pserver,printer,&printerNum);
if(ccode)
printf("NWPSCfgAddPrinter returned a [%x]\n",ccode);
/*----------------------------------------------------------------------------
** NWPSCfgAddPrinterAttr() adds a printer attribute to the printer. In this
** case, the printer attribute is the name of a person to be notified
** when problems arise with the printer.
*/
printf("Please enter the name of person to notify if printer problems.\n");
gets(buffer);
strcpy(notify,strupr(buffer));
notifyTypedName=(Typed_Name_T*)malloc(sizeof(Typed_Name_T));
notifyTypedName->objectName=notify;
notifyTypedName->level=1;
notifyTypedName->interval=1;
notifyType.objectType=OT_USER;
notifyType.tName=notifyTypedName;
ccode=NWPSCfgAddPrinterAttr(NWPS_DIRECTORY_SERVICE,context,pserver,printer,NWPS_ATTR_NOTIFY,¬ifyType);
if(ccode)
printf("NWPSCfgAddPrinterAttr returned a [%x]\n",ccode);
/*----------------------------------------------------------------------------
** NWPSCfgGetPrinterDefaults() returns the printer defaults of the
** printer type. In this case, printerType has been defined as a
** serial printer. Thus, this call returns the printer defaults
** associated with a serial printer.
*/
octet=malloc(sizeof(NWPS_PConfig)+sizeof(Octet_String_T));
octet->data=(BYTE *)(octet+1);
pconfig=(NWPS_PConfig *)octet->data;
pconfig->printerType=NWPS_P_SER;
ccode=NWPSCfgGetPrinterDefaults(pconfig->printerType,0,pconfig);
if(ccode)
printf("NWPSCfgGetPrinterDefaults returned a [%x]\n",ccode);
/*----------------------------------------------------------------------------
** This call to NWPSCfgAddPrinterAttr() adds the printer attribute of the
** printer configuration.
*/
ccode=NWPSCfgAddPrinterAttr(NWPS_DIRECTORY_SERVICE,context,pserver,printer,NWPS_ATTR_CONF,octet);
if(ccode)
printf("NWPSCfgAddPrinterAttr returned a [%x]\n",ccode);
free(notifyTypedName);
free(octet);
NWFreeUnicodeTables();
NWDSFreeContext(context);
}