Last change
on this file since 2446 was 465, checked in by bird, 22 years ago |
#579?: Detect if the file is a library and take appropriate actions.
|
-
Property cvs2svn:cvs-rev
set to
1.2
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
|
File size:
1.0 KB
|
Line | |
---|
1 | /* omflibam.c (emx+gcc) -- Copyright (c) 1993-1996 by Eberhard Mattes */
|
---|
2 |
|
---|
3 | /* Add an OBJ module to an OMFLIB. */
|
---|
4 |
|
---|
5 | #include <stdio.h>
|
---|
6 | #include <stdlib.h>
|
---|
7 | #include <string.h>
|
---|
8 | #include "omflib0.h"
|
---|
9 | #include <sys/omflib.h>
|
---|
10 |
|
---|
11 | int omflib_add_module (struct omflib *p, const char *fname, char *error)
|
---|
12 | {
|
---|
13 | FILE *f;
|
---|
14 | char name[256];
|
---|
15 | char obj_fname[256+4];
|
---|
16 | byte libhdr[1];
|
---|
17 | int ret;
|
---|
18 |
|
---|
19 | omflib_module_name (name, fname);
|
---|
20 | strcpy (obj_fname, fname);
|
---|
21 | _defext (obj_fname, "obj");
|
---|
22 | f = fopen (obj_fname, "rb");
|
---|
23 | if (f == NULL)
|
---|
24 | return omflib_set_error (error);
|
---|
25 |
|
---|
26 | /* this may be a library, check so we don't create invalid libraries
|
---|
27 | (#579?) */
|
---|
28 | if ( fread(&libhdr[0], sizeof(libhdr), 1, f) == 1
|
---|
29 | && libhdr[0] == LIBHDR
|
---|
30 | )
|
---|
31 | {
|
---|
32 | struct omflib * src = omflib_open (fname, error);
|
---|
33 | if (!src)
|
---|
34 | return -1;
|
---|
35 | ret = omflib_copy_lib(p, src, error);
|
---|
36 | omflib_close(src, error);
|
---|
37 | return ret;
|
---|
38 | }
|
---|
39 | fseek(f, 0, SEEK_SET);
|
---|
40 |
|
---|
41 | ret = omflib_copy_module (p, p->f, NULL, f, name, error);
|
---|
42 | fclose (f);
|
---|
43 | return ret;
|
---|
44 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.