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
0b239cf8
Commit
0b239cf8
authored
2 years ago
by
Eric Vidal
Browse files
Options
Downloads
Patches
Plain Diff
Provide a current tree by default. End of use of tree path
parent
9f097519
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lib66/tree/tree_sethome.c
+20
-20
20 additions, 20 deletions
src/lib66/tree/tree_sethome.c
src/lib66/tree/tree_setname.c
+0
-39
0 additions, 39 deletions
src/lib66/tree/tree_setname.c
with
20 additions
and
59 deletions
src/lib66/tree/tree_sethome.c
+
20
−
20
View file @
0b239cf8
...
...
@@ -18,15 +18,14 @@
#include
<oblibs/log.h>
#include
<oblibs/string.h>
#include
<66/config.h>
#include
<66/constants.h>
#include
<66/ssexec.h>
#include
<66/tree.h>
/**
* @Return -3 > unable to find current
* @Return -2 > unable to fix tree name
* @Return -1 > unable to parse seed file
* @Return 0 > tree doesn't exist
* @Return -1 > error system
* @Return 0 > unable to find seed file
* @Return 1 > success */
int
tree_sethome
(
ssexec_t
*
info
)
{
...
...
@@ -38,15 +37,22 @@ int tree_sethome(ssexec_t *info)
if
(
!
info
->
opt_tree
)
{
if
(
!
tree_find_current
(
&
info
->
tree
,
base
))
{
/** no current tree found. Use the default one. */
info
->
tree
.
len
=
0
;
if
(
!
auto_stra
(
&
info
->
tree
,
base
,
SS_SYSTEM
,
"/"
,
SS_DEFAULT_TREENAME
)
)
return
0
;
}
char
t
[
SS_MAX_TREENAME
+
1
]
;
r
=
tree_find_current
(
t
,
base
)
;
if
(
r
<
0
)
return
-
1
;
info
->
treename
.
len
=
0
;
if
(
!
tree_setname
(
&
info
->
treename
,
info
->
tree
.
s
))
return
-
2
;
if
(
!
r
)
{
/** no current tree found. Use the default one.*/
if
(
!
auto_stra
(
&
info
->
treename
,
SS_DEFAULT_TREENAME
))
return
-
1
;
}
else
{
if
(
!
auto_stra
(
&
info
->
treename
,
t
))
return
-
1
;
}
}
else
{
...
...
@@ -56,7 +62,7 @@ int tree_sethome(ssexec_t *info)
/** The tree name exist on the system
* but it's not a directory */
errno
=
EEXIST
;
return
0
;
return
-
1
;
}
else
if
(
!
r
)
{
...
...
@@ -77,16 +83,10 @@ int tree_sethome(ssexec_t *info)
char
const
*
prog
=
PROG
;
PROG
=
"tree"
;
if
(
ssexec_tree_admin
(
nargc
,
newargv
,
info
))
log_warnu_return
(
LOG_EXIT_
ZERO
,
"create tree: "
,
info
->
treename
.
s
)
;
log_warnu_return
(
LOG_EXIT_
LESSONE
,
"create tree: "
,
info
->
treename
.
s
)
;
PROG
=
prog
;
}
/** The tree_sethome() function can be recursively called. The info->tree may not be empty.
* Be sure to clean up before using it. */
info
->
tree
.
len
=
0
;
if
(
!
auto_stra
(
&
info
->
tree
,
base
,
SS_SYSTEM
,
"/"
,
info
->
treename
.
s
))
log_warnsys_return
(
LOG_EXIT_ZERO
,
"stralloc"
)
;
}
return
1
;
...
...
This diff is collapsed.
Click to expand it.
src/lib66/tree/tree_setname.c
deleted
100644 → 0
+
0
−
39
View file @
9f097519
/*
* tree_setname.c
*
* Copyright (c) 2018-2021 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
<66/tree.h>
#include
<string.h>
#include
<sys/types.h>
//ssize
#include
<oblibs/string.h>
#include
<oblibs/log.h>
#include
<skalibs/stralloc.h>
char
tree_setname
(
stralloc
*
sa
,
char
const
*
tree
)
{
log_flow
()
;
size_t
tlen
=
strlen
(
tree
)
;
ssize_t
treelen
=
get_rlen_until
(
tree
,
'/'
,
tlen
)
;
if
(
treelen
<=
0
)
return
0
;
treelen
++
;
size_t
treenamelen
=
tlen
-
treelen
;
if
(
!
stralloc_catb
(
sa
,
tree
+
treelen
,
treenamelen
))
return
0
;
if
(
!
stralloc_0
(
sa
))
return
0
;
sa
->
len
--
;
return
1
;
}
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