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
f8924f9e
Commit
f8924f9e
authored
6 years ago
by
Eric Vidal
Browse files
Options
Downloads
Patches
Plain Diff
add db_write_master
parent
ecf0591f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lib66/db_cmd_master.c
+74
-1
74 additions, 1 deletion
src/lib66/db_cmd_master.c
with
74 additions
and
1 deletion
src/lib66/db_cmd_master.c
+
74
−
1
View file @
f8924f9e
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
#include
<66/utils.h>
#include
<66/utils.h>
#include
<66/graph.h>
#include
<66/graph.h>
//
#include <stdio.h>
#include
<stdio.h>
//USAGE "db_update_start [ -v verbosity ] [ -a add ] [ -d delete ] [ -c copy to ] [ -B bundle ] [ -D directory ] service"
//USAGE "db_update_start [ -v verbosity ] [ -a add ] [ -d delete ] [ -c copy to ] [ -B bundle ] [ -D directory ] service"
// -c -> copy the contents file to the given directory, in this case service is not mandatory
// -c -> copy the contents file to the given directory, in this case service is not mandatory
int
db_update_master
(
int
argc
,
char
const
*
const
*
argv
)
int
db_update_master
(
int
argc
,
char
const
*
const
*
argv
)
...
@@ -350,3 +350,76 @@ int db_write_contents(genalloc *ga, char const *bundle,char const *dir)
...
@@ -350,3 +350,76 @@ int db_write_contents(genalloc *ga, char const *bundle,char const *dir)
stralloc_free
(
&
in
)
;
stralloc_free
(
&
in
)
;
return
0
;
return
0
;
}
}
int
db_write_master
(
ssexec_t
*
info
,
genalloc
*
ga
,
char
const
*
dir
)
{
int
r
;
stralloc
in
=
STRALLOC_ZERO
;
stralloc
inres
=
STRALLOC_ZERO
;
ss_resolve_t
res
=
RESOLVE_ZERO
;
size_t
dirlen
=
strlen
(
dir
)
;
char
runat
[
info
->
livetree
.
len
+
1
+
info
->
treename
.
len
+
SS_SVDIRS_LEN
+
SS_MASTER_LEN
+
1
]
;
memcpy
(
runat
,
info
->
livetree
.
s
,
info
->
livetree
.
len
)
;
runat
[
info
->
livetree
.
len
]
=
'/'
;
memcpy
(
runat
+
info
->
livetree
.
len
+
1
,
info
->
treename
.
s
,
info
->
treename
.
len
)
;
memcpy
(
runat
+
info
->
livetree
.
len
+
1
+
info
->
treename
.
len
,
SS_SVDIRS
,
SS_SVDIRS_LEN
)
;
memcpy
(
runat
+
info
->
livetree
.
len
+
1
+
info
->
treename
.
len
+
SS_SVDIRS_LEN
,
SS_MASTER
,
SS_MASTER_LEN
)
;
runat
[
info
->
livetree
.
len
+
1
+
info
->
treename
.
len
+
SS_SVDIRS_LEN
+
SS_MASTER_LEN
]
=
0
;
char
dst
[
dirlen
+
SS_DB_LEN
+
SS_SRC_LEN
+
SS_MASTER_LEN
+
1
]
;
memcpy
(
dst
,
dir
,
dirlen
)
;
memcpy
(
dst
+
dirlen
,
SS_DB
,
SS_DB_LEN
)
;
memcpy
(
dst
+
dirlen
+
SS_DB_LEN
,
SS_SRC
,
SS_SRC_LEN
)
;
memcpy
(
dst
+
dirlen
+
SS_DB_LEN
+
SS_SRC_LEN
,
SS_MASTER
,
SS_MASTER_LEN
)
;
dst
[
dirlen
+
SS_DB_LEN
+
SS_SRC_LEN
+
SS_MASTER_LEN
]
=
0
;
for
(
unsigned
int
i
=
0
;
i
<
genalloc_len
(
stralist
,
ga
);
i
++
)
{
if
(
!
stralloc_cats
(
&
in
,
gaistr
(
ga
,
i
)))
goto
err
;
if
(
!
stralloc_cats
(
&
in
,
"
\n
"
))
goto
err
;
if
(
!
stralloc_cats
(
&
inres
,
gaistr
(
ga
,
i
)))
goto
err
;
if
(
!
stralloc_cats
(
&
inres
,
" "
))
goto
err
;
}
inres
.
len
--
;
if
(
!
stralloc_0
(
&
inres
))
goto
err
;
r
=
file_write_unsafe
(
dst
,
SS_CONTENTS
,
in
.
s
,
in
.
len
)
;
if
(
!
r
)
{
VERBO3
strerr_warnwu3sys
(
"write: "
,
dst
,
"contents"
)
;
goto
err
;
}
ss_resolve_init
(
&
res
)
;
res
.
name
=
ss_resolve_add_string
(
&
res
,
"Master"
)
;
res
.
description
=
ss_resolve_add_string
(
&
res
,
"inner bundle - do not use it"
)
;
res
.
treename
=
ss_resolve_add_string
(
&
res
,
info
->
treename
.
s
)
;
res
.
tree
=
ss_resolve_add_string
(
&
res
,
info
->
tree
.
s
)
;
res
.
type
=
BUNDLE
;
res
.
deps
=
ss_resolve_add_string
(
&
res
,
inres
.
s
)
;
res
.
ndeps
=
genalloc_len
(
stralist
,
ga
)
;
res
.
runat
=
ss_resolve_add_string
(
&
res
,
runat
)
;
res
.
disen
=
1
;
res
.
init
=
0
;
res
.
unsupervise
=
0
;
res
.
reload
=
0
;
if
(
!
ss_resolve_write
(
&
res
,
dir
,
"Master"
))
goto
err
;
stralloc_free
(
&
in
)
;
stralloc_free
(
&
inres
)
;
ss_resolve_free
(
&
res
)
;
return
1
;
err:
ss_resolve_free
(
&
res
)
;
stralloc_free
(
&
in
)
;
stralloc_free
(
&
inres
)
;
return
0
;
}
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