]> git.saurik.com Git - apple/boot.git/blob - i386/nasm/outform.c
5b4cc161d7212244a7c3675502586c3680e63de2
[apple/boot.git] / i386 / nasm / outform.c
1 /*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /* outform.c manages a list of output formats, and associates
26 * them with their relevant drivers. Also has a
27 * routine to find the correct driver given a name
28 * for it
29 *
30 * The Netwide Assembler is copyright (C) 1996 Simon Tatham and
31 * Julian Hall. All rights reserved. The software is
32 * redistributable under the licence given in the file "Licence"
33 * distributed in the NASM archive.
34 */
35
36 #include <stdio.h>
37 #include <string.h>
38 #include "outform.h"
39
40 static struct ofmt *drivers[MAX_OUTPUT_FORMATS];
41 static int ndrivers = 0;
42
43 struct ofmt *ofmt_find(char *name) /* find driver */
44 {
45 int i;
46
47 for (i=0; i<ndrivers; i++)
48 if (!strcmp(name,drivers[i]->shortname))
49 return drivers[i];
50
51 return NULL;
52 }
53
54 void ofmt_list(struct ofmt *deffmt, FILE *fp)
55 {
56 int i;
57 for (i=0; i<ndrivers; i++)
58 fprintf(fp, " %c %-7s%s\n",
59 drivers[i] == deffmt ? '*' : ' ',
60 drivers[i]->shortname,
61 drivers[i]->fullname);
62 }
63
64 void ofmt_register (struct ofmt *info) {
65 drivers[ndrivers++] = info;
66 }