/****************************** Module Header ******************************* * * Module Name: getnextprofilekey.e * * E wrapper routine to access the NEPMD library DLL. * Include of nepmdlib.e. * * Copyright (c) Netlabs EPM Distribution Project 2002 * * $Id$ * * =========================================================================== * * This file is part of the Netlabs EPM Distribution package and is free * software. You can redistribute it and/or modify it under the terms of the * GNU General Public License as published by the Free Software * Foundation, in version 2 as it comes in the "COPYING" file of the * Netlabs EPM Distribution. This library is distributed in the hope that it * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * ****************************************************************************/ /* @@NepmdGetNextProfileKey@PROTOTYPE Flag = NepmdGetNextProfileKey( Handle, ProfileApp, Filter, NextKey) @@NepmdGetNextProfileKey@CATEGORY@CONFIG @@NepmdGetNextProfileKey@SYNTAX This function queries all keys of a profile. For that it needs to be [.IDPNL_EFUNC_NEPMDGETNEXTPROFILEKEY_EXAMPLE called in a loop]. @@NepmdGetNextProfileKey@PARM@Handle This parameter determines the handle of a profile. For NEPMD.INI, that handle is obtained by a previous call to [.IDPNL_EFUNC_NEPMDOPENCONFIG]. USER__INI and SYSTEM__INI are already opened by the system. NEPMD.INI is usually opened by EPM at startup. To use these files, specify: .sl compact - *HINI__USERPROFILE* or *-1* for USER__INI - *HINI__SYSTEMPROFILE* or *-2* for SYSTEM__INI - *HINI__NEPMDPROFILE* or *-3* for NEPMD.INI A lookup in both USER__INI and SYSTEM__INI is not possible when being called in a loop. Therefore *HINI__PROFILE* or *0* is disabled. With *-3* or *HINI__NEPMDPROFILE*, the value of the universal var *nepmd__hini* is automatically inserted. You may pass an *empty string* or *-9* to [.IDPNL_REGISTRY_IMPLICITOPEN implicitely open and close] the configuration repository NEPMD.INI before and after this call. @@NepmdGetNextProfileKey@PARM@ProfileApp This parameter specifies the name of the profile application. @@NepmdGetNextProfileKey@PARM@Filter To limit the returned keys, a filter may be specified that must match the begin of the returned keys. An empty filter value matches all keys. @@NepmdGetNextProfileKey@PARM@NextKey This parameter must be a variable. It specifies either .ul compact - an empty string to query the first key or - the previously returned key in order to query the next key. If a key is specified, it must exist in the profile, otherwise *NepmdGetNextProfileKey* will return an error. Searching both USER__INI and SYSTEM__INI in one call doesn't work, because it would create an infinite loop, if a key doesn't exist in both of them. The next found key is stored in this parameter. @@NepmdGetNextProfileKey@EXAMPLE The following code searches keys within the *RegDefaults* application of *NEPMD.INI* that match the filter *\NEPMD\T*: .fo text Handle = HINI_NEPMDPROFILE ProfileApp = 'RegDefaults' Filter = '\NEPMD\T' NextKey = '' -- Search all keys do while NepmdGetNextProfileKey( Handle, ProfileApp, Filter, NextKey) -- Process key - here as a sample we display a popup messagenwait( 'Key found:' NextKey) enddo .fo on @@NepmdGetNextProfileKey@RETURNS *NepmdGetNextProfileKey* returns either .ul compact - *0* (zero), if no more keys exist or on error - *1*, if next profile key was queried successfully. The next key returned by the key search is stored in the [.IDPNL_EFUNC_NEPMDGETNEXTPROFILEKEY_PARM_NEXTKEY NextKey] parameter. This procedure sets the implicit universal var *rc*. rc is set to an [inf:cp2 "Errors" OS/2 error code] or to zero for no error. rc is set to 18 = ERROR__NO__MORE__FILES if key was not found. @@NepmdGetNextProfileKey@TESTCASE You can test this function from the *EPM* commandline by executing: .sl - *NepmdGetNextProfileKey* - or - *GetNextProfileKey* Executing this command will open up a virtual file and write all keys of *NEPMD.INI*, application *RegDefaults* that match the filter *\NEPMD\T* to it. @@ */ ; --------------------------------------------------------------------------- ; Allow editor command to call function ; --------------------------------------------------------------------------- compile if NEPMD_LIB_TEST defc NepmdGetNextProfileKey, GetNextProfileKey Handle = HINI_NEPMDPROFILE ProfileApp = 'RegDefaults' Filter = '\NEPMD\T' NextKey = '' -- Create virtual file helperNepmdCreateDumpfile( 'NepmdGetNextProfileKey', ProfileApp Filter) -- Search all keys do while NepmdGetNextProfileKey( Handle, ProfileApp, Filter, NextKey) insertline( '-' NextKey) enddo insertline '' .modify = 0 compile endif ; --------------------------------------------------------------------------- ; Procedure: NepmdGetNextProfileKey ; --------------------------------------------------------------------------- ; E syntax: ; Handle = '' ; Flag = NepmdGetNextProfileKey( Handle, ProfileApp, Filter, NextKey) ; ; --------------------------------------------------------------------------- ; C prototype: ; APIRET EXPENTRY NepmdGetNextProfileKey( HCONFIG hconfig, ; PSZ pszAppName, ; PSZ pszFilter, ; PSZ pszPreviousKey, ; PSZ pszBuffer, ; ULONG ulBuffLen); ; ; --------------------------------------------------------------------------- defproc NepmdGetNextProfileKey( Handle, ProfileApp, Filter, var NextKey) -- For -3, use the handle returned by the initial OpenConfig of NEPMD.INI. if Handle = HINI_NEPMDPROFILE then Handle = helperNepmdGetConfigHandle() elseif Handle = '' then Handle = -9 endif -- The values -1 and -2 are handled by the called Prf function. -- The value 0 can't be used here. It would create an infinite loop when -- being called for both profiles in a loop. -- Prepare parameters for C routine ProfileAppZ = ProfileApp\0 FilterZ = Filter\0 PreviousKeyZ = NextKey\0 BuffLen = NEPMD_MAXLEN_ESTRING + 1 NextKey = copies( \0, BuffLen) -- Call C routine LibFile = helperNepmdGetlibfile() rc = dynalink32( LibFile, 'NepmdGetNextProfileKey', atol( Handle) || address( ProfileAppZ) || address( FilterZ) || address( PreviousKeyZ) || address( NextKey) || atol( BuffLen)) helperNepmdCheckliberror( LibFile, rc) if rc then Flag = 0 NextKey = '' else Flag = 1 NextKey = makerexxstring( NextKey) endif return Flag