#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <signal.h>
#include <ctype.h>
#include "samp.h"
Defines | |
#define | SZ_CLIENT_LIST 1024 |
Functions | |
handle_t | sampInit (String appName, String description) |
Initialize the SAMP interface. | |
void | sampClose (handle_t handle) |
Close the SAMP interface and free resources. | |
int | sampDebug (handle_t handle, int value) |
Set interface debug level. | |
int | sampVerbose (handle_t handle, int value) |
Set interface debug level. | |
int | sampStartup (handle_t handle) |
Startup the SAMP interface to send/receive messages. | |
int | sampShutdown (handle_t handle) |
Shut down the active SAMP interface. | |
int | samp_hubActive (handle_t handle) |
Determine if the Hub is active (i.e. connected). | |
int | samp_setOpt (handle_t handle, char *opt, int value) |
void | samp_Metadata (handle_t handle, String field, String value) |
Set a metadata field value for the application. | |
void | samp_Subscribe (handle_t handle, String mtype, void *userFunc) |
Subscribe to a given mtype. | |
void | samp_Unsubscribe (handle_t handle, String mtype) |
Unsubscribe to a given mtype. | |
void | samp_setCallMode (handle_t handle, int mode) |
Set the default calling mode (synch or asynch). | |
void | samp_setSyncMode (handle_t handle) |
Set the calling mode to use synchronous messaging. | |
void | samp_setASyncMode (handle_t handle) |
Set the calling mode to use asynchronous messaging. | |
void | samp_setNotifyMode (handle_t handle) |
Set the calling mode to use notification messaging. | |
void | samp_setMsgMode (handle_t handle, int mode) |
Set the message pattern to the specified mode. | |
void | samp_setCallByRef (handle_t handle) |
Have interface call user handlers by reference. | |
void | samp_setReplyCallback (handle_t handle, int *func) |
Set the Reply callback. samp_setReplyCallback (handle_t handle, int *func). | |
void | samp_setResponseCallback (handle_t handle, int *func) |
Set the Response callback. samp_setResponseCallback (handle_t handle, int *func). | |
void | samp_defaultReplyHandler (handle_t handle) |
The interface's default Reply handler. | |
void | samp_deaultfResponseHandler (handle_t handle) |
int | samp_replyStatus (handle_t handle) |
Reply with the status of the last message sent. | |
void | samp_setTimeout (handle_t handle, int timeout) |
Set the message timeout value (in seconds). | |
void | samp_setAppName (handle_t handle, String name) |
void | samp_setAppVersion (handle_t handle, String version) |
Set the application name string. | |
int | samp_mapClients (handle_t handle) |
int | samp_addClient (handle_t handle, String name, String id) |
int | samp_listClients (handle_t handle) |
char * | samp_getClients (handle_t handle) |
int | samp_removeClient (handle_t handle, String id) |
Map | samp_getOKMap () |
Map | samp_getNullMap () |
Variables | |
Samp * | sampP |
handle_t | sampH |
Map | nullMap |
Map | OK_Map |
List | nullList |
Hub * | hub |
int | numHubs |
long | hubHandles [MAX_HUBS] |
SAMP.C -- Top-level interface to the SAMP library.
samp = sampInit (appName, descr) sampClose (samp)
stat = sampStartup (samp) sampShutdown (samp)
samp_Metadata (samp, field, value) samp_Subscribe (samp, mtype, handler) samp_Unsubscribe (samp, mtype)
samp_setReplyCallback (samp, func) samp_setResponseCallback (samp, func) stat = samp_replyStatus (samp)
Utility Methods: samp_setSyncMode (samp) // Default samp_setASyncMode (samp) samp_setNotifyMode (samp) samp_setCallByRef (samp)
samp_setTimeout (samp, timeout) samp_setAppNmae (samp, version) samp_setAppVersion (samp, name)
samp_mapClients (handle_t handle) samp_addClient (handle_t handle, String name, String id) samp_removeClient (handle_t handle, String id)
#define SZ_CLIENT_LIST 1024 |
SAMP_GETCLIENTS -- Get a list of clients as a character string as the PubID and Name separated by a space, one client per line.
SAMP_ADDCLIENT -- Add a newly registered client to the list of known apps so we can do the public-private name translation.
References Samp::clients, Client::name, Samp::nclients, and SZ_NAME.
Referenced by samp_processHubEvent().
samp_defaultReplyHandler | ( | handle_t | handle | ) |
The interface's default Reply handler.
SAMP_DEFAULTREPLYHANDLER -- The interface's default Reply handler.
handle | samp handle |
Map samp_getNullMap | ( | void | ) |
SAMP_GETNULLMAP -- Generate a 'Null' map we can return to the Hub.
References samp_newMap().
Map samp_getOKMap | ( | void | ) |
SAMP_GETOKMAP -- Generate an 'OK' map we can return to the Hub.
References nullMap, samp_newMap(), samp_setMapInMap(), and samp_setStringInMap().
samp_hubActive | ( | handle_t | handle | ) |
Determine if the Hub is active (i.e. connected).
SAMP_HUBACTIVE -- Determine if the Hub is active (i.e. connected).
handle | user handle to samp struct |
References Samp::active.
int samp_listClients | ( | handle_t | handle | ) |
SAMP_LISTCLIENTS -- List the available clients to stdout.
References Samp::clients, Client::name, and Samp::nclients.
int samp_mapClients | ( | handle_t | handle | ) |
SAMP_MAPCLIENTS -- Map the public-ids of registered clients to the appName.
References Samp::clients, Client::name, Samp::nclients, samp_freeList(), samp_GetMetadata(), samp_GetRegisteredClients(), samp_getStringFromList(), samp_listLen(), and SZ_NAME.
Referenced by sampStartup().
Set a metadata field value for the application.
SAMP_METADATA -- Set a metadata field for the application. This will be sent to the Hub later in a declareMetadata() call.
handle | samp handle | |
field | metadata field to set (name, author, etc) | |
samp | value of field |
References appMD::aKey, Samp::appVer, Hub::appVer, appMD::aVal, appMD::desc, Hub::description, Samp::description, appMD::docURL, Samp::hub, appMD::iconURL, Hub::meta, Samp::meta, appMD::nkeys, and sampTrace().
int samp_removeClient | ( | handle_t | handle, | |
String | id | |||
) |
SAMP_REMOVECLIENT -- Remove a registered client from the list of known apps that do the public-private name translation.
References Samp::clients, Client::name, Samp::nclients, and SZ_NAME.
Referenced by samp_processHubEvent().
status samp_replyStatus | ( | handle_t | handle | ) |
Reply with the status of the last message sent.
SAMP_REPLYSTATUS -- Reply with the status of the last message sent.
May be used to 'poll' for a reponse from the caller in cases where use of a callback is a problem. Codes are: <0==ERR, 0==PENDING, 1==OK
samp | samp struct ptr |
Referenced by samp_Register().
samp_setAppVersion | ( | handle_t | handle, | |
String | version | |||
) |
Set the application name string.
Set the application version string.
SAMP_SETAPPNAME -- Set the application name string.
handle | samp handle | |
name | application name |
handle | samp handle | |
name | application version |
References Hub::appVer, Samp::appVer, and Samp::hub.
samp_setASyncMode | ( | handle_t | handle | ) |
Set the calling mode to use asynchronous messaging.
SAMP_SETASYNCMODE -- Set the calling mode to use asynchronous messaging.
handle | samp handle |
References Samp::msgMode.
samp_setCallByRef | ( | handle_t | handle | ) |
Have interface call user handlers by reference.
SAMP_SETCALLBYREF -- Have interface call user handlers by reference.
handle | samp handle |
References Samp::handlerMode.
samp_setCallMode | ( | handle_t | handle, | |
int | mode | |||
) |
Set the default calling mode (synch or asynch).
SAMP_SETCALLMODE -- Set the default calling mode (synch or asynch)
handle | samp handle | |
mode | call mode (synch or asynch) |
References Samp::msgMode.
samp_setMsgMode | ( | handle_t | handle, | |
int | mode | |||
) |
Set the message pattern to the specified mode.
SAMP_SETMSGMODE -- Set the message pattern to the specified mode.
handle | samp handle | |
mode | message mode |
References Samp::msgMode.
samp_setNotifyMode | ( | handle_t | handle | ) |
Set the calling mode to use notification messaging.
SAMP_SETNOTIFYMODE -- Set the calling mode to use notification messaging.
handle | samp handle |
References Samp::msgMode.
void samp_setReplyCallback | ( | handle_t | handle, | |
int * | func | |||
) |
Set the Reply callback. samp_setReplyCallback (handle_t handle, int *func).
SAMP_SETREPLYCALLBACK -- Set the Reply callback.
handle | samp handle | |
func | callback for Reply message |
void samp_setResponseCallback | ( | handle_t | handle, | |
int * | func | |||
) |
Set the Response callback. samp_setResponseCallback (handle_t handle, int *func).
SAMP_SETRESPONSECALLBACK -- Set the Response callback.
handle | samp handle | |
func | callback for message response |
samp_setSyncMode | ( | handle_t | handle | ) |
Set the calling mode to use synchronous messaging.
SAMP_SETSYNCMODE -- Set the calling mode to use synchronous messaging.
handle | samp handle |
References Samp::msgMode.
samp_setTimeout | ( | handle_t | handle, | |
int | timeout | |||
) |
Set the message timeout value (in seconds).
SAMP_SETTIMEOUT -- Set the message timeout value (in seconds).
handle | samp handle | |
name | application name |
References Samp::hub, and Hub::timeout.
samp_Subscribe | ( | handle_t | handle, | |
String | mtype, | |||
void * | func | |||
) |
Subscribe to a given mtype.
SAMP_SUBSCRIBE -- Subscribe to a given mtype.
handle | user handle to samp struct | |
mtype | mtype name | |
func | callback function |
References Samp::nsubs, samp_getSampHandler(), samp_setSampHandler(), and samp_setUserHandler().
samp_Unsubscribe | ( | handle_t | handle, | |
String | mtype | |||
) |
Unsubscribe to a given mtype.
SAMP_UNSUBSCRIBE -- Unsubscribe to a given mtype.
handle | user handle to samp struct | |
mtype | mtype name |
References Samp::nsubs, samp_DeclareSubscriptions(), Subs::sampFunc, and Subs::userFunc.
sampClose | ( | handle_t | handle | ) |
Close the SAMP interface and free resources.
SAMP_CLOSE -- Close the SAMP interface.
handle | user handle to samp struct |
References Samp::hub, Samp::hubHandle, samp_freeHandle(), samp_hubClose(), sampTrace(), and Samp::verbose.
sampDebug | ( | handle_t | handle, | |
int | value | |||
) |
Set interface debug level.
SAMPDEBUG -- Set interface debug level.
handle | user handle to samp struct | |
value | debug value |
References Samp::debug, and Samp::verbose.
Initialize the SAMP interface.
SAMP_INIT -- Initialize the SAMP interface.
appName | application name | |
description | description of application |
References nullList, nullMap, OK_Map, samp_hubOpen(), samp_newHandle(), samp_newList(), samp_newMap(), samp_serverPort(), samp_setMapInMap(), samp_setStringInMap(), sampH, and sampTrace().
sampShutdown | ( | handle_t | handle | ) |
Shut down the active SAMP interface.
SAMP_SHUTDOWN -- Shut down the active SAMP interface.
handle | user handle to samp struct |
References Samp::active, Samp::hubHandle, samp_hubClose(), Samp::svrThread, and Samp::verbose.
Referenced by samp_processHubEvent().
sampStartup | ( | handle_t | handle | ) |
Startup the SAMP interface to send/receive messages.
SAMP_STARTUP -- Startup the SAMP interface to send/receive messages.
handle | user handle to samp struct |
References Samp::active, Samp::clients, Samp::hub, Samp::hubHandle, Hub::id, Samp::mapClients, Client::name, Samp::nclients, samp_hubDeclareMetadata(), samp_hubDeclareSubscriptions(), samp_hubOpen(), samp_mapClients(), Samp::trace, and Samp::verbose.
sampVerbose | ( | handle_t | handle, | |
int | value | |||
) |
Set interface debug level.
SAMPVERBOSE -- Set interface verbose level.
handle | user handle to samp struct | |
value | verbose value |
References Samp::verbose.
empty List struct
Referenced by samp_bibLoad(), samp_call(), samp_callAll(), samp_callAndWait(), samp_cmdExec(), samp_coordPointAtSky(), samp_DeclareMetadata(), samp_DeclareSubscriptions(), samp_envGet(), samp_envSet(), samp_GetMetadata(), samp_imageLoadFITS(), samp_notify(), samp_notifyAll(), samp_paramGet(), samp_paramSet(), samp_Register(), samp_Reply(), samp_resourceLoad(), samp_sendGeneric(), samp_specLoadSSAGeneric(), samp_tableHighlightRow(), samp_tableLoadFITS(), samp_tableLoadVOTable(), samp_tableSelectRowList(), and samp_UnRegister().
long hubHandles[MAX_HUBS] |
No. of available hubs
SAMP_OK Map struct
Referenced by sampInit().
SAMP handle
Referenced by samp_getHandlerReply(), samp_getOKMap(), samp_hubDeclareSubscriptions(), and sampInit().
int numHubs |
HUB connection
empty Map struct
Referenced by samp_getHandlerReply(), samp_receiveCall(), samp_receiveNotification(), samp_receiveResponse(), and sampInit().
handle_t sampH |
SAMP struct pointer
Referenced by samp_processHubEvent(), samp_receiveCall(), and sampInit().