/****************************** Module Header ******************************* * * Module Name: getnextprofileapp.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. * ****************************************************************************/ /* @@NepmdGetNextProfileApp@PROTOTYPE Flag = NepmdGetNextProfileApp( Handle, Filter, NextApp) @@NepmdGetNextProfileApp@CATEGORY@CONFIG @@NepmdGetNextProfileApp@SYNTAX This function queries all applications of a profile. For that it needs to be [.IDPNL_EFUNC_NEPMDGETNEXTPROFILEAPP_EXAMPLE called in a loop]. @@NepmdGetNextProfileApp@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. @@NepmdGetNextProfileApp@PARM@Filter To limit the returned apps, a filter may be specified that must match the begin of the returned apps. An empty filter value matches all apps. @@NepmdGetNextProfileApp@PARM@NextApp This parameter must be a variable. It specifies either .ul compact - an empty string to query the first app or - the previously returned app in order to query the next app. If an app is specified, it must exist in the profile, otherwise *NepmdGetNextProfileApp* 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 app is stored in this parameter. @@NepmdGetNextProfileApp@EXAMPLE The following code searches applications within *USER__INI* that match the filter *PM__W*: .fo text Handle = HINI_USERPROFILE -- HINI_PROFILE doesn't work Filter = 'PM_W' NextApp = '' -- Search all apps do while NepmdGetNextProfileApp( Handle, Filter, NextApp) -- Process app - here as a sample we display a popup messagenwait( 'App found:' NextApp) enddo .fo on @@NepmdGetNextProfileApp@RETURNS *NepmdGetNextProfileApp* returns either .ul compact - *0* (zero), if no more apps exist or on error - *1*, if next profile app was queried successfully. The next app returned by the app search is stored in the [.IDPNL_EFUNC_NEPMDGETNEXTPROFILEAPP_PARM_NEXTAPP NextApp] 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 app was not found. @@NepmdGetNextProfileApp@TESTCASE You can test this function from the *EPM* commandline by executing: .sl - *NepmdGetNextProfileApp* - or - *GetNextProfileApp* Executing this command will open up a virtual file and write all applications of *USER__INI* that match the filter *PM__W* to it. @@ */ ; --------------------------------------------------------------------------- ; Allow editor command to call function ; --------------------------------------------------------------------------- compile if NEPMD_LIB_TEST defc NepmdGetNextProfileApp, GetNextProfileApp Handle = HINI_USERPROFILE Filter = 'PM_W' NextApp = '' -- Create virtual file helperNepmdCreateDumpfile( 'NepmdGetNextProfileApp', Filter) -- Search all apps do while NepmdGetNextProfileApp( Handle, Filter, NextApp) insertline( '-' NextApp) enddo insertline '' .modify = 0 compile endif ; --------------------------------------------------------------------------- ; Procedure: NepmdGetNextProfileApp ; --------------------------------------------------------------------------- ; E syntax: ; Handle = '' ; Flag = NepmdGetNextProfileApp( Handle, Filter, NextApp) ; ; --------------------------------------------------------------------------- ; C prototype: ; APIRET EXPENTRY NepmdGetNextProfileApp( HCONFIG hconfig, ; PSZ pszFilter, ; PSZ pszPreviousApp, ; PSZ pszBuffer, ; ULONG ulBuffLen); ; ; --------------------------------------------------------------------------- defproc NepmdGetNextProfileApp( Handle, Filter, var NextApp) -- 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 FilterZ = Filter\0 PreviousAppZ = NextApp\0 BuffLen = NEPMD_MAXLEN_ESTRING + 1 NextApp = copies( \0, BuffLen) -- Call C routine LibFile = helperNepmdGetlibfile() rc = dynalink32( LibFile, 'NepmdGetNextProfileApp', atol( Handle) || address( FilterZ) || address( PreviousAppZ) || address( NextApp) || atol( BuffLen)) helperNepmdCheckliberror( LibFile, rc) if rc then Flag = 0 NextApp = '' else Flag = 1 NextApp = makerexxstring( NextApp) endif return Flag