Regenerate META.yml
[p5sagit/p5-mst-13.2.git] / beos / nm.c
CommitLineData
c4f23d77 1/* nm.c - a feeble shared-lib library parser
2 * Copyright 1997, 1998 Tom Spindler
3 * This software is covered under perl's Artistic license.
4 */
5
6/* $Id: nm.c,v 1.1 1998/02/16 03:51:26 dogcow Exp $ */
7
8#include <be/kernel/image.h>
9#include <malloc.h>
10#include <string.h>
11#include <unistd.h>
12#include <stdio.h>
13#include <stdlib.h>
14
15main(int argc, char **argv) {
16char *path, *symname;
17image_id img;
18int32 n = 0;
19volatile int32 symnamelen, symtype;
20void *symloc;
21
22if (argc != 2) { printf("more args, bozo\n"); exit(1); }
23
24path = (void *) malloc((size_t) 2048);
25symname = (void *) malloc((size_t) 2048);
26
27if (!getcwd(path, 2048)) { printf("aiee!\n"); exit(1); }
28if (!strcat(path, "/")) {printf("naah.\n"); exit (1); }
29/*printf("%s\n",path);*/
30
31if ('/' != argv[1][0]) {
32 if (!strcat(path, argv[1])) { printf("feh1\n"); exit(1); }
33} else {
34 if (!strcpy(path, argv[1])) { printf("gah!\n"); exit(1); }
35}
36/*printf("%s\n",path);*/
37
38img = load_add_on(path);
39if (B_ERROR == img) {printf("Couldn't load_add_on() %s.\n", path); exit(2); }
40
41symnamelen=2047;
42
43while (B_BAD_INDEX != get_nth_image_symbol(img, n++, symname, &symnamelen,
44 &symtype, &symloc)) {
45 printf("%s |%s |GLOB %Lx | \n", symname,
46 ((B_SYMBOL_TYPE_ANY == symtype) || (B_SYMBOL_TYPE_TEXT == symtype)) ? "FUNC" : "VAR ", symloc);
47 symnamelen=2047;
48}
49printf("number of symbols: %d\n", n);
50if (B_ERROR == unload_add_on(img)) {printf("err while closing.\n"); exit(3); }
51free(path);
52return(0);
53}