00001 00002 /* 00003 * THIS FILE IS UNDER RCS - DO NOT MODIFY UNLESS YOU HAVE 00004 * CHECKED IT OUT USING THE COMMAND CHECKOUT. 00005 * 00006 * $Id: ws__client_8h-source.html 2161 2006-05-19 16:55:03Z paulf $ 00007 * 00008 * Revision history: 00009 * $Log$ 00009 * Revision 1.1 2006/05/19 16:55:03 paulf 00009 * first inclusion 00009 * 00010 * Revision 1.1 2000/02/14 20:05:54 lucky 00011 * Initial revision 00012 * 00013 * 00014 */ 00015 00016 /* 8/22/97 00017 This is the include file for the WaveServerIV client routines 00018 and associated structures */ 00019 00020 /* Changed PNL, 11/23/97: fixed up return status codes here and in ws_client.c. 00021 */ 00022 00023 #ifndef WS_CLIENT 00024 #define WS_CLIENT 00025 00026 /* Error codes used by routines in ws_client.c 00027 *********************************************/ 00028 #define WS_ERR_NONE 1 00029 #define WS_ERR_NO_CONNECTION -1 00030 #define WS_ERR_BROKEN_CONNECTION -3 00031 #define WS_ERR_MEMORY -4 00032 #define WS_ERR_BUFFER_OVERFLOW -5 00033 #define WS_ERR_EMPTY_MENU -6 00034 #define WS_ERR_SCN_NOT_IN_MENU -7 00035 #define WS_ERR_SERVER_NOT_IN_MENU -8 00036 #define WS_ERR_INPUT -9 00037 #define WS_ERR_TIMEOUT -10 00038 #define WS_ERR_FLAGGED -11 00039 #define WS_ERR_PARSE -12 00040 #define WS_ERR_GENERIC -99 00041 00042 /* Trace Request structure 00043 *************************/ 00044 /* the structure below is the 'form' which must be filled out to request a 00045 snippet of trace data. The requester fills out the first part, and the 00046 client routines fill out the second part. */ 00047 typedef struct 00048 { 00049 /* the request portion */ 00050 char sta[7]; /* Site name */ 00051 char chan[9]; /* Component/channel code */ 00052 char net[9]; /* Network name */ 00053 short pinno; /* Pin number that maps to sta/net/chan */ 00054 double reqStarttime; /* requested starttime - seconds since 1970 */ 00055 double reqEndtime; /* requested endtime - seconds since 1970 */ 00056 int partial; /* 1=> I'll accept partial data; 00057 0=> all or nothing */ 00058 char* pBuf; /* pointer to user supplied buffer for trace */ 00059 unsigned long bufLen; /* length of above */ 00060 long timeout; /* seconds after which we must return */ 00061 long fill; /* ASCII only: fill value for gaps in trace */ 00062 00063 /* the reply portion */ 00064 char retFlag; /* return flag (if any) from wave server */ 00065 double waitSec; /* seconds to wait until requested data will be 00066 available in the wave server. 00067 Based on times in current menu list; 00068 <0 => it's too late */ 00069 double actStarttime; /* actual start time of supplied trace */ 00070 double actEndtime; /* actual end time of supplied trace */ 00071 long actLen; /* actual length in bytes */ 00072 double samprate; /* nominal sampling rate - samples per second */ 00073 00074 } 00075 TRACE_REQ; 00076 00077 #define wsADRLEN 16 /* length for ip and port adrress strings */ 00078 #define wsREQLEN 256 /* length for MENU request */ 00079 #define wsREPLEN 8192 /* length for reply to MENU request(up to 128 SCNs) */ 00080 00081 00082 typedef struct _WS_PSCN_REC *WS_PSCN; 00083 typedef struct _WS_PSCN_REC 00084 { 00085 char sta[7]; /* Site name */ 00086 char chan[9]; /* Component/channel code */ 00087 char net[9]; /* Network name */ 00088 short pinno; /* Pin number that maps to sta/net/chan */ 00089 double tankStarttime; /* starttime for this SCN */ 00090 double tankEndtime; /* endtime for this SCN */ 00091 00092 WS_PSCN next; 00093 } WS_PSCN_REC; 00094 00095 typedef struct _WS_MENU_REC *WS_MENU; 00096 typedef struct _WS_MENU_REC 00097 { 00098 char addr[wsADRLEN]; 00099 char port[wsADRLEN]; 00100 int sock; 00101 00102 WS_PSCN pscn; 00103 WS_MENU next; 00104 } WS_MENU_REC; 00105 00106 typedef volatile struct 00107 { 00108 WS_MENU head; 00109 WS_MENU tail; 00110 } WS_MENU_QUEUE_REC; 00111 00112 /* to setup a list of servers and SCN's of each server 00113 *****************************************************/ 00114 int wsAppendMenu( char* , char*, long ); 00115 00116 /* to find out what servers the menu has 00117 ***************************************/ 00118 int wsGetMenu( WS_MENU* ); 00119 00120 /* to find out what a waveserver has; 00121 an example to find out what a server has is as follows: 00122 int FindOutWhatAServerHas( char* addr, char* port ) 00123 { 00124 WS_PSCN pscn = NULL; 00125 int err = WS_ERR_GENERIC; 00126 00127 err = wsGetServerPSCN( addr, port, &pscn ); 00128 if ( err != WS_ERR_NONE ) 00129 goto abort; 00130 if ( !pscn ) 00131 { 00132 print( "Server has nothing to offer\n" ); 00133 goto abort; 00134 } 00135 while ( pscn ) 00136 { 00137 printf( "pinno[%d] s[%s] c[%s] n[%s]\n", 00138 pscn->pinno, pscn->sta, pscn->chan, pscn->net ); 00139 pscn = pscn->next; 00140 } 00141 err = WS_ERR_NONE; 00142 abort: 00143 return( err ); 00144 } 00145 ***********************************/ 00146 int wsGetServerPSCN( char*, char*, WS_PSCN* ); 00147 00148 /* to release the list created by wsAppendMenu 00149 *********************************************/ 00150 void wsKillMenu(); 00151 00152 /* wsGetServerPSCN: Return the pscn list for this server from the menu queue * 00153 *****************************************************************************/ 00154 int wsGetServerPSCN( char*, char*, WS_PSCN*, WS_MENU_QUEUE_REC* ); 00155 00156 /* to retrieve the binary trace snippet specified in the structure TRACE_REQ 00157 ***************************************************************************/ 00158 int wsGetTraceBin( TRACE_REQ* ); 00159 00160 /* to retrieve the ASCII trace snippet specified in the structure TRACE_REQ 00161 **************************************************************************/ 00162 int wsGetTraceAscii( TRACE_REQ* ); 00163 00164 #endif /* WS_CLIENT */