source: trunk/guitools/shared/usercredmem.vrs@ 1030

Last change on this file since 1030 was 1023, checked in by Herwig Bauernfeind, 8 years ago

GUITools: Add GPLv3 header to all .VRS files

File size: 2.2 KB
Line 
1/* Provide routines to store/check/access user credentials
2 stored in a shared memory object */
3
4/*
5Copyright (C) 2007-2017 Herwig Bauernfeind for bww bitwise works GmbH.
6
7This program is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation, either version 3 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21_ucInitObj: procedure expose ucMem
22 /* Initialize shared memory object */
23 /* Not implemented as we use only an existing object */
24 ucMem = '\SHAREMEM\INETXXX'
25return ucMem
26
27_ucChkObj: procedure expose ucMem ucPtr
28 /* Check if appropriate memory object is available */
29 Success = 0
30 getrc = RxGetNamedSharedMem('ucPtr', ucMem , 'rw')
31 if getrc = 0 then Success = 1
32return Success
33
34_ucChkUc: procedure expose ucMem ucPtr
35 /* Check whether credentials are stored in memory object */
36 rawMem = RxStorage( ucPtr , 4096 )
37 ucPos = lastpos('--user=',rawMem)
38 Success = (ucPos > 0)
39return Success
40
41_ucSetUc: procedure expose ucMem ucPtr UserCred
42 /* Set/Store credentials in memory object */
43 Success = 0
44 rawMem = RxStorage( ucPtr , 4096 )
45 ucL = length(UserCred)
46 rawMem = overlay(UserCred, rawMem, 4096-ucL)
47 rawMem = RxStorage( ucPtr , 4096, rawMem )
48 Success = 1
49return Success
50
51_ucDelUc: procedure expose ucMem ucPtr UserCred
52 /* Delete credentials from memory object */
53 rawMem = RxStorage( ucPtr , 4096 )
54 cPos = lastpos('--user=',rawMem)
55 rawMem = overlay(copies('00'x,4096-cPos), rawMem, cPos)
56 rawMem = RxStorage( ucPtr , 4096, rawMem )
57return 1
58
59_ucGetUc: procedure expose ucMem ucPtr
60 /* Read credentials from memory object */
61 rawMem = RxStorage( ucPtr , 4096 )
62 ucPos = lastpos('--user=',rawMem)
63 UserCred = strip(substr(rawMem,ucPos),,'00'x)
64return UserCred
Note: See TracBrowser for help on using the repository browser.