unsigned long SysPutEA(unsigned char *name, unsigned long numargs, RXSTRING args[], char *queuename, RXSTRING *retstr) { unsigned long rc; /* Ret code */ unsigned long act; /* open action */ void *fealist; /* fealist buffer */ EAOP2 eaop; /* eaop structure */ PFEA2 pfea; /* pfea structure */ HFILE handle; /* file handle */ if (numargs != 3 || !RXVALIDSTRING(args[0]) || !RXVALIDSTRING(args[1])) return INVALID_ROUTINE; if (rc = DosOpen2(args[0].strptr, &handle, &act, 0L, 0, OPEN_ACTION_OPEN_IF_EXISTS, OPEN_ACCESS_READWRITE + OPEN_SHARE_DENYWRITE + OPEN_FLAGS_FAIL_ON_ERROR + OPEN_FLAGS_WRITE_THROUGH, NULL)) { RETVAL(rc) } if (DosAllocMem((PPVOID)&fealist, 0x00010000L, AllocFlag)) { BUILDRXSTRING(retstr, ERROR_NOMEM); return VALID_ROUTINE; } eaop.fpFEA2List = (PFEA2LIST)fealist;/* Set memory for the FEA */ eaop.fpGEA2List = NULL; /* GEA is unused */ pfea = &eaop.fpFEA2List->list[0]; /* point to first FEA */ pfea->fEA = '\0'; /* set the flags */ /* Size of FEA name field */ pfea->cbName = (BYTE)args[1].strlength; /* Size of Value for this one */ pfea->cbValue = (SHORT)args[2].strlength; /* Set the name of this FEA */ strcpy((PSZ)pfea->szName, args[1].strptr); /* Set the EA value */ memcpy((PSZ)pfea->szName+(pfea->cbName+1), args[2].strptr, args[2].strlength); pfea->oNextEntryOffset = 0; /* no next entry */ eaop.fpFEA2List->cbList = /* Set the total size var */ sizeof(ULONG) + sizeof(FEA2) + pfea->cbName + pfea->cbValue; /* set the file info */ rc = DosSetFileInfo(handle, 2, (PSZ)&eaop, sizeof(EAOP2)); DosClose(handle); /* Close the File */ DosFreeMem(fealist); /* Free the memory */ RETVAL(rc) }
ULONG RxLoadThisResourceDll ( PSZ pszName, ULONG ulNumargs, RXSTRING args[], PSZ pszQueuename, PRXSTRING prxstrRetstr ) { static PSZ pszResult = "0"; // do nothin special here, just return zero as result string BUILDRXSTRING( prxstrRetstr, pszResult); // no REXX exception return NO_ERROR; }
unsigned long SysGetEA(unsigned char *name, unsigned long numargs, RXSTRING args[], char *queuename, RXSTRING *retstr) { long rc; /* Ret code */ unsigned char geabuff[300]; /* buffer for GEA */ unsigned long act; /* open action */ void *fealist; /* fealist buffer */ EAOP2 eaop; /* eaop structure */ PGEA2 pgea; /* pgea structure */ PFEA2 pfea; /* pfea structure */ HFILE handle; /* file handle */ RXSTEMDATA ldp; /* stem data */ if (numargs != 3 || !RXVALIDSTRING(args[0]) || !RXVALIDSTRING(args[1]) || !RXVALIDSTRING(args[2])) return INVALID_ROUTINE; ldp.count = 0; /* get the stem variable name */ strcpy(ldp.varname, args[2].strptr); ldp.stemlen = args[2].strlength; strupr(ldp.varname); /* uppercase the name */ if (rc = DosOpen(args[0].strptr, &handle, &act, 0L, 0, OPEN_ACTION_OPEN_IF_EXISTS, OPEN_ACCESS_READONLY + OPEN_SHARE_DENYREADWRITE + OPEN_FLAGS_FAIL_ON_ERROR + OPEN_FLAGS_WRITE_THROUGH, NULL)) { RETVAL(rc) } /* get the file status info */ if (DosAllocMem((PPVOID)&fealist, 0x00010000L, AllocFlag)) { BUILDRXSTRING(retstr, ERROR_NOMEM); return VALID_ROUTINE; } /* FEA and GEA lists */ eaop.fpGEA2List = (PGEA2LIST)geabuff; eaop.fpFEA2List = (PFEA2LIST)fealist; eaop.oError = 0; /* no error occurred yet */ pgea = &eaop.fpGEA2List->list[0]; /* point to first GEA */ eaop.fpGEA2List->cbList = sizeof(ULONG) + sizeof(GEA2) + args[1].strlength; eaop.fpFEA2List->cbList = (ULONG)0xffff; /* fill in the EA name length */ pgea->cbName = (BYTE)args[1].strlength; strcpy(pgea->szName, args[1].strptr);/* fill in the name */ pgea->oNextEntryOffset = 0; /* fill in the next offset */ /* read the extended attribute*/ rc = DosQueryFileInfo(handle, 3, (PSZ)&eaop, sizeof(EAOP2)); DosClose(handle); /* close the file */ if (eaop.fpFEA2List->cbList <= sizeof(ULONG)) rc = ERROR_EAS_NOT_SUPPORTED; /* this is error also */ sprintf(retstr->strptr, "%d", rc); /* format return code */ retstr->strlength = strlen(retstr->strptr); if (rc) { /* failure? */ DosFreeMem(fealist); /* error, get out */ return VALID_ROUTINE; } pfea = &(eaop.fpFEA2List->list[0]); /* point to the first FEA */ ldp.shvb.shvnext = NULL; ldp.shvb.shvname.strptr = ldp.varname; ldp.shvb.shvname.strlength = ldp.stemlen; ldp.shvb.shvnamelen = ldp.stemlen; ldp.shvb.shvvalue.strptr = ((PSZ)pfea->szName+(pfea->cbName+1)); ldp.shvb.shvvalue.strlength = pfea->cbValue; ldp.shvb.shvvaluelen = ldp.shvb.shvvalue.strlength; ldp.shvb.shvcode = RXSHV_SET; ldp.shvb.shvret = 0; if (RexxVariablePool(&ldp.shvb) == RXSHV_BADN) { DosFreeMem(fealist); /* free our buffer */ return INVALID_ROUTINE; /* error on non-zero */ } DosFreeMem(fealist); /* free our buffer */ return VALID_ROUTINE; }
unsigned long SysIni(unsigned char *name, unsigned long numargs, RXSTRING args[], char *queuename, RXSTRING *retstr) { HINI hini; unsigned long x; unsigned long len; unsigned long lSize; char *IniFile = ""; char *App; char *Key = ""; char *Val; char Temp[256]; char UserName[256]; char SysName[256]; PRFPROFILE PrfInfo; long Error = FALSE; bool WildCard = FALSE; bool QueryApps; RXSTEMDATA ldp; // initialize PM HAB AnchBlk = NULLHANDLE; bool WinIntial = TRUE; #ifdef DLOGGING logmessage(__func__); #endif /* validate arguments */ if (numargs < 2 || numargs > 4 || !RXVALIDSTRING(args[1])) return INVALID_ROUTINE; /* get pointers to args */ IniFile = args[0].strptr; App = args[1].strptr; if (numargs >= 3 && args[2].strptr) Key = args[2].strptr; if (numargs == 4) Val = args[3].strptr; /* Check KEY and APP values for "WildCard" */ if (!stricmp(App, "ALL:")) { App = ""; QueryApps = TRUE; WildCard = TRUE; if (numargs != 3) return INVALID_ROUTINE; /* Error - Not enough args */ else x = 2; /* Arg number of STEM variable*/ } else if (!stricmp(Key, "ALL:")) { Key = ""; Val = ""; QueryApps = FALSE; WildCard = TRUE; if (numargs != 4) return INVALID_ROUTINE; /* Error - Not enough args */ else x = 3; /* Arg number of STEM variable*/ } /* * If this is a "WildCard search, then allocate mem * for stem struct and get the stem name */ if (WildCard == TRUE) { ldp.count = 0; /* get the stem variable name */ strcpy(ldp.varname, args[x].strptr); ldp.stemlen = args[x].strlength; strupr(ldp.varname); /* uppercase the name */ if (ldp.varname[ldp.stemlen-1] != '.') ldp.varname[ldp.stemlen++] = '.'; } WININIT(WinIntial,AnchBlk) /************************************************************** * The following section of code gets the INI file handle * * given the INI file spec (IniFile). * * * * Possible Ini file specs: * * * * NULL - Same as USERPROFILE ( OS2.INI ) * * "BOTH" - Same as PROFILE ( OS2.INI & OS2SYS.INI ) * * "USER" - Same as USERPROFILE ( OS2.INI ) * * "SYSTEM" - Same as SYSTEMPROFILE ( OS2SYS.INI) * * other - Filespec of INI file. * **************************************************************/ hini = NULLHANDLE; if (!IniFile) hini = HINI_USERPROFILE; else if (!stricmp(IniFile, "BOTH")) hini = HINI_PROFILE; else if (!stricmp(IniFile, "USER")) hini = HINI_USERPROFILE; else if (!stricmp(IniFile, "SYSTEM")) hini = HINI_SYSTEMPROFILE; /*********************************************************** * If Ini file spec is 'other' then make sure it does not * * specify the current USER or SYSTEM profiles. * * * * Trying to open the current USER or SYSTEM ini file via * * PrfOpenProfile() will fail. Therefore, use the function * * PrfQueryProfile() to query the current USER and SYSTEM * * ini file specs. If the IniFile string matches either * * the current USER or SYSTEM file specs, then use either * * HINI_USERPROFILE or HINI_SYSTEMPROFILE as appropriate. * * * * If IniFile does not specify the current USER or SYSTEM * * ini file then use PrfOpenProfile() to get the ini file * * handle. * ***********************************************************/ else { PrfInfo.pszUserName = UserName; PrfInfo.cchUserName = sizeof(UserName); PrfInfo.pszSysName = SysName; PrfInfo.cchSysName = sizeof(SysName); if (PrfQueryProfile(AnchBlk, &PrfInfo)) { if (!stricmp(IniFile, PrfInfo.pszUserName)) hini = HINI_USERPROFILE; else if (!stricmp(IniFile, PrfInfo.pszSysName)) hini = HINI_SYSTEMPROFILE; else hini = PrfOpenProfile(AnchBlk, IniFile); } else hini = PrfOpenProfile(AnchBlk, IniFile); /************************************************** * Exit with INI FILE error if the ini file handle * * is NULL at this point (and if IniFile != BOTH, * * as that would make the handle NULL also). * **************************************************/ if (hini == NULLHANDLE && stricmp(IniFile, "BOTH")) { BUILDRXSTRING(retstr, ERROR_RETSTR); WINTERM(WinIntial,AnchBlk) return VALID_ROUTINE; } }
unsigned long SysDriveMap(unsigned char *name, unsigned long numargs, RXSTRING args[], char *queuename, RXSTRING *retstr) { char temp[MAX]; /* Entire drive map built here*/ char tmpstr[MAX]; /* Single drive entries built */ /* here */ char buf[256]; /* Give DosQFSInfo 256 bytes */ char DeviceName[3]; /* Device name or drive letter*/ /* string */ unsigned long CurDrive; /* Current drive */ unsigned long DriveMap; /* Drive map */ unsigned long Ordinal; /* Ordinal of entry in name */ /* list */ unsigned long FSAInfoLevel; /* Type of attached FSD data */ /* required */ unsigned long DataBufferLen; /* Buffer length */ unsigned long dnum; /* Disk num variable */ unsigned long start = 3; /* Initial disk num */ unsigned long Mode = USED; /* Query mode USED, FREE, */ /* LOCAL, etc */ FSQBUFFER2 DataBuffer; /* Returned data buffer */ long rc; /* OS/2 return codes */ Ordinal = (unsigned long )0; FSAInfoLevel = (unsigned long )1; temp[0] = '\0'; #ifdef DLOGGING logmessage(__func__); #endif if (numargs > 2) return INVALID_ROUTINE; if (numargs >= 1 && args[0].strptr) { if ((strlen(args[0].strptr) == 2 && args[0].strptr[1] != ':') || strlen(args[0].strptr) > 2 || strlen(args[0].strptr) == 0 || !isalpha(args[0].strptr[0])) return INVALID_ROUTINE; start = toupper(args[0].strptr[0])-'A'+1; } /* check the mode */ if (numargs == 2 && args[1].strlength != 0) { if (!stricmp(args[1].strptr, "FREE")) Mode = FREE; else if (!stricmp(args[1].strptr, "USED")) Mode = USED; else if (!stricmp(args[1].strptr, "DETACHED")) Mode = DETACHED; else if (!stricmp(args[1].strptr, "REMOTE")) Mode = REMOTE; else if (!stricmp(args[1].strptr, "LOCAL")) Mode = LOCAL; else return INVALID_ROUTINE; } /* perform the query */ DosError(0); /* Disable Hard-Error Popups */ DosQueryCurrentDisk(&CurDrive, &DriveMap); DriveMap>>=start-1; /* Shift to the first drive */ temp[0] = '\0'; /* Clear temporary buffer */ for (dnum = start; dnum <= 26; dnum++) { if (!(DriveMap&(unsigned long)1) && Mode == FREE) { sprintf(tmpstr, "%c: ", dnum+'A'-1); strcat(temp, tmpstr); } /* Hey, we have a used drive */ else if ((DriveMap&(unsigned long)1) && Mode == USED) { sprintf(tmpstr, "%c: ", dnum+'A'-1); strcat(temp, tmpstr); } else if (DriveMap&(unsigned long)1) { /* Check specific drive info */ sprintf(DeviceName, "%c:", dnum+'A'-1); DataBufferLen = sizeof DataBuffer; DosQueryFSAttach(DeviceName, Ordinal, FSAInfoLevel, &DataBuffer, &DataBufferLen); rc = DosQueryFSInfo(dnum, 2, buf, sizeof(buf)); if (rc == 67 && DataBuffer.iType == 4 && Mode == DETACHED) { /* Hey, we have a detached */ /* drive */ sprintf(tmpstr, "%c: ", dnum+'A'-1); strcat(temp, tmpstr); } else if (DataBuffer.iType == 4 && Mode == REMOTE) { sprintf(tmpstr, "%c: ", dnum+'A'-1); strcat(temp, tmpstr); } else if (DataBuffer.iType == 3 && Mode == LOCAL) { sprintf(tmpstr, "%c: ", dnum+'A'-1); strcat(temp, tmpstr); } } DriveMap>>=1; /* Shift to the next drive */ } BUILDRXSTRING(retstr, temp); /* pass back result */ if (retstr->strlength) retstr->strlength--; DosError(1); /* Enable Hard-Error Popups */ return VALID_ROUTINE; /* no error on call */ }