1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
<!-- =defdoc xpaconvert xpaconvert n -->
<HTML>
<HEAD>
<TITLE>Converting the XPA API to 2.0</TITLE>
</HEAD>
<BODY>
<!-- =section xpaconvert NAME -->
<H2><A NAME="xpaconvert">XPAConvert: Converting the XPA API to 2.0</A></H2>
<!-- =section xpaconvert SYNOPSIS -->
<H2>Summary</H2>
<P>
This document describes tips for converting from xpa 1.0 (Xt-based
xpa) to xpa 2.0 (socket-based xpa).
<!-- =section xpaconvert DESCRIPTION -->
<H2>Description</H2>
<P>
The following are tips for converting from xpa 1.0 (Xt-based xpa) to
xpa 2.0 (socket-based xpa). The changes are straight-forward and
almost can be done automatically (we used editor macros for most of
the conversion).
<UL>
<P>
<LI>The existence of the cpp XPA_VERSION directive to distinguish between 1.0
(where it is not defined) and 2.0 (where it is defined).
<P>
<LI>Remove the first widget argument from all send and receive server
callbacks. Also change first 2 arguments from XtPointer to void
*. For example:
<PRE>
#ifdef XPA_VERSION
static void XPAReceiveFile(client_data, call_data, paramlist, buf, len)
void *client_data;
void *call_data;
char *paramlist;
char *buf;
int len;
#else
static void XPAReceiveFile(w, client_data, call_data, paramlist, buf, len)
Widget w;
XtPointer client_data;
XtPointer call_data;
char *paramlist;
char *buf;
int len;
#endif
</PRE>
<P>
<LI>Server callbacks should be declared as returning int instead
of void. They now should return 0 for no errors, -1 for error.
<P>
<LI> The mode flags have changed when defining XPA server callbacks.
The old <EM>S</EM> flag (save buffer) is replaced by <EM>freebuf=false</EM>.
The old <EM>E</EM> flag (empty buffer is OK) is no longer used (it
was an artifact of the X implementation).
<P>
<LI>Change NewXPACommand() to XPAcmdNew(), with the new calling sequence:
<PRE>
xpa = NewXPACommand(toplevel, NULL, prefix, NULL);
</PRE>
is changed to:
<PRE>
xpa = XPACmdNew(xclass, name);
</PRE>
<P>
<LI>Change the AddXPACommand() subroutine name to XPACmdAdd (with the same
calling sequence):
<PRE>
AddXPACommand(xpa, "file",
"\tdisplay a new file\n\t\t requires: filename",
NULL, NULL, NULL, XPAReceiveFile, text, NULL);
</PRE>
is changed to:
<PRE>
XPACmdAdd(xpa, "file",
"\tdisplay a new file\n\t\t requires: filename",
NULL, NULL, NULL, XPAReceiveFile, text, NULL);
</PRE>
<P>
<LI>The XPAXtAppInput() routine should be called just before XtAppMainLoop()
to add xpa fds to the Xt event loop:
<PRE>
/* add the xpas to the Xt loop */
XPAXtAddInput(app, NULL);
/* process events */
XtAppMainLoop(app);
</PRE>
<P>
<LI>Change NewXPA() to XPANew() and call XPAXtAddInput() if the XtAppMainLoop
routine already has been entered:
<PRE>
xpa = NewXPA(saotng->xim->toplevel, prefix, xparoot,
"FITS data or image filename\n\t\t options: file type",
XPASendData, new, NULL,
XPAReceiveData, new, "SE");
</PRE>
is changed to:
<PRE>
sprintf(tbuf, "%s.%s", prefix, xparoot);
xpa = XPANew("SAOTNG", tbuf,
"FITS data or image filename\n\t\t options: file type",
XPASendData, new, NULL,
XPAReceiveData, new, "SE");
XPAXtAddInput(XtWidgetToApplicationContext(saotng->xim->toplevel), xpa);
</PRE>
<P>
<LI>Change XPAInternalReceiveCommand() to XPACmdInternalReceive()
remove first argument in the calling sequence):
<PRE>
XPAInternalReceiveCommand(im->saotng->xim->toplevel,
im->saotng, im->saotng->commands,
"zoom reset", NULL, 0);
</PRE>
is changed to:
<PRE>
XPACmdInternalReceive(im->saotng, im->saotng->commands,
"zoom reset", NULL, 0);
</PRE>
<P>
<LI>Change DestroyXPA to XPAFree:
<PRE>
DestroyXPA(im->dataxpa);
</PRE>
is changed to:
<PRE>
XPAFree(im->dataxpa);
</PRE>
</UL>
<!-- =section xpaconvert SEE ALSO -->
<!-- =text See xpa(n) for a list of XPA help pages -->
<!-- =stop -->
<P>
<A HREF="./help.html">Go to XPA Help Index</A>
<H5>Last updated: September 10, 2003</H5>
</BODY>
</HTML>
|