Main Page | Class List | Directories | File List | Class Members | File Members

dl.c File Reference

#include "awk.h"
#include <dlfcn.h>

Go to the source code of this file.

Functions

static NODEzaxxon (NODE *tree)
NODEdlload (NODE *tree, void *dl)

Variables

static void * sdl = NULL


Function Documentation

NODE* dlload NODE tree,
void *  dl
 

Definition at line 89 of file dl.c.

References AWKNUM, sdl, tmp_number, and zaxxon().

00092 {
00093         sdl = dl;
00094         make_builtin("zaxxon", zaxxon, 4);
00095         return tmp_number((AWKNUM) 0);
00096 }

static NODE* zaxxon NODE tree  )  [static]
 

Definition at line 35 of file dl.c.

References AWKNUM, dlclose(), force_string, free_temp, i, NULL, param_cnt, sdl, and tmp_number.

Referenced by dlload().

00037 {
00038         NODE *obj;
00039         int i;
00040         int comma = 0;
00041 
00042         /*
00043          * Print the arguments
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          * Do something useful
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                          * XXX: How to clean up the function? 
00073                          * I would like the ability to remove a function...
00074                          */
00075                         dlclose(sdl);
00076                         sdl = NULL;
00077                 }
00078                 free_temp(obj);
00079         }
00080 
00081         /* Set the return value */
00082         set_value(tmp_number((AWKNUM) 3.14));
00083 
00084         /* Just to make the interpreter happy */
00085         return tmp_number((AWKNUM) 0);
00086 }


Variable Documentation

void* sdl = NULL [static]
 

Definition at line 32 of file dl.c.

Referenced by dlload(), and zaxxon().


© sourcejam.com 2005-2008