00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "awk.h"
00030 #include <dlfcn.h>
00031
00032 static void *sdl = NULL;
00033
00034 static NODE *
00035 zaxxon(tree)
00036 NODE *tree;
00037 {
00038 NODE *obj;
00039 int i;
00040 int comma = 0;
00041
00042
00043
00044
00045 printf("External linkage %s(", tree->param);
00046
00047 for (i = 0; i < tree->param_cnt; i++) {
00048
00049 obj = get_argument(tree, i);
00050
00051 if (obj == NULL)
00052 break;
00053
00054 force_string(obj);
00055
00056 printf(comma ? ", %s" : "%s", obj->stptr);
00057 free_temp(obj);
00058 comma = 1;
00059 }
00060
00061 printf(");\n");
00062
00063
00064
00065
00066 obj = get_argument(tree, 0);
00067
00068 if (obj != NULL) {
00069 force_string(obj);
00070 if (strcmp(obj->stptr, "unload") == 0 && sdl) {
00071
00072
00073
00074
00075 dlclose(sdl);
00076 sdl = NULL;
00077 }
00078 free_temp(obj);
00079 }
00080
00081
00082 set_value(tmp_number((AWKNUM) 3.14));
00083
00084
00085 return tmp_number((AWKNUM) 0);
00086 }
00087
00088 NODE *
00089 dlload(tree, dl)
00090 NODE *tree;
00091 void *dl;
00092 {
00093 sdl = dl;
00094 make_builtin("zaxxon", zaxxon, 4);
00095 return tmp_number((AWKNUM) 0);
00096 }