@@ -58,6 +58,8 @@ struct ldb_table oss_dependency;
5858struct ldb_table oss_license ;
5959struct ldb_table oss_attribution ;
6060struct ldb_table oss_cryptography ;
61+ struct ldb_table oss_sources ;
62+
6163component_item * ignore_components ;
6264component_item * declared_components ;
6365
@@ -66,6 +68,48 @@ uint8_t trace_id[MD5_LEN];
6668bool trace_on ;
6769bool lib_encoder_present = false;
6870#define LDB_VER_MIN "4.1.0"
71+
72+ void * lib_encoder_handle = NULL ;
73+ bool lib_encoder_load ()
74+ {
75+ #ifndef SCANOSS_ENCODER_VERSION
76+ /*set decode funtion pointer to NULL*/
77+ lib_encoder_handle = dlopen ("libscanoss_encoder.so" , RTLD_NOW );
78+ char * err ;
79+ if ((err = dlerror ()))
80+ {
81+ scanlog ("Lib scanoss-encoder was not detected. %s\n" , err );
82+ }
83+
84+ if (lib_encoder_handle )
85+ {
86+ scanlog ("Lib scanoss-encoder present\n" );
87+ decrypt_data = dlsym (lib_encoder_handle , "scanoss_decode_table" );
88+ decrypt_mz = dlsym (lib_encoder_handle , "scanoss_decode_mz" );
89+ encoder_version = dlsym (lib_encoder_handle , "scanoss_encoder_version" );
90+ if ((err = dlerror ()))
91+ {
92+ printf ("%s - You may need to update libscanoss_encoder.so\n" , err );
93+ exit (EXIT_FAILURE );
94+ }
95+
96+ char version [32 ] = "\0" ;
97+ encoder_version (version );
98+ scanlog ("Lib scanoss-encoder version %s\n" , version );
99+ return true;
100+ }
101+ decrypt_data = standalone_decrypt_data ;
102+ decrypt_mz = NULL ;
103+ return false;
104+ #else
105+ decrypt_data = scanoss_decode_table ;
106+ decrypt_mz = scanoss_decode_mz ;
107+ encoder_version = scanoss_encoder_version ;
108+ scanlog ("Using built-in encoder library v%s\n" , SCANOSS_ENCODER_VERSION );
109+ return false;
110+ #endif
111+ }
112+
69113/* Initialize tables for the DB name indicated (defaults to oss) */
70114void initialize_ldb_tables (char * name )
71115{
@@ -121,8 +165,13 @@ void initialize_ldb_tables(char *name)
121165 snprintf (dbtable , MAX_ARGLN * 2 , "%s/%s" , oss_db_name , "cryptography" );
122166 oss_cryptography = ldb_read_cfg (dbtable );
123167
168+ snprintf (dbtable , MAX_ARGLN * 2 , "%s/%s" , oss_db_name , "sources" );
169+ oss_sources = ldb_read_cfg (dbtable );
170+
124171 kb_version_get ();
125172 osadl_load_file ();
173+
174+ lib_encoder_present = lib_encoder_load ();
126175}
127176
128177/**
@@ -212,45 +261,6 @@ uint64_t read_flags()
212261 return 0 ;
213262}
214263
215-
216- void * lib_encoder_handle = NULL ;
217- bool lib_encoder_load ()
218- {
219- #ifndef SCANOSS_ENCODER_VERSION
220- /*set decode funtion pointer to NULL*/
221- lib_encoder_handle = dlopen ("libscanoss_encoder.so" , RTLD_NOW );
222- char * err ;
223- if ((err = dlerror ()))
224- {
225- scanlog ("Lib scanoss-encoder was not detected. %s\n" , err );
226- }
227-
228- if (lib_encoder_handle )
229- {
230- scanlog ("Lib scanoss-encoder present\n" );
231- decrypt_data = dlsym (lib_encoder_handle , "scanoss_decode_table" );
232- decrypt_mz = dlsym (lib_encoder_handle , "scanoss_decode_mz" );
233- encoder_version = dlsym (lib_encoder_handle , "scanoss_encoder_version" );
234- if ((err = dlerror ()))
235- {
236- printf ("%s - You may need to update libscanoss_encoder.so\n" , err );
237- exit (EXIT_FAILURE );
238- }
239- return true;
240- }
241- decrypt_data = standalone_decrypt_data ;
242- decrypt_mz = NULL ;
243- return false;
244- #else
245- decrypt_data = scanoss_decode_table ;
246- decrypt_mz = scanoss_decode_mz ;
247- encoder_version = scanoss_encoder_version ;
248- scanlog ("Using built-in encoder library v%s\n" , SCANOSS_ENCODER_VERSION );
249- return false;
250- #endif
251- }
252-
253-
254264/**
255265 * @brief //TODO
256266 * @param argc //TODO
@@ -429,14 +439,6 @@ int main(int argc, char **argv)
429439 /* Perform scan */
430440 else
431441 {
432- lib_encoder_present = lib_encoder_load ();
433- if (lib_encoder_present && debug_on )
434- {
435- char version [32 ] = "\0" ;
436- encoder_version (version );
437- scanlog ("Lib encoder present - version %s\n" , version );
438- }
439-
440442 /* Validate target */
441443 char * arg_target = argv [argc - 1 ];
442444 bool isfile = is_file (arg_target );
0 commit comments