http://www.ousob.com --- Legacy Redefined #include <stdio.h> #include <stdlib.h> #include <string.h> #include <process.h> #include <memory.h> #include <nit.h> #include <npt.h> #include <extend50.h> char fileServers[10][48]; int prnCt = 1; void readProperty(char *objectName,WORD objectType,char *propertyName); void scanProperty(char *objectName,WORD objectType); void getBindObj(long object_ID, char *objectName); void getServers(); int getPrinters(); CLIPPER b_netprn() { int prnCount = 0; int ccode, i; char searchObjectName[48]; WORD searchObjectType; long objectID = -1; char objectName[48], objName[48]; WORD objectType, objType; char objectHasProperties; char objectFlag; char objectSecurity; WORD newConnID, oldConnID; prnCount = getPrinters(); _reta(prnCount); if( prnCount == 0 ){ return; } for(i=1; i<9; i++){ memset(fileServers[i],0,48); } getServers(); oldConnID = GetPreferredConnectionID(); for(i=1; fileServers[i][0] != NULL; i++) { newConnID = 0; GetConnectionID(fileServers[i],&newConnID); SetPreferredConnectionID(newConnID); for( objectID = -1, ccode = 0; !ccode;){ ccode = ScanBinderyObject( "*", 0x03, &objectID, objectName, &objectType, &objectHasProperties, &objectFlag, &objectSecurity); if( ccode == 0 ){ if( objectHasProperties == -1 ){ scanProperty(objectName,objectType); } } } } SetPreferredConnectionID(oldConnID); _ret(); } void scanProperty(char *objectName,WORD objectType) { int segmentNumber; BYTE propertyValue[128]; BYTE moreSegments; BYTE propertyFlags2; int ccode; long sequenceNumber; char searchPropertyName[16], propertyName[16]; char propertyFlags, propertySecurity, propertyHasValue; char moreProperties; char errmsg[24]; ccode = 0; sequenceNumber = -1; moreProperties = -1; while( moreProperties != 0 ){ ccode = ScanProperty(objectName, objectType, "*", &sequenceNumber, propertyName, &propertyFlags, &propertySecurity, &propertyHasValue, &moreProperties); if (ccode == 0){ if(strcmp(propertyName,"Q_SERVERS") == 0 && propertyHasValue ){ memset(propertyValue,NULL,48); ReadPropertyValue(objectName, objectType, "IDENTIFICATION", segmentNumber, propertyValue, &moreSegments, &propertyFlags2); readProperty(objectName,objectType,propertyName); break; } } } } void readProperty(char *objectName,WORD objectType,char *propertyName) { int ccode; int i; int segmentNumber; BYTE propertyValue[128]; BYTE moreSegments; BYTE propertyFlags; LONG obj_ID; LONG temp; segmentNumber = 1; while( moreSegments != 0 ){ ccode = ReadPropertyValue (objectName, objectType, propertyName, segmentNumber, propertyValue, &moreSegments, &propertyFlags); if( ccode == 0 ){ if( propertyFlags >= 0x02 ){ for(i=0; i<128; i=i+4){ memcpy(&temp, &propertyValue[i], 4); obj_ID = LongSwap(temp); if( obj_ID == 0 ){ break; } getBindObj(obj_ID,objectName); break; } } } segmentNumber++; } } void getBindObj(long object_ID, char *objectName) { char buff[256]; int ccode; int segmentNumber = 1; BYTE propertyValue[128]; BYTE moreSegments; BYTE propertyFlags; char object_name[48]; WORD object_type; ccode = GetBinderyObjectName (object_ID, object_name, &object_type); memset(propertyValue,0,128); ReadPropertyValue(object_name,object_type, "IDENTIFICATION", segmentNumber, propertyValue, &moreSegments, &propertyFlags); sprintf(buff,"%-16s %s\0",objectName,propertyValue); _storc(buff,-1,prnCt++); } void getServers(void) { int sct; int ccode; char searchObjectName[48]; WORD searchObjectType; long objectID = -1; char objectName[48], objName[48]; WORD objectType, objType; char objectHasProperties; char objectFlag; char objectSecurity; for( objectID = -1, ccode = 0, sct = 1; !ccode; sct++) { ccode = ScanBinderyObject( "*", OT_FILE_SERVER, &objectID, objectName, &objectType, &objectHasProperties, &objectFlag, &objectSecurity); if( ccode == 0 ){ strcpy(fileServers[sct],objectName); } } } int getPrinters(void) { int sct, i; int ccode; char searchObjectName[48]; WORD searchObjectType; long objectID = -1; char objectName[48], objName[48]; WORD objectType, objType; char objectHasProperties; char objectFlag; char objectSecurity; WORD newConnID, oldConnID; oldConnID = GetPreferredConnectionID(); for(i=1; fileServers[i][0] != NULL; i++) { newConnID = 0; GetConnectionID(fileServers[i],&newConnID); SetPreferredConnectionID(newConnID); for( objectID = -1, ccode = 0, sct = 1; !ccode;) { ccode = ScanBinderyObject( "*", 0x03, &objectID, objectName, &objectType, &objectHasProperties, &objectFlag, &objectSecurity); if( ccode == 0 ){ sct++; } } } SetPreferredConnectionID(oldConnID); return(sct-1); }