Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
require
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
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
Code review analytics
Issue 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
epics-modules
require
Commits
3167af91
Commit
3167af91
authored
20 years ago
by
zimoch
Browse files
Options
Downloads
Patches
Plain Diff
load libs and dbd if not already done and check versions
parent
0e37f621
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
require.c
+85
-0
85 additions, 0 deletions
require.c
with
85 additions
and
0 deletions
require.c
0 → 100644
+
85
−
0
View file @
3167af91
#include
<symLib.h>
#include
<sysSymTbl.h>
#include
<stdio.h>
#include
<string.h>
#include
<shellLib.h>
#include
<usrLib.h>
int
dbLoadDatabase
(
char
*
filename
,
char
*
path
,
char
*
substitutions
);
int
require
(
char
*
lib
,
char
*
version
)
{
char
libname
[
256
];
char
dbdname
[
256
];
char
symbol
[
256
];
char
**
path
;
char
*
loaded
;
SYM_TYPE
type
;
if
(
symFindByName
(
sysSymTbl
,
"LIB"
,
(
char
**
)
&
path
,
&
type
)
!=
OK
)
{
static
char
*
here
=
"."
;
path
=
&
here
;
}
if
(
!
lib
)
{
printf
(
"Usage: require
\"
<libname>
\"
[,
\"
<version>
\"
]
\n
"
);
printf
(
"Loads <libname>Lib[-<version>] and dbd/<libname>[-<version>].dbd
\n
"
);
printf
(
"Directory is LIB = %s
\n
"
,
*
path
);
return
ERROR
;
}
sprintf
(
symbol
,
"_%sLibRelease"
,
lib
);
if
(
version
)
{
sprintf
(
libname
,
"%s/%sLib-%s"
,
*
path
,
lib
,
version
);
sprintf
(
dbdname
,
"%s/dbd/%s-%s.dbd"
,
*
path
,
lib
,
version
);
}
else
{
sprintf
(
libname
,
"%s/%sLib"
,
*
path
,
lib
);
sprintf
(
dbdname
,
"%s/dbd/%s.dbd"
,
*
path
,
lib
);
}
if
(
symFindByName
(
sysSymTbl
,
symbol
,
&
loaded
,
&
type
)
!=
OK
)
{
/* Load library and dbd file of requested version */
if
(
ld
(
0
,
0
,
libname
)
==
NULL
)
{
printf
(
"%s not loaded
\n
"
,
libname
);
return
ERROR
;
}
printf
(
"%s loaded
\n
"
,
libname
);
if
(
dbLoadDatabase
(
dbdname
,
NULL
,
NULL
)
!=
OK
)
{
printf
(
"%s not loaded
\n
"
,
dbdname
);
return
ERROR
;
}
printf
(
"%s loaded
\n
"
,
dbdname
);
return
OK
;
}
else
{
/* Library already loaded. Check Version. */
if
(
version
&&
strcmp
(
loaded
,
version
)
!=
0
)
{
int
lmajor
,
lminor
,
lpatch
,
lmatches
;
int
major
,
minor
,
patch
,
matches
;
lmatches
=
sscanf
(
loaded
,
"%d.%d.%d"
,
&
lmajor
,
&
lminor
,
&
lpatch
);
matches
=
sscanf
(
version
,
"%d.%d.%d"
,
&
major
,
&
minor
,
&
patch
);
if
(
matches
==
0
||
lmatches
==
0
/* non-numerical version*/
||
major
!=
lmajor
||
(
matches
>=
2
&&
minor
!=
lminor
)
||
(
matches
>
2
&&
patch
!=
lpatch
))
{
printf
(
"Conflict between requested %s
\n
and already loaded version %s
\n
"
,
libname
,
loaded
);
shellScriptAbort
();
return
ERROR
;
}
}
/* Loaded version is ok */
printf
(
"%sLib-%s already loaded
\n
"
,
lib
,
loaded
);
return
OK
;
}
}
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