Category : Network Files
Archive   : WHOHAS.ZIP
Filename : WHOHAS2.C

 
Output of file : WHOHAS2.C contained in archive : WHOHAS.ZIP
/* *********************************************************************
* WHOHAS is a utility to determine whether or not someone else on the
* network is using a file, and if they are to alert them to the fact
* that you would like to use the file.
***********************************************************************/
#include
#include

char path[255], server[48]; /* for parsing path */
char volume[16], directories[255];

/* for conns. using file call */
WORD connectionID; /* server ID number */
BYTE directoryHandle; /* handle number at server */
char filePath[255];
int lastRecord, taskID; /* end of reply/buffers indicators */
CONN_USING_FILE fileUse; /* the data structure */

/* for connection info. call */
char objectName[48]; /* bindery name of user */
int objectType;
long objectID;
BYTE loginTime[7];

/* for send message call */
char message[56]; /* place for message text */
WORD connectionList[100]; /* list of workstation connection IDs */
BYTE resultList[100]; /* completion codes for broadcast */
WORD connectionCount;

ErrorOut(char *errorString, int errorLevel)
{
printf("%s\n", errorString);
exit(errorLevel);
}

main(int argc, char *argv[])
{
unsigned ccode;
char ch;
int i;

if (argc!=2)
{
printf("Usage: whohas filename.\n");
exit(0);
}
strcpy(filePath, argv[1]);
if (ConvertNameToFullPath(filePath, path))
ErrorOut("Invalid filename/path.", 1);

ParsePath(filePath, server, volume, directories);
if (strlen(server)==0)
ErrorOut("Please indicate a file on a network drive.", 1);

if (GetConnectionID(server, &connectionID))
ErrorOut("Invalid server.", 1);

directoryHandle = 0; /* use null handle since path is full */
taskID = lastRecord = 0; /* get first buffer in first reply */
connectionCount = 0; /* start counting connections from 0 */
do
{ /* here's where all the real work gets done */
ccode = GetConnectionsUsingFile(connectionID, &lastRecord, &taskID,
directoryHandle, path, sizeof(fileUse), &fileUse);
if (fileUse.logicalConnNumber)
connectionList[connectionCount++] = fileUse.logicalConnNumber;
} while (lastRecord);

/* if file is in use, print users and allow message send */
if (connectionCount)
{ /* direct these bindery requests to correct server */
SetPreferredConnectionID(connectionID);
for (i=0; i {
ccode = GetConnectionInformation(connectionList[i], objectName,
&objectType, &objectID, loginTime);
printf("User %s is using file %s.\n", objectName, filePath);
}
printf("Send a message to persons using the file? (y/n)");
while(!kbhit())
;
ch = getche(); /* get & echo response */
printf("\n");
if (ch=='y' || ch=='Y')
{ /* message can go to end of line */
printf("Enter a short message =>");
gets(message); /* send the message to the whole list */
ccode = SendBroadcastMessage(message, connectionList, resultList,
connectionCount);
/* I ignore the resultList of completion codes */
}
}
else
printf("Nobody is currently using file %s.\n", filePath);
return(0);
}


  3 Responses to “Category : Network Files
Archive   : WHOHAS.ZIP
Filename : WHOHAS2.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/