Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
python-cellframe
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container 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
cellframe
python-cellframe
Commits
b3a9cdb8
Commit
b3a9cdb8
authored
5 years ago
by
alexey.stratulat
Browse files
Options
Downloads
Patches
Plain Diff
[*] Fix. Translated use for building a list of manifests from dap_list _t to utlist.
parent
e5434255
No related branches found
Branches containing commit
No related tags found
1 merge request
!27
Support update sdk and merge plugins repo
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/dap_chain_plugins_manifest.h
+17
-22
17 additions, 22 deletions
include/dap_chain_plugins_manifest.h
src/dap_chain_plugins_manifest.c
+38
-51
38 additions, 51 deletions
src/dap_chain_plugins_manifest.c
with
55 additions
and
73 deletions
include/dap_chain_plugins_manifest.h
+
17
−
22
View file @
b3a9cdb8
#ifndef _DAP_CHAIN_PLUGINS_MANIFEST_
#ifndef _DAP_CHAIN_PLUGINS_MANIFEST_
#define _DAP_CHAIN_PLUGINS_MANIFEST_
#define _DAP_CHAIN_PLUGINS_MANIFEST_
#include
"dap_common.h"
#include
"dap_common.h"
#include
"dap_list.h"
#include
"dap_strfuncs.h"
#include
"dap_strfuncs.h"
#include
"stdio.h"
#include
"stdio.h"
#include
"json-c/json_object.h"
#include
"json-c/json_object.h"
#include
"json-c/json_tokener.h"
#include
"json-c/json_tokener.h"
#include
"utlist.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
...
@@ -14,37 +14,32 @@ extern "C"{
...
@@ -14,37 +14,32 @@ extern "C"{
#undef LOG_TAG
#undef LOG_TAG
#define LOG_TAG "dap_chain_plugins_manifest"
#define LOG_TAG "dap_chain_plugins_manifest"
enum
data_in_manifest
{
typedef
struct
dap_chain_plugins_list_char
{
NAME
,
char
*
value
;
VERSION
,
struct
dap_chain_plugins_list_char
*
next
;
DEPENDENCYS
,
}
dap_chain_plugins_list_char_t
;
AUTHOR
,
DESCRIPTION
};
typedef
struct
manifest
{
typedef
struct
dap_list_
manifest
{
char
*
name
;
char
*
name
;
char
*
version
;
char
*
version
;
dap_list_t
*
dependencys
;
char
*
author
;
char
*
author
;
char
*
description
;
char
*
description
;
bool
init
;
dap_chain_plugins_list_char_t
*
dependencys
;
}
manifest_t
;
struct
dap_list_manifest
*
next
;
}
dap_chain_plugins_list_manifest_t
;
manifest_t
*
dap_chain_plugins_manifest_new
(
const
char
*
name
,
const
char
*
version
,
const
dap_list_t
*
dep
,
const
char
*
author
,
dap_chain_plugins_list_manifest_t
*
manifests
;
const
char
*
description
);
void
dap_chain_plugins_manifest_free
(
manifest_t
*
manifest
);
manifest_t
*
dap_chain_plugins_add_manifest_from_file
(
const
char
*
file_path
);
static
dap_list_t
*
manifests
;
dap_chain_plugins_list_manifest_t
*
dap_chain_plugins_manifest_new
(
const
char
*
name
,
const
char
*
version
,
const
dap_chain_plugins_list_char_t
*
dep
,
const
char
*
author
,
const
char
*
description
);
void
dap_chain_plugins_manifest_list_create
();
void
dap_chain_plugins_manifest_list_create
();
manifest_t
*
dap_chain_plugins_manifest_get_list
(
size_t
index
);
unsigned
int
dap_chain_plugins_manifests_get_lenght
();
void
dap_chain_plugins_manifest_list_free
();
void
dap_chain_plugins_manifest_list_add_manifest
(
manifest_t
*
manifest
);
bool
dap_chain_plugins_manifest_list_add_from_file
(
const
char
*
file_path
);
dap_chain_plugins_list_manifest_t
*
dap_chain_plugins_manifests_get_list
();
dap_chain_plugins_list_manifest_t
*
dap_chain_plugins_add_manifest_from_file
(
const
char
*
file_path
);
bool
dap_chain_plugins_manifest_list_add_from_file
(
const
char
*
path_file
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
This diff is collapsed.
Click to expand it.
src/dap_chain_plugins_manifest.c
+
38
−
51
View file @
b3a9cdb8
#include
"dap_chain_plugins_manifest.h"
#include
"dap_chain_plugins_manifest.h"
dap_list_t
*
JSON_array_to_dap_list
(
json_object
*
obj
){
dap_chain_plugins_list_manifest_t
*
dap_chain_plugins_manifest_new
(
const
char
*
name
,
const
char
*
version
,
const
dap_chain_plugins_list_char_t
*
dep
,
const
char
*
author
,
int
len
=
json_object_array_length
(
obj
);
const
char
*
description
){
dap_list_t
*
list
=
NULL
;
dap_chain_plugins_list_manifest_t
*
man
=
(
dap_chain_plugins_list_manifest_t
*
)
DAP_NEW
(
dap_chain_plugins_list_manifest_t
);
json_object
*
j_data
;
man
->
name
=
dap_strdup
(
name
);
char
*
data
;
man
->
author
=
dap_strdup
(
author
);
for
(
int
i
=
0
;
i
<
len
;
i
++
){
man
->
version
=
dap_strdup
(
version
);
j_data
=
json_object_array_get_idx
(
obj
,
i
);
man
->
description
=
dap_strdup
(
description
);
data
=
dap_strdup
(
json_object_get_string
(
j_data
));
man
->
dependencys
=
NULL
;
dap_list_append
(
list
,
data
);
//copy informantion from dep to man->dependencys
int
len_dep
;
dap_chain_plugins_list_char_t
*
char_t
;
LL_COUNT
((
dap_chain_plugins_list_char_t
*
)
dep
,
char_t
,
len_dep
);
LL_FOREACH
((
dap_chain_plugins_list_char_t
*
)
dep
,
char_t
){
LL_APPEND
(
man
->
dependencys
,
char_t
);
}
}
return
list
;
man
->
dependencys
=
(
dap_chain_plugins_list_char_t
*
)
dep
;
return
man
;
}
}
manifest_t
*
dap_chain_plugins_manifest_new
(
const
char
*
name
,
const
char
*
version
,
const
dap_list_t
*
dep
,
const
char
*
author
,
static
dap_chain_plugins_list_char_t
*
JSON_array_to_dap_list_char
(
json_object
*
j_obj
){
const
char
*
description
){
dap_chain_plugins_list_char_t
*
list
=
NULL
;
manifest_t
*
manifest
=
(
manifest_t
*
)
malloc
(
sizeof
(
manifest_t
));
//DAP_NEW(manifest_t);
dap_chain_plugins_list_char_t
*
element
=
NULL
;
manifest
->
name
=
dap_strdup
(
name
);
for
(
int
i
=
0
;
i
<
json_object_array_length
(
j_obj
);
i
++
){
manifest
->
version
=
dap_strdup
(
version
);
element
=
(
dap_chain_plugins_list_char_t
*
)
DAP_NEW
(
dap_chain_plugins_list_char_t
);
manifest
->
dependencys
=
dap_list_copy
((
dap_list_t
*
)
dep
);
element
->
value
=
dap_strdup
(
json_object_get_string
(
json_object_array_get_idx
(
j_obj
,
i
)));
manifest
->
author
=
dap_strdup
(
author
);
LL_APPEND
(
list
,
element
);
manifest
->
description
=
dap_strdup
(
description
);
}
manifest
->
init
=
false
;
return
list
;
return
manifest
;
}
}
void
dap_chain_plugins_manifest_free
(
manifest_t
*
manifest
){
free
(
manifest
->
name
);
void
dap_chain_plugins_manifest_list_create
(){
free
(
manifest
->
version
);
manifests
=
NULL
;
free
(
manifest
->
author
);
free
(
manifest
->
description
);
dap_list_free
(
manifest
->
dependencys
);
free
(
manifest
);
}
}
manifest_t
*
dap_chain_plugins_add_manifest_from_file
(
const
char
*
file_path
){
dap_chain_plugins_list_manifest_t
*
dap_chain_plugins_add_manifest_from_file
(
const
char
*
file_path
){
//READ File in char
//READ File in char
log_it
(
L_INFO
,
"Parse json file"
);
log_it
(
L_INFO
,
"Parse json file"
);
FILE
*
file
=
fopen
(
file_path
,
"rt"
);
FILE
*
file
=
fopen
(
file_path
,
"rt"
);
...
@@ -58,38 +60,23 @@ manifest_t* dap_chain_plugins_add_manifest_from_file(const char *file_path){
...
@@ -58,38 +60,23 @@ manifest_t* dap_chain_plugins_add_manifest_from_file(const char *file_path){
version
=
json_object_get_string
(
j_version
);
version
=
json_object_get_string
(
j_version
);
author
=
json_object_get_string
(
j_author
);
author
=
json_object_get_string
(
j_author
);
description
=
json_object_get_string
(
j_description
);
description
=
json_object_get_string
(
j_description
);
dap_
list
_t
*
dep
=
JSON_array_to_dap_list
(
j_dependencys
);
dap_
chain_plugins_list_char
_t
*
dep
=
JSON_array_to_dap_list
_char
(
j_dependencys
);
DAP_FREE
(
json
);
DAP_FREE
(
json
);
manifest_t
*
manifest
=
dap_chain_plugins_manifest_new
(
name
,
version
,
dep
,
author
,
description
);
dap_chain_plugins_list_char_t
*
tmp
=
NULL
;
dap_chain_plugins_list_manifest_t
*
manifest
=
dap_chain_plugins_manifest_new
(
name
,
version
,
dep
,
author
,
description
);
return
manifest
;
return
manifest
;
}
}
//--------------------------------------------------------
void
dap_chain_plugins_manifest_list_add_manifest
(
dap_chain_plugins_list_manifest_t
*
man
){
void
dap_chain_plugins_manifest_list_create
(){
LL_APPEND
(
manifests
,
man
);
manifests
=
NULL
;
}
manifest_t
*
dap_chain_plugins_manifest_get_list
(
size_t
index
){
return
(
manifest_t
*
)
dap_list_nth_data
(
manifests
,
(
unsigned
int
)
index
);
}
}
unsigned
int
dap_chain_plugins_manifests_get_l
engh
t
(){
dap_chain_plugins_list_manifest_t
*
dap_chain_plugins_manifests_get_l
is
t
(){
return
dap_list_length
(
manifests
)
;
return
manifests
;
}
}
void
dap_chain_plugins_manifest_list_free
(){
unsigned
int
len
=
dap_list_length
(
manifests
);
for
(
unsigned
int
i
=
0
;
i
<
len
;
i
++
){
manifest_t
*
manifest
=
dap_list_nth_data
(
manifests
,
i
);
dap_chain_plugins_manifest_free
(
manifest
);
}
dap_list_free
(
manifests
);
}
void
dap_chain_plugins_manifest_list_add_manifest
(
manifest_t
*
manifest
){
manifests
=
dap_list_append
(
manifests
,
manifest
);
}
bool
dap_chain_plugins_manifest_list_add_from_file
(
const
char
*
file_path
){
bool
dap_chain_plugins_manifest_list_add_from_file
(
const
char
*
file_path
){
manifest_t
*
manifest
=
dap_chain_plugins_add_manifest_from_file
(
file_path
);
dap_chain_plugins_list_
manifest_t
*
manifest
=
dap_chain_plugins_add_manifest_from_file
(
file_path
);
if
(
manifest
==
NULL
)
if
(
manifest
==
NULL
)
return
false
;
return
false
;
dap_chain_plugins_manifest_list_add_manifest
(
manifest
);
dap_chain_plugins_manifest_list_add_manifest
(
manifest
);
...
...
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