Fixed distinction between char and int8_t data types.
[platform/upstream/nasm.git] / outform.c
1 /* outform.c    manages a list of output formats, and associates
2  *              them with their relevant drivers. Also has a
3  *              routine to find the correct driver given a name
4  *              for it
5  *
6  * The Netwide Assembler is copyright (C) 1996 Simon Tatham and
7  * Julian Hall. All rights reserved. The software is
8  * redistributable under the licence given in the file "Licence"
9  * distributed in the NASM archive.
10  */
11
12 #include <stdio.h>
13 #include <string.h>
14 #include <inttypes.h>
15
16 #define BUILD_DRIVERS_ARRAY
17 #include "outform.h"
18
19 static int ndrivers = 0;
20
21 struct ofmt *ofmt_find(char *name)
22 {                               /* find driver */
23     int i;
24
25     for (i = 0; i < ndrivers; i++)
26         if (!strcmp(name, drivers[i]->shortname))
27             return drivers[i];
28
29     return NULL;
30 }
31 struct dfmt *dfmt_find(struct ofmt *ofmt, char *name)
32 {                               /* find driver */
33     struct dfmt **dfmt = ofmt->debug_formats;
34     while (*dfmt) {
35         if (!strcmp(name, (*dfmt)->shortname))
36             return (*dfmt);
37         dfmt++;
38     }
39     return NULL;
40 }
41
42 void ofmt_list(struct ofmt *deffmt, FILE * fp)
43 {
44     int i;
45     for (i = 0; i < ndrivers; i++)
46         fprintf(fp, "  %c %-10s%s\n",
47                 drivers[i] == deffmt ? '*' : ' ',
48                 drivers[i]->shortname, drivers[i]->fullname);
49 }
50 void dfmt_list(struct ofmt *ofmt, FILE * fp)
51 {
52     struct dfmt **drivers = ofmt->debug_formats;
53     while (*drivers) {
54         fprintf(fp, "  %c %-10s%s\n",
55                 drivers[0] == ofmt->current_dfmt ? '*' : ' ',
56                 drivers[0]->shortname, drivers[0]->fullname);
57         drivers++;
58     }
59 }
60 struct ofmt *ofmt_register(efunc error)
61 {
62     for (ndrivers = 0; drivers[ndrivers] != NULL; ndrivers++) ;
63
64     if (ndrivers == 0) {
65         error(ERR_PANIC | ERR_NOFILE,
66               "No output drivers given at compile time");
67     }
68
69     return (&OF_DEFAULT);
70 }