/* Provide routines to store/check/access user credentials stored in a shared memory object */ /* Copyright (C) 2007-2017 Herwig Bauernfeind for bww bitwise works GmbH. This program 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, either version 3 of the License, or (at your option) any later version. This program 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. You should have received a copy of the GNU General Public License along with this program. If not, see . */ _ucInitObj: procedure expose ucMem /* Initialize shared memory object */ /* Not implemented as we use only an existing object */ ucMem = '\SHAREMEM\INETXXX' return ucMem _ucChkObj: procedure expose ucMem ucPtr /* Check if appropriate memory object is available */ Success = 0 getrc = RxGetNamedSharedMem('ucPtr', ucMem , 'rw') if getrc = 0 then Success = 1 return Success _ucChkUc: procedure expose ucMem ucPtr /* Check whether credentials are stored in memory object */ rawMem = RxStorage( ucPtr , 4096 ) ucPos = lastpos('--user=',rawMem) Success = (ucPos > 0) return Success _ucSetUc: procedure expose ucMem ucPtr UserCred /* Set/Store credentials in memory object */ Success = 0 rawMem = RxStorage( ucPtr , 4096 ) ucL = length(UserCred) rawMem = overlay(UserCred, rawMem, 4096-ucL) rawMem = RxStorage( ucPtr , 4096, rawMem ) Success = 1 return Success _ucDelUc: procedure expose ucMem ucPtr UserCred /* Delete credentials from memory object */ rawMem = RxStorage( ucPtr , 4096 ) cPos = lastpos('--user=',rawMem) rawMem = overlay(copies('00'x,4096-cPos), rawMem, cPos) rawMem = RxStorage( ucPtr , 4096, rawMem ) return 1 _ucGetUc: procedure expose ucMem ucPtr /* Read credentials from memory object */ rawMem = RxStorage( ucPtr , 4096 ) ucPos = lastpos('--user=',rawMem) UserCred = strip(substr(rawMem,ucPos),,'00'x) return UserCred