home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
srchdr.exe
/
SRCHDR.C
next >
Wrap
C/C++ Source or Header
|
1995-08-21
|
7KB
|
184 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:Dsearch.C
**
** Desc: This program will use the NWFileSearchInitialize and
** NWIntSearchContinue functions to get Directory Information from
** the specified directory.
**
**
** Programmers:
** Ini Who Firm
** ------------------------------------------------------------------
** ARM A. Ray Maxwell Novell Developer Support.
**
** History:
**
** ------------------------------------------------------------------
** 08-16-95 ARM First code.
*/
/***************************************************************************
** Include headers, macros, function prototypes, etc.
*/
/*------------------------------------------------------------------
** ANSI
*/
#include <stdlib.h> /* exit(), atol() */
#include <stdio.h> /* printf() */
#include <string.h> /* strcpy() */
#include <conio.h> /* clrscr() */
#include <mem.h> /* memset() */
/*------------------------------------------------------------------
** NetWare
*/
#include <nwcalls.h>
#define MAX_BUFFER_LENGTH 80
/****************************************************************************
** Program Start
*/
void main(int argc, char *argv[])
{
NWDIR_HANDLE dirHandle;
NWCONN_HANDLE connHandle;
NWCCODE ccode;
NWPATH_VOL volNumber;
NWSEQUENCE_NUM sequenceNumber;
NWACCESS_RIGHTS dirAccessRights;
NWDIR_NUM dirID;
NWSEARCH_ATTR searchAttributes; /* SA_SUBDIR_ONLY */
char path[256];
char newName[32];
char pathString[256] = "";
char serverName[48];
BYTE buffer [MAX_BUFFER_LENGTH];
SEARCH_DIR_INFO *dirInfo;
/*-----------------------------------------------------------------------
** Memory Allocation for struct
*/
dirInfo = ( SEARCH_DIR_INFO * ) malloc(sizeof( struct SEARCH_DIR_INFO ));
dirInfo = ( SEARCH_DIR_INFO * ) buffer;
/*-----------------------------------------------------------------------
** Set Search Attributes
*/
searchAttributes=0;
searchAttributes|=SA_SUBDIR_ONLY;
if(argc < 2)
{
clrscr();
printf("Usage: SRCHDR <server\\volume:dir\\dir...>\n");
printf("EXAMPLE DSEARCH MYSERVER\SYS:PUBLIC\\n");
exit(1);
}
strcpy(pathString, strupr(argv[2]));
ccode = NWCallsInit(NULL, NULL);
if (ccode)
{
printf("\nNWCallsInit returned %04X\n", ccode);
exit(1);
}
strupr(argv[1]);
ccode = NWParseNetWarePath(
/* > path being parsed */ argv[1],
/* < server conn Handle */ &connHandle,
/* < directory Handle */ &dirHandle,
/* < new path relative to dir Handle */ path);
if (ccode)
{
printf("\nNWParseNetWarePath returned %04X\n", ccode);
exit(1);
}
ccode=NWFileSearchInitialize(
/* connection Handle */ connHandle,
/* directory Handle */ dirHandle,
/* path */ path,
/* volume Number */ &volNumber,
/* volume ID */ &dirID,
/* sequence number */ &sequenceNumber,
/* directory access rights */ &dirAccessRights);
if (ccode)
{
printf("NWFileSearchInitialize failed: %X.\n",ccode);
exit(1);
}
clrscr();
printf("Dir Name Dir Attributes Seq Number\n");
do
{
ccode=NWIntFileSearchContinue(
/* connection Handle */ connHandle,
/* volume Number */ volNumber,
/* directory ID */ dirID,
/* search context */ sequenceNumber,
/* search Attributes */ searchAttributes,
/* search Path */ "*",
/* return buffer */ buffer,
/* augment flag */ 0);
if(ccode==0)
{
printf("%s\t",dirInfo->directoryName);
printf(" [%s%c%s%c%c%c%c]",
(dirInfo->directoryAttributes & FA_READ_ONLY) ? "Ro" : "Rw",
(dirInfo->directoryAttributes & FA_HIDDEN) ? 'H' : ' ',
(dirInfo->directoryAttributes & FA_SYSTEM) ? "Sy" : "-",
(dirInfo->directoryAttributes & FA_EXECUTE_ONLY) ? 'X' : '-',
(dirInfo->directoryAttributes & FA_DIRECTORY) ? 'D' : '-',
(dirInfo->directoryAttributes & FA_NEEDS_ARCHIVED) ? 'A' : '-',
(dirInfo->directoryAttributes & FA_SHAREABLE) ? 'S' : '-');
printf(" %d\n",sequenceNumber);
}
sequenceNumber = dirInfo->sequenceNumber;
} /* End of do/while */
while ( ccode==0);
switch(ccode)
{
case 0X89FF : printf("NWIntFileSearchContinue failed: %X",ccode);
printf(" NO_FILES_FOUND_ERROR\n");
break;
case 0X8998 : printf("NWIntFileSearchContinue failed: %X",ccode);
printf(" VOLUME_DOES_NOT_EXIST\n");
break;
case 0X8801 : printf("NWIntFileSearchContinue failed: %X",ccode);
printf(" INVALID_CONNECTION\n");
break;
default : printf("NWIntFileSearchContinue failed: %X\n",ccode);
break;
}
}