home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
qinfo.exe
/
GETQINFO.C
next >
Wrap
Text File
|
1995-01-11
|
9KB
|
294 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: GETQINFO.C
**
** Desc: This program will read the bindery of the default server into
** a linked list. It will then (using the linked list) read the
** servers one at a time and attach to each server in the list and
** find the print servers on that server. It will write the server
** names to a file call SERVERS.TXT and the print servers to
** QUEINFO.TXT along with the print servers object ID.
**
** Programmers:
** Ini Who Firm
** ------------------------------------------------------------------
** ARM A. Ray Maxwell Novell Developer Support.
**
** History:
**
** ------------------------------------------------------------------
** 1-10-95 ARM First code.
*/
/***************************************************************************
** Include headers, macros, function prototypes, etc.
*/
/*------------------------------------------------------------------
** ANSI
*/
#include <stdlib.h> /* exit(), atol() */
#include <stdio.h> /* fprintf() */
#include <string.h>
#include <malloc.h>
#include <mem.h>
#include <conio.h> /* kbhit() */
#define slot 100
/*------------------------------------------------------------------
** NetWare
*/
#include <nwcalls.h>
#include <nwlocale.h>
#include <nwnet.h>
#include <nwndscon.h>
#include <nwerror.h>
#define NWDOS
/*------------------------------------------------------------------
** Gobal parameters
*/
struct {
BYTE accountExpiraionDate[3];
BYTE accountDisableFlag;
BYTE passwordExpiraionDate[3];
BYTE graceLogin;
WORD passwordExpirationIntervals;
BYTE graceLoginResetValue;
BYTE minPasswordLength;
WORD maxConcurrentConnections;
BYTE allowedLoginTimeBitmap[42];
BYTE lastLoginDateTime[6];
BYTE restrictionFlags;
BYTE reserved;
DWORD maxDiskUsageInBlocks;
WORD badLoginCount;
DWORD nextResetTime;
BYTE badLoginAddr[12];
BYTE padding[43];
} loginControl;
typedef struct list {
char Fserver[48];
NWOBJ_ID ObjectID;
struct list *link;
} Slist;
typedef Slist *fptr; // struct variable ServerList
fptr ptr = NULL;
fptr p1 = NULL;
fptr p2 = NULL;
/*****************************************************************************
** Program Start
*/
void main(void)
{
WORD ccode; /* value for return code */
WORD defaultID, connID1,connID2,connID3,tempConn;
NWOBJ_ID objectID = -1; /* same as unsigned int */
char objectName[48];
char searchObjectName[48];
NWOBJ_TYPE objType;
NWFLAGS NWFAR *hasPropertiesFlag;
NWFLAGS objFlag;
NWFLAGS objSec;
NWLOCAL_MODE mode = 0; /* NWGetConnectionList stuff */
NWCONN_HANDLE *connListBuffer;
NWSTRUCT_SIZE connListSize;
NWNUMBER NWFAR *numConnections;
NWNUMBER maxConns = 8;
WORD connType;
CONNECT_INFO connInfo;
NWSTRUCT_SIZE connInfoSize;
DWORD NWFAR *seq = -1;
char NWFAR *queueName;
int True = 0;
int n = 0;
FILE *fp, *fp1;
ptr = (fptr)calloc(sizeof(Slist),1);
ptr->link = NULL;
p1 = ptr;
fp=fopen("servers.txt","w+");
fp1=fopen("queinfo.txt","w+");
ccode = NWCallsInit(NULL,NULL);
if (ccode)
printf("NWCallsInit failed\n");
ccode = NWGetDefaultConnectionID(&defaultID);
if(ccode){
printf("\n Error in getting connection ID: %x\n", ccode);
exit(0);
}
/*-----------------------------------------------------------------------
** Get the print server names and object ID's.
*/
while ( !ccode) {
ccode = NWScanObject (defaultID,
"*",
OT_FILE_SERVER,
&objectID,
objectName,
&objType,
&hasPropertiesFlag,
&objFlag,
&objSec );
if (ccode) {
printf("NWScanObject failed: %x\n", ccode);
break; // exit(0);
}
if(objType == OT_FILE_SERVER) {
printf("Server Name: %s ObjectID: %08lX\n",
objectName,NWLongSwap(objectID));
strcpy(p1->Fserver,objectName);
p1->ObjectID = objectID;
p2 = (fptr)malloc(sizeof(struct list));
p2->link = NULL;
p1->link = p2;
p1 = p2;
}
}/* end while */
/*-----------------------------------------------------------------------
** Check the linklist and print it to the file server.txt
*/
printf("\n\n");
p1 = ptr;
do {
printf("ServerName : %s , ID : %08lX\n",p1->Fserver, NWLongSwap(p1->ObjectID));
fprintf(fp,"ServerName : %s , ID : %08lX\n",p1->Fserver, NWLongSwap(p1->ObjectID));
p1 = p1->link;
} while(p1->link != NULL);
fclose(fp);
printf("\n\n");
// Preparing for Scan
objectID = -1L;
printf("\nPRNCODE ...ver 1.3d\n");
ccode = 0;
p1 = ptr;
while (p1->link != NULL && (!kbhit())) {
ccode = NWAttachToFileServer( p1->Fserver,
NULL,
&connID1);
printf("\nNWAttach... %s, %x",p1->Fserver,ccode);
switch(ccode){
case 0x0000 : printf("Attach Successful on %s\n",p1->Fserver);
break;
case 0x8800 : printf("Already attached to %s\n",p1->Fserver);
break;
case 0x8801 : printf("Invalid Connection to %s\n",p1->Fserver);
break;
case 0x8847 :
case 0x89FC : printf("Unknown or no server found\n");
break;
default : break;
}
if(ccode==0x0000){
ccode = NWGetConnectionHandle(p1->Fserver,
NULL,
&connID1,
NULL);
if (ccode)
printf("\nNWGetConnHandle failed... %x on %s\n",ccode,p1->Fserver);
}
if (ccode==0x0000 || ccode==0x8800){
ccode = NWGetConnectionStatus(connID1,
&connInfo,
connInfoSize);
if (ccode)
printf("\nGet Conn Status failed... %x\n",ccode);
if (connInfo.connectFlags & CONNECTION_NDS) {
printf("\nAn NDS connection is already established to %s.\n",
p1->Fserver);
exit(0);
}
while ( True == 0 && (!kbhit())) {
ccode = NWScanObject ( connID1,
"*",
OT_WILD,
&objectID,
objectName,
&objType,
&hasPropertiesFlag,
&objFlag,
&objSec );
if (objType == OT_PRINT_QUEUE)
fprintf(fp1,"PrnQ: %s Server: %s ccode: %4x Object ID %08Xl\n",
objectName,p1->Fserver,ccode,NWLongSwap(objectID));
else if(ccode){
fprintf(fp1,"NWScanObject failed : %X\n",ccode);
True=-1;
}
}
ccode = NWGetConnectionStatus(connID1,
&connInfo,
sizeof(CONNECT_INFO));
if (ccode)
printf("\nGet Conn Status failed... %x\n",ccode);
if (connInfo.connectFlags & CONNECTION_NDS) {
printf("\nAn NDS connection is already established to %s.\n",
p1->Fserver);
exit(0);
}
if (connInfo.connectFlags & CONNECTION_LOGGED_IN)
printf("this is the default server\n");
else
ccode = NWDetachFromFileServer(connID1);
}
else
fprintf(fp,"\nserver %s could not be found\n",p1->Fserver);
p1 = p1->link;
objectID = -1L;
True = 0;
}
if (p1->link == NULL)
printf("\nEndOfLList, NULL encountered");
else printf("\n leavingPGM.. last server used: %s, ccode: %4x" ,
p1->Fserver,ccode);
free(ptr);
fcloseall();
} /* end of main */