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