Formatting: kill off "stealth whitespace"
[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 "compiler.h"
13
14 #include <stdio.h>
15 #include <string.h>
16 #include <inttypes.h>
17
18 #define BUILD_DRIVERS_ARRAY
19 #include "outform.h"
20
21 static int ndrivers = 0;
22
23 struct ofmt *ofmt_find(char *name)
24 {                               /* find driver */
25     int i;
26
27     for (i = 0; i < ndrivers; i++)
28         if (!strcmp(name, drivers[i]->shortname))
29             return drivers[i];
30
31     return NULL;
32 }
33 struct dfmt *dfmt_find(struct ofmt *ofmt, char *name)
34 {                               /* find driver */
35     struct dfmt **dfmt = ofmt->debug_formats;
36     while (*dfmt) {
37         if (!strcmp(name, (*dfmt)->shortname))
38             return (*dfmt);
39         dfmt++;
40     }
41     return NULL;
42 }
43
44 void ofmt_list(struct ofmt *deffmt, FILE * fp)
45 {
46     int i;
47     for (i = 0; i < ndrivers; i++)
48         fprintf(fp, "  %c %-10s%s\n",
49                 drivers[i] == deffmt ? '*' : ' ',
50                 drivers[i]->shortname, drivers[i]->fullname);
51 }
52 void dfmt_list(struct ofmt *ofmt, FILE * fp)
53 {
54     struct dfmt **drivers = ofmt->debug_formats;
55     while (*drivers) {
56         fprintf(fp, "  %c %-10s%s\n",
57                 drivers[0] == ofmt->current_dfmt ? '*' : ' ',
58                 drivers[0]->shortname, drivers[0]->fullname);
59         drivers++;
60     }
61 }
62 struct ofmt *ofmt_register(efunc error)
63 {
64     for (ndrivers = 0; drivers[ndrivers] != NULL; ndrivers++) ;
65
66     if (ndrivers == 0) {
67         error(ERR_PANIC | ERR_NOFILE,
68               "No output drivers given at compile time");
69     }
70
71     return (&OF_DEFAULT);
72 }