1/* -*- buffer-read-only: t -*- vi: set ro:
2   THIS FILE IS GENERATED AUTOMATICALLY.  PLEASE DO NOT EDIT.
3*/
4#line 1 "safedb.mf4"
5/* Safe DB I/O                                             -*- mfl -*-
6   Copyright (C) 2007-2021 Sergey Poznyakoff
7
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 3, or (at your option)
11   any later version.
12
13   This program is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   GNU General Public License for more details.
17
18   You should have received a copy of the GNU General Public License
19   along with this program .  If not, see <http://www.gnu.org/licenses/>. */
20
21module 'safedb'.
22require status
23
24number safedb_verbose
25
26func safedbget(string name, string key ; string defval, number null)
27  returns string
28do
29  catch e_dbfailure
30  do
31    if safedb_verbose
32      echo "safedbget: exception $1: $2"
33    fi
34    return defval
35  done
36  if not $#>@null
37    set null 0
38    if not $#>@defval
39      set defval ""
40    fi
41  fi
42  return dbget(name, key, defval, null)
43done
44
45func safedbput(string name, string key, string value ; number null)
46do
47  catch e_dbfailure
48  do
49    if safedb_verbose
50      echo "safedbput: exception $1: $2"
51    fi
52    return
53  done
54  if not $#>@null
55    set null 0
56  fi
57  dbput(name, key, value, null)
58done
59
60
61func safedbmap(string name, string key; number defval, number null)
62  returns number
63do
64  catch e_dbfailure
65  do
66    if safedb_verbose
67      echo "safedbmap: exception $1: $2"
68    fi
69    return defval
70  done
71  if not $#>@defval
72    set defval 0
73  fi
74  if not $#>@null
75    set null 0
76  fi
77  return dbmap(name, key, null)
78done
79
80func safedbdel(string name, string key; number null)
81do
82  catch e_dbfailure
83  do
84    if safedb_verbose
85      echo "safedbdel: exception $1: $2"
86    fi
87    return
88  done
89  if not $#>@null
90    set null 0
91  fi
92  dbdel(name, key, null)
93done
94
95
96