<\body> Instead of connecting your system to using a pipe, it is also possible to connect it as a dynamically linked library. Although communication through pipes is usually easier to implement, more robust and compatible with gradual output, the second option is faster. Let us now describe the steps you have to go through in order to link your system as a dynamic library. <\enumerate> Modify the architecture of your system in such a way that the main part of it can be linked as a shared library; your binary should typically become a very small program, which handles verbatim input and output, and which is linked with your shared library at runtime. Copy the include file into the include directory of your system's source and write the input/output routines as required by the last communication protocol as explained below. Include a line of the form:\ <\verbatim> \ \ \ \ (package-declare "myplugin" "libmyplugin.so" "get_name_package" "init") in your file which has been described in the case of communication by pipes. Here is the corresponding shared library, the function which will be called by in order to link your system to , and some initialization string for your package. Proceed in a similar way as in the case of communication by pipes. communication protocol> The communication protocol is used for linking libraries dynamically to . The file contains the declarations of all data structures and functions used by the protocol. Actually, we foresee a succession of different protocols. Each of these protocols have the abstract data structures and in common, with information about the versions of the protocol, and your package. The -th concrete version of the communication protocol should provide two data structures and . The first structure contains all routines and data of , which may be necessary for the package. The second structure contains all routines and data of your package, which should be visible inside . In order to link your system to , you have to implement a function: <\verbatim> \ \ \ \ package_exports* get_my_package (int version); This function takes the highest communication protocol supported by your system on input. It should return a pointer to an instance of a concrete structure , where is inferior or equal to . communication protocol> In the first version of the communication protocol, your package should export an instance of the following data structure:\ <\verbatim> \ \ \ \ typedef struct package_exports_1 { \ \ \ \ \ char* version_protocol; /* "TeXmacs communication protocol 1" */ \ \ \ \ \ char* version_package; \ \ \ \ \ char* (*install) (TeXmacs_exports_1* TM, char* options, char** errors); \ \ \ \ \ char* (*evaluate) (char* what, char* session, char** errors); \ \ \ \ \ char* (*execute) (char* what, char* session, char** errors); \ \ \ } package_exports_1; The string should contain and the string the version of your package. The routine will be called once by in order to initialize your system with options . It communicates the routines exported by to your system in the form of . The routine should return a status message like:\ <\verbatim> \ \ \ \ "yourcas-version successfully linked to TeXmacs" If installation failed, then you should return and should contain an error message. Both and the returned string have a special format, in which it is possible to encode arbitrary documents. This format will be explained in the next section. The routine is used to evaluate the expression inside a -session with name . It should return the evaluation of or if an error occurred. either contains one or more warning messages or an error message, if the evaluation failed. The command:\ <\verbatim> \ \ \ \ (package-format "yourcas" "input-format" "output-format") is used in order to specify the input and output formats for evaluations, in a similar way as in the case of pipes. The routine has a similar specification as , except that it is not used for the evaluation of expressions inside a -session, but rather for other communication purposes between and your package. <\remark> All strings returned by the routines , and , as well as all warning and error messages should be allocated using . They will be freed by using . The first version of the communication protocol also requires to export an instance of the data structure: <\verbatim> \ \ \ \ typedef struct TeXmacs_exports_1 { \ \ \ \ \ char* version_protocol; /* "TeXmacs communication protocol 1" */ \ \ \ \ \ char* version_TeXmacs; \ \ \ } TeXmacs_exports_1; The string contains the version of the protocol and the current version of . <\initial> <\collection> <\references> <\collection> > |?>> > |?>> > > <\auxiliary> <\collection> <\associate|toc> |math font series||1Connections via dynamically linked libraries> |math font series||2The TeXmacs communication protocol> |math font series||3Version 1 of the TeXmacs communication protocol>