dynamically add functions to a program
Electrodude
Posts: 1,665
Hi
In Mike G's server, there is a dispatcher function which basically looks at the path of the request and, if it is a dynamic page, calls the appropriate function, and otherwise calls the normal file server function. I think that if I added a couple dummy functions and remembered their IDs then I could dynamically change the dispatcher by writing the new dynamic page's function and the new dispatcher to a heap and then replacing the entries in the method table of one of the dummy functions and the old dispatcher with entries pointing to the new ones then it would work. The only problems I can see with this method is that 1) you might run out of dummy functions and 2) you would probably have to manually tell the program (in the CON block) which function is the dispatcher and which ones are dummies. For problem 2 you might be able to put a special command at the beginning (eg repeat while 0 or dummy:=special number) of the dispatcher and dummy functions and have the init program search for them on startup.
Anyone see any other problems and/or need a better explanation?
Thanks
In Mike G's server, there is a dispatcher function which basically looks at the path of the request and, if it is a dynamic page, calls the appropriate function, and otherwise calls the normal file server function. I think that if I added a couple dummy functions and remembered their IDs then I could dynamically change the dispatcher by writing the new dynamic page's function and the new dispatcher to a heap and then replacing the entries in the method table of one of the dummy functions and the old dispatcher with entries pointing to the new ones then it would work. The only problems I can see with this method is that 1) you might run out of dummy functions and 2) you would probably have to manually tell the program (in the CON block) which function is the dispatcher and which ones are dummies. For problem 2 you might be able to put a special command at the beginning (eg repeat while 0 or dummy:=special number) of the dispatcher and dummy functions and have the init program search for them on startup.
Anyone see any other problems and/or need a better explanation?
Thanks