NASM 0.95
[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 "outform.h"
15
16 static struct ofmt *drivers[MAX_OUTPUT_FORMATS];
17 static int ndrivers = 0;
18
19 struct ofmt *ofmt_find(char *name)     /* find driver */
20 {
21     int i;
22
23     for (i=0; i<ndrivers; i++)
24         if (!strcmp(name,drivers[i]->shortname))
25             return drivers[i];
26
27     return NULL;
28 }
29
30 void ofmt_list(struct ofmt *deffmt, FILE *fp)
31 {
32     int i;
33     for (i=0; i<ndrivers; i++)
34         fprintf(fp, "  %c %-7s%s\n",
35                 drivers[i] == deffmt ? '*' : ' ',
36                 drivers[i]->shortname,
37                 drivers[i]->fullname);
38 }
39
40 void ofmt_register (struct ofmt *info) {
41     drivers[ndrivers++] = info;
42 }