Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
6
66
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eric Vidal
66
Commits
8d719895
Commit
8d719895
authored
8 months ago
by
Eric Vidal
Browse files
Options
Downloads
Patches
Plain Diff
Provide resolve_open_cdb function
parent
00cbc661
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/include/66/resolve.h
+1
-0
1 addition, 0 deletions
src/include/66/resolve.h
src/lib66/resolve/resolve_open_cdb.c
+50
-0
50 additions, 0 deletions
src/lib66/resolve/resolve_open_cdb.c
src/lib66/resolve/resolve_read_cdb.c
+8
-33
8 additions, 33 deletions
src/lib66/resolve/resolve_read_cdb.c
with
59 additions
and
33 deletions
src/include/66/resolve.h
+
1
−
0
View file @
8d719895
...
...
@@ -71,6 +71,7 @@ extern void resolve_init(resolve_wrapper_t *wres) ;
* */
extern
int
resolve_check_g
(
resolve_wrapper_t
*
wres
,
char
const
*
base
,
char
const
*
name
)
;
extern
int
resolve_open_cdb
(
int
*
fd
,
cdb
*
c
,
const
char
*
path
,
const
char
*
name
)
;
extern
int
resolve_read_g
(
resolve_wrapper_t
*
wres
,
char
const
*
base
,
char
const
*
name
)
;
extern
int
resolve_write_g
(
resolve_wrapper_t
*
wres
,
char
const
*
base
,
char
const
*
name
)
;
extern
void
resolve_remove_g
(
char
const
*
base
,
char
const
*
name
,
uint8_t
data_type
)
;
...
...
This diff is collapsed.
Click to expand it.
src/lib66/resolve/resolve_open_cdb.c
0 → 100644
+
50
−
0
View file @
8d719895
/*
* resolve_open_cdb.c
*
* Copyright (c) 2018-2024 Eric Vidal <eric@obarun.org>
*
* All rights reserved.
*
* This file is part of Obarun. It is subject to the license terms in
* the LICENSE file found in the top-level directory of this
* distribution.
* This file may not be copied, modified, propagated, or distributed
* except according to the terms contained in the LICENSE file./
*/
#include
<string.h>
#include
<errno.h>
#include
<unistd.h>
#include
<oblibs/log.h>
#include
<oblibs/string.h>
#include
<skalibs/cdb.h>
#include
<skalibs/djbunix.h>
int
resolve_open_cdb
(
int
*
fd
,
cdb
*
c
,
const
char
*
path
,
const
char
*
name
)
{
log_flow
()
;
int
err
=
errno
;
char
file
[
strlen
(
path
)
+
strlen
(
name
)
+
1
]
;
errno
=
0
;
auto_strings
(
file
,
path
,
name
)
;
(
*
fd
)
=
open_readb
(
file
)
;
if
((
*
fd
)
<
0
)
log_warnusys_return
(
errno
==
ENOENT
?
0
:
-
1
,
"open: "
,
file
)
;
errno
=
err
;
if
(
!
cdb_init_fromfd
(
c
,
(
*
fd
)))
{
log_warnusys
(
"cdb_init: "
,
file
)
;
close
((
*
fd
))
;
cdb_free
(
c
)
;
return
-
1
;
}
return
1
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/lib66/resolve/resolve_read_cdb.c
+
8
−
33
View file @
8d719895
...
...
@@ -13,13 +13,10 @@
*/
#include
<unistd.h>
#include
<errno.h>
#include
<oblibs/log.h>
#include
<oblibs/string.h>
#include
<skalibs/cdb.h>
#include
<skalibs/djbunix.h>
#include
<66/resolve.h>
#include
<66/service.h>
...
...
@@ -29,57 +26,35 @@ int resolve_read_cdb(resolve_wrapper_t *wres, char const *path, const char *name
{
log_flow
()
;
int
fd
,
e
=
-
1
,
err
=
errno
;
char
file
[
strlen
(
path
)
+
strlen
(
name
)
+
1
]
;
int
fd
,
e
=
0
;
cdb
c
=
CDB_ZERO
;
errno
=
0
;
auto_strings
(
file
,
path
,
name
)
;
fd
=
open_readb
(
file
)
;
if
(
fd
<
0
)
{
log_warnusys
(
"open: "
,
file
)
;
if
(
errno
==
ENOENT
)
e
=
0
;
goto
err_fd
;
}
errno
=
err
;
e
=
resolve_open_cdb
(
&
fd
,
&
c
,
path
,
name
)
;
if
(
e
<=
0
)
return
e
;
if
(
!
cdb_init_fromfd
(
&
c
,
fd
))
{
log_warnusys
(
"cdb_init: "
,
file
)
;
goto
err
;
}
e
=
0
;
if
(
wres
->
type
==
DATA_SERVICE
)
{
if
(
!
service_resolve_read_cdb
(
&
c
,
((
resolve_service_t
*
)
wres
->
obj
)))
{
e
=
0
;
if
(
!
service_resolve_read_cdb
(
&
c
,
((
resolve_service_t
*
)
wres
->
obj
)))
goto
err
;
}
}
else
if
(
wres
->
type
==
DATA_TREE
){
if
(
!
tree_resolve_read_cdb
(
&
c
,
((
resolve_tree_t
*
)
wres
->
obj
)))
{
e
=
0
;
if
(
!
tree_resolve_read_cdb
(
&
c
,
((
resolve_tree_t
*
)
wres
->
obj
)))
goto
err
;
}
}
else
if
(
wres
->
type
==
DATA_TREE_MASTER
)
{
if
(
!
tree_resolve_master_read_cdb
(
&
c
,
((
resolve_tree_master_t
*
)
wres
->
obj
)))
{
e
=
0
;
if
(
!
tree_resolve_master_read_cdb
(
&
c
,
((
resolve_tree_master_t
*
)
wres
->
obj
)))
goto
err
;
}
}
e
=
1
;
err:
close
(
fd
)
;
err_fd:
cdb_free
(
&
c
)
;
return
e
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment