1 | #define DIMLIB
|
---|
2 | #include <dic.hxx>
|
---|
3 | #include <stdio.h>
|
---|
4 |
|
---|
5 | char *DimClient::dimDnsNode = 0;
|
---|
6 | DimErrorHandler *DimClient::itsCltError = 0;
|
---|
7 | char *DimClient::serverName = 0;
|
---|
8 | int DimClient::dicNoCopy = 0;
|
---|
9 |
|
---|
10 | extern "C" {
|
---|
11 | static void user_routine(void *tagp, void *bufp, int *size)
|
---|
12 | {
|
---|
13 | // int *tag = (int *)tagp;
|
---|
14 | char *buf = (char *)bufp;
|
---|
15 | // int id = *tag;
|
---|
16 | DimInfo *t;
|
---|
17 |
|
---|
18 | // t = (DimInfo *)id_get_ptr(id, SRC_DIC);
|
---|
19 | t = * (DimInfo **)tagp;
|
---|
20 | if(DimClient::getNoDataCopy() == 0)
|
---|
21 | {
|
---|
22 | if(!t->itsDataSize)
|
---|
23 | {
|
---|
24 | t->itsData = new char[*size];
|
---|
25 | t->itsDataSize = *size;
|
---|
26 | }
|
---|
27 | else if(t->itsDataSize < *size)
|
---|
28 | {
|
---|
29 | delete[] (char *)(t->itsData);
|
---|
30 | t->itsData = new char[*size];
|
---|
31 | t->itsDataSize = *size;
|
---|
32 | }
|
---|
33 | memcpy(t->itsData, buf, *size);
|
---|
34 | }
|
---|
35 | else
|
---|
36 | {
|
---|
37 | t->itsData = buf;
|
---|
38 | }
|
---|
39 | t->itsSize = *size;
|
---|
40 | if(t->itsHandler)
|
---|
41 | {
|
---|
42 | t->itsHandler->itsService = t;
|
---|
43 | DimCore::inCallback = 1;
|
---|
44 | t->itsHandler->infoHandler();
|
---|
45 | DimCore::inCallback = 0;
|
---|
46 | }
|
---|
47 | else
|
---|
48 | {
|
---|
49 | DimCore::inCallback = 1;
|
---|
50 | t->infoHandler();
|
---|
51 | DimCore::inCallback = 0;
|
---|
52 | }
|
---|
53 | }
|
---|
54 | }
|
---|
55 |
|
---|
56 | void DimInfo::infoHandler()
|
---|
57 | {
|
---|
58 | char *data;
|
---|
59 | if(DimClient::getNoDataCopy() == 1)
|
---|
60 | {
|
---|
61 | data = (char *)itsData;
|
---|
62 | if(!itsDataSize)
|
---|
63 | {
|
---|
64 | itsData = new char[itsSize];
|
---|
65 | itsDataSize = itsSize;
|
---|
66 | }
|
---|
67 | else if(itsDataSize < itsSize)
|
---|
68 | {
|
---|
69 | delete[] (char *)(itsData);
|
---|
70 | itsData = new char[itsSize];
|
---|
71 | itsDataSize = itsSize;
|
---|
72 | }
|
---|
73 | memcpy(itsData, data, itsSize);
|
---|
74 | }
|
---|
75 | }
|
---|
76 |
|
---|
77 | void DimInfo::doIt()
|
---|
78 | {
|
---|
79 | dim_init();
|
---|
80 | DISABLE_AST
|
---|
81 |
|
---|
82 | // itsTagId = id_get((void *)this, SRC_DIC);
|
---|
83 | itsId = dic_info_service(itsName,itsType,itsTime, 0, 0,
|
---|
84 | // user_routine, itsTagId,
|
---|
85 | user_routine, (long)this,
|
---|
86 | itsNolinkBuf, itsNolinkSize);
|
---|
87 | ENABLE_AST
|
---|
88 | }
|
---|
89 |
|
---|
90 | int DimInfo::getQuality()
|
---|
91 | {
|
---|
92 | return dic_get_quality(itsId);
|
---|
93 | }
|
---|
94 |
|
---|
95 | int DimInfo::getTimestamp()
|
---|
96 | {
|
---|
97 | int ret;
|
---|
98 |
|
---|
99 | ret = dic_get_timestamp(itsId, &secs, &millisecs);
|
---|
100 | return(secs);
|
---|
101 | }
|
---|
102 |
|
---|
103 | int DimInfo::getTimestampMillisecs()
|
---|
104 | {
|
---|
105 | return(millisecs);
|
---|
106 | }
|
---|
107 |
|
---|
108 |
|
---|
109 | char *DimInfo::getFormat()
|
---|
110 | {
|
---|
111 | char *def;
|
---|
112 |
|
---|
113 | if(itsFormat)
|
---|
114 | {
|
---|
115 | return itsFormat;
|
---|
116 | }
|
---|
117 | def = dic_get_format(itsId);
|
---|
118 |
|
---|
119 | itsFormat = new char[strlen(def)+1];
|
---|
120 | strcpy(itsFormat, def);
|
---|
121 | return itsFormat;
|
---|
122 | }
|
---|
123 |
|
---|
124 | void DimInfo::timerHandler()
|
---|
125 | {
|
---|
126 | // itsTagId = id_get((void *)this, SRC_DIC);
|
---|
127 | itsId = dic_info_service(itsName,itsType,itsTime, 0, 0,
|
---|
128 | // user_routine, itsTagId,
|
---|
129 | user_routine, (long)this,
|
---|
130 | itsNolinkBuf, itsNolinkSize);
|
---|
131 | }
|
---|
132 |
|
---|
133 | void DimInfo::subscribe(char *name, int time, void *nolink, int nolinksize,
|
---|
134 | DimInfoHandler *handler)
|
---|
135 | {
|
---|
136 | itsId = 0;
|
---|
137 | // itsTagId = 0;
|
---|
138 | itsData = 0;
|
---|
139 | itsFormat = 0;
|
---|
140 | itsHandler = handler;
|
---|
141 | itsName = new char[strlen(name)+1];
|
---|
142 | strcpy(itsName,name);
|
---|
143 | itsDataSize = 0;
|
---|
144 | itsSize = 0;
|
---|
145 | itsNolinkBuf = new char[nolinksize];
|
---|
146 | itsNolinkSize = nolinksize;
|
---|
147 | memcpy(itsNolinkBuf, nolink, nolinksize);
|
---|
148 | if(!time)
|
---|
149 | {
|
---|
150 | itsType = MONITORED;
|
---|
151 | itsTime = 0;
|
---|
152 | }
|
---|
153 | else if(time > 0)
|
---|
154 | {
|
---|
155 | itsType = MONITORED;
|
---|
156 | itsTime = time;
|
---|
157 | }
|
---|
158 | else
|
---|
159 | {
|
---|
160 | itsType = ONCE_ONLY;
|
---|
161 | itsTime = 30;
|
---|
162 | }
|
---|
163 | doIt();
|
---|
164 | }
|
---|
165 |
|
---|
166 |
|
---|
167 | DimInfo::~DimInfo()
|
---|
168 | {
|
---|
169 | // if(itsTagId)
|
---|
170 | // id_free(itsTagId, SRC_DIC);
|
---|
171 | dic_release_service(itsId);
|
---|
172 | delete[] (char *)itsNolinkBuf;
|
---|
173 | if(itsDataSize)
|
---|
174 | delete[] (char *)itsData;
|
---|
175 | delete[] itsName;
|
---|
176 | if(itsFormat)
|
---|
177 | delete[] itsFormat;
|
---|
178 | }
|
---|
179 |
|
---|
180 | void *DimInfo::getData()
|
---|
181 | {
|
---|
182 | // if(!this->itsSize)
|
---|
183 | // return itsNolinkBuf;
|
---|
184 | /*
|
---|
185 | if(DimClient::getNoDataCopy() == 1)
|
---|
186 | {
|
---|
187 | if(!DimCore::inCallback)
|
---|
188 | return (void *)0;
|
---|
189 | }
|
---|
190 | */
|
---|
191 | return this->itsData;
|
---|
192 | }
|
---|
193 |
|
---|
194 | void DimStampedInfo::doIt()
|
---|
195 | {
|
---|
196 | dim_init();
|
---|
197 | DISABLE_AST
|
---|
198 | // itsTagId = id_get((void *)this, SRC_DIC);
|
---|
199 | itsId = dic_info_service_stamped(itsName,itsType,itsTime, 0, 0,
|
---|
200 | // user_routine, itsTagId,
|
---|
201 | user_routine, (long)this,
|
---|
202 | itsNolinkBuf, itsNolinkSize);
|
---|
203 | ENABLE_AST
|
---|
204 | }
|
---|
205 |
|
---|
206 | void DimStampedInfo::subscribe(char *name, int time, void *nolink, int nolinksize,
|
---|
207 | DimInfoHandler *handler)
|
---|
208 | {
|
---|
209 | itsId = 0;
|
---|
210 | itsFormat = 0;
|
---|
211 | itsHandler = handler;
|
---|
212 | itsName = new char[strlen(name)+1];
|
---|
213 | strcpy(itsName,name);
|
---|
214 | itsDataSize = 0;
|
---|
215 | itsNolinkBuf = new char[nolinksize];
|
---|
216 | itsNolinkSize = nolinksize;
|
---|
217 | memcpy(itsNolinkBuf, nolink, nolinksize);
|
---|
218 | if(!time)
|
---|
219 | {
|
---|
220 | itsType = MONITORED;
|
---|
221 | itsTime = 0;
|
---|
222 | }
|
---|
223 | else if(time > 0)
|
---|
224 | {
|
---|
225 | itsType = MONITORED;
|
---|
226 | itsTime = time;
|
---|
227 | }
|
---|
228 | else
|
---|
229 | {
|
---|
230 | itsType = ONCE_ONLY;
|
---|
231 | itsTime = 30;
|
---|
232 | }
|
---|
233 | doIt();
|
---|
234 | }
|
---|
235 |
|
---|
236 | DimStampedInfo::~DimStampedInfo()
|
---|
237 | {
|
---|
238 | }
|
---|
239 |
|
---|
240 | void DimUpdatedInfo::doIt()
|
---|
241 | {
|
---|
242 | dim_init();
|
---|
243 | DISABLE_AST
|
---|
244 | // itsTagId = id_get((void *)this, SRC_DIC);
|
---|
245 | itsId = dic_info_service_stamped(itsName,itsType,itsTime, 0, 0,
|
---|
246 | // user_routine, itsTagId,
|
---|
247 | user_routine, (long)this,
|
---|
248 | itsNolinkBuf, itsNolinkSize);
|
---|
249 | ENABLE_AST
|
---|
250 | }
|
---|
251 |
|
---|
252 | void DimUpdatedInfo::subscribe(char *name, int time, void *nolink, int nolinksize,
|
---|
253 | DimInfoHandler *handler)
|
---|
254 | {
|
---|
255 | itsId = 0;
|
---|
256 | itsFormat = 0;
|
---|
257 | itsHandler = handler;
|
---|
258 | itsName = new char[strlen(name)+1];
|
---|
259 | strcpy(itsName,name);
|
---|
260 | itsDataSize = 0;
|
---|
261 | itsNolinkBuf = new char[nolinksize];
|
---|
262 | itsNolinkSize = nolinksize;
|
---|
263 | memcpy(itsNolinkBuf, nolink, nolinksize);
|
---|
264 | if(!time)
|
---|
265 | {
|
---|
266 | itsType = MONIT_ONLY;
|
---|
267 | itsTime = 0;
|
---|
268 | }
|
---|
269 | else if(time > 0)
|
---|
270 | {
|
---|
271 | itsType = UPDATE;
|
---|
272 | itsTime = time;
|
---|
273 | }
|
---|
274 | doIt();
|
---|
275 | }
|
---|
276 |
|
---|
277 | DimUpdatedInfo::~DimUpdatedInfo()
|
---|
278 | {
|
---|
279 | }
|
---|
280 |
|
---|
281 | extern "C" {
|
---|
282 | static void data_user_routine(void *tagp, void *bufp, int *size)
|
---|
283 | {
|
---|
284 | // int *tag = (int *)tagp;
|
---|
285 | char *buf = (char *)bufp;
|
---|
286 | // int id = *tag;
|
---|
287 | DimCurrentInfo *t;
|
---|
288 |
|
---|
289 | // t = (DimCurrentInfo *)id_get_ptr(id, SRC_DIC);
|
---|
290 | t = * (DimCurrentInfo **)tagp;
|
---|
291 | if(!t->itsDataSize)
|
---|
292 | {
|
---|
293 | t->itsData = new char[*size];
|
---|
294 | t->itsDataSize = *size;
|
---|
295 | }
|
---|
296 | else if(t->itsDataSize < *size)
|
---|
297 | {
|
---|
298 | delete[] (char *)(t->itsData);
|
---|
299 | t->itsData = new char[*size];
|
---|
300 | t->itsDataSize = *size;
|
---|
301 | }
|
---|
302 | memcpy(t->itsData, buf, *size);
|
---|
303 | t->itsSize = *size;
|
---|
304 | t->wakeUp = 1;
|
---|
305 | #ifdef __VMS
|
---|
306 | sys$wake(0,0);
|
---|
307 | #endif
|
---|
308 | #ifdef WIN32
|
---|
309 | wake_up();
|
---|
310 | #endif
|
---|
311 | }
|
---|
312 | }
|
---|
313 |
|
---|
314 | void DimCurrentInfo::subscribe(char *name, int time, void *nolink, int nolinksize)
|
---|
315 | {
|
---|
316 |
|
---|
317 | int timeout;
|
---|
318 |
|
---|
319 | // itsTagId = 0;
|
---|
320 | if(!time)
|
---|
321 | timeout = 10;
|
---|
322 | else
|
---|
323 | timeout = time;
|
---|
324 | itsName = new char[strlen(name)+1];
|
---|
325 | strcpy(itsName,name);
|
---|
326 | itsDataSize = 0;
|
---|
327 | itsNolinkBuf = new char[nolinksize];
|
---|
328 | itsNolinkSize = nolinksize;
|
---|
329 | memcpy(itsNolinkBuf, nolink, nolinksize);
|
---|
330 | wakeUp = 0;
|
---|
331 | // itsTagId = id_get((void *)this, SRC_DIC);
|
---|
332 | dic_info_service(itsName,ONCE_ONLY,timeout, 0, 0,
|
---|
333 | // data_user_routine, itsTagId,
|
---|
334 | data_user_routine, (long)this,
|
---|
335 | itsNolinkBuf, itsNolinkSize);
|
---|
336 | }
|
---|
337 |
|
---|
338 | DimCurrentInfo::~DimCurrentInfo()
|
---|
339 | {
|
---|
340 | delete[] (char *)itsNolinkBuf;
|
---|
341 |
|
---|
342 | // if(itsTagId)
|
---|
343 | // id_free(itsTagId, SRC_DIC);
|
---|
344 | if(itsDataSize)
|
---|
345 | delete[] (char *)itsData;
|
---|
346 | delete[] itsName;
|
---|
347 | }
|
---|
348 |
|
---|
349 | void *DimCurrentInfo::getData()
|
---|
350 | {
|
---|
351 | while(!wakeUp)
|
---|
352 | {
|
---|
353 | #ifdef __VMS
|
---|
354 | sys$hiber();
|
---|
355 | #else
|
---|
356 | dim_wait();
|
---|
357 | #endif
|
---|
358 | }
|
---|
359 | return this->itsData;
|
---|
360 | }
|
---|
361 |
|
---|
362 | extern "C" {
|
---|
363 | static void cmnd_done(void *tagp, int *result)
|
---|
364 | {
|
---|
365 | // int *tag = (int *)tagp;
|
---|
366 | // int id = *tag;
|
---|
367 | DimCmnd *t;
|
---|
368 |
|
---|
369 | // t = (DimCmnd *)id_get_ptr(id, SRC_DIC);
|
---|
370 | t = *(DimCmnd **)tagp;
|
---|
371 | t->result = *result;
|
---|
372 | t->wakeUp = 1;
|
---|
373 | #ifdef __VMS
|
---|
374 | sys$wake(0,0);
|
---|
375 | #endif
|
---|
376 | #ifdef WIN32
|
---|
377 | wake_up();
|
---|
378 | #endif
|
---|
379 | }
|
---|
380 | }
|
---|
381 |
|
---|
382 | int DimCmnd::send(char *name, void *data, int datasize)
|
---|
383 | {
|
---|
384 | // int id;
|
---|
385 | if(DimCore::inCallback)
|
---|
386 | {
|
---|
387 | dic_cmnd_service(name, data, datasize);
|
---|
388 | return(1);
|
---|
389 | }
|
---|
390 | else
|
---|
391 | {
|
---|
392 | wakeUp = 0;
|
---|
393 | // id = id_get((void *)this, SRC_DIC);
|
---|
394 | dic_cmnd_callback(name, data, datasize,
|
---|
395 | // cmnd_done, id);
|
---|
396 | cmnd_done, (long)this);
|
---|
397 | while(!wakeUp)
|
---|
398 | {
|
---|
399 | #ifdef __VMS
|
---|
400 | sys$hiber();
|
---|
401 | #else
|
---|
402 | dim_wait();
|
---|
403 | #endif
|
---|
404 | }
|
---|
405 | // id_free(id, SRC_DIC);
|
---|
406 | return(result);
|
---|
407 | }
|
---|
408 | }
|
---|
409 |
|
---|
410 | void DimCmnd::sendNB(char *name, void *data, int datasize)
|
---|
411 | {
|
---|
412 | dic_cmnd_service(name, data, datasize);
|
---|
413 | }
|
---|
414 |
|
---|
415 | extern "C" {
|
---|
416 | static void rpc_user_routine(void *tagp, void *bufp, int *sizep)
|
---|
417 | {
|
---|
418 | // int *tag = (int *)tagp;
|
---|
419 | char *buf = (char *)bufp;
|
---|
420 | int size = *sizep;
|
---|
421 | // int id = *tag;
|
---|
422 | DimRpcInfo *t;
|
---|
423 | int quality;
|
---|
424 |
|
---|
425 | // t = (DimRpcInfo *)id_get_ptr(id, SRC_DIC);
|
---|
426 | t = *(DimRpcInfo **)tagp;
|
---|
427 | quality = dic_get_quality(0);
|
---|
428 | if(quality == -1)
|
---|
429 | {
|
---|
430 | buf = (char *)t->itsNolinkBuf;
|
---|
431 | size = t->itsNolinkSize;
|
---|
432 | }
|
---|
433 | if(DimClient::getNoDataCopy() == 0)
|
---|
434 | {
|
---|
435 | if(!t->itsDataSize)
|
---|
436 | {
|
---|
437 | t->itsData = new char[size];
|
---|
438 | t->itsDataSize = size;
|
---|
439 | }
|
---|
440 | else if(t->itsDataSize < size)
|
---|
441 | {
|
---|
442 | delete[] (char *)(t->itsData);
|
---|
443 | t->itsData = new char[size];
|
---|
444 | t->itsDataSize = size;
|
---|
445 | }
|
---|
446 | }
|
---|
447 | if(!t->itsConnected)
|
---|
448 | {
|
---|
449 | t->itsConnected = 1;
|
---|
450 | }
|
---|
451 | if(t->itsWaiting)
|
---|
452 | {
|
---|
453 | t->stop();
|
---|
454 | //dim_print_date_time();
|
---|
455 | //printf("DIM RPC: Stopped Timer, Data Received for %s\n", t->getName());
|
---|
456 | if(DimClient::getNoDataCopy() == 0)
|
---|
457 | memcpy(t->itsData, buf, size);
|
---|
458 | else
|
---|
459 | t->itsData = buf;
|
---|
460 | t->itsSize = size;
|
---|
461 | t->wakeUp = 1;
|
---|
462 | if(t->itsInit)
|
---|
463 | {
|
---|
464 | t->itsWaiting = 1;
|
---|
465 | t->itsHandler->rpcInfoHandler();
|
---|
466 | }
|
---|
467 | if(t->itsWaiting != 2)
|
---|
468 | t->itsWaiting = 0;
|
---|
469 | }
|
---|
470 | #ifdef __VMS
|
---|
471 | sys$wake(0,0);
|
---|
472 | #endif
|
---|
473 | #ifdef WIN32
|
---|
474 | wake_up();
|
---|
475 | #endif
|
---|
476 | }
|
---|
477 | }
|
---|
478 |
|
---|
479 | void DimRpcInfo::timerHandler()
|
---|
480 | {
|
---|
481 | char *buf;
|
---|
482 | int size;
|
---|
483 |
|
---|
484 | buf = (char *)itsNolinkBuf;
|
---|
485 | size = itsNolinkSize;
|
---|
486 |
|
---|
487 | if(DimClient::getNoDataCopy() == 0)
|
---|
488 | {
|
---|
489 | if(!itsDataSize)
|
---|
490 | {
|
---|
491 | itsData = new char[size];
|
---|
492 | itsDataSize = size;
|
---|
493 | }
|
---|
494 | else if(itsDataSize < size)
|
---|
495 | {
|
---|
496 | delete[] (char *)(itsData);
|
---|
497 | itsData = new char[size];
|
---|
498 | itsDataSize = size;
|
---|
499 | }
|
---|
500 | }
|
---|
501 | if(itsWaiting)
|
---|
502 | {
|
---|
503 | if(DimClient::getNoDataCopy() == 0)
|
---|
504 | memcpy(itsData, buf, size);
|
---|
505 | else
|
---|
506 | itsData = buf;
|
---|
507 | itsSize = size;
|
---|
508 | //dim_print_date_time();
|
---|
509 | //printf("DIM RPC: Timer fired, No Data Received for %s\n", itsName);
|
---|
510 | wakeUp = 1;
|
---|
511 | if(itsInit)
|
---|
512 | {
|
---|
513 | itsWaiting = 1;
|
---|
514 | itsHandler->rpcInfoHandler();
|
---|
515 | }
|
---|
516 | if(itsWaiting != 2)
|
---|
517 | itsWaiting = 0;
|
---|
518 | }
|
---|
519 | #ifdef __VMS
|
---|
520 | sys$wake(0,0);
|
---|
521 | #endif
|
---|
522 | #ifdef WIN32
|
---|
523 | wake_up();
|
---|
524 | #endif
|
---|
525 | }
|
---|
526 |
|
---|
527 | void DimRpcInfo::rpcInfoHandler()
|
---|
528 | {
|
---|
529 | char *data;
|
---|
530 | if(DimClient::getNoDataCopy() == 1)
|
---|
531 | {
|
---|
532 | data = (char *)itsData;
|
---|
533 | if(!itsDataSize)
|
---|
534 | {
|
---|
535 | itsData = new char[itsSize];
|
---|
536 | itsDataSize = itsSize;
|
---|
537 | }
|
---|
538 | else if(itsDataSize < itsSize)
|
---|
539 | {
|
---|
540 | delete[] (char *)(itsData);
|
---|
541 | itsData = new char[itsSize];
|
---|
542 | itsDataSize = itsSize;
|
---|
543 | }
|
---|
544 | memcpy(itsData, data, itsSize);
|
---|
545 | }
|
---|
546 | }
|
---|
547 |
|
---|
548 | void DimRpcInfo::subscribe(char *name, void *data, int size,
|
---|
549 | void *nolink, int nolinksize, int timeout)
|
---|
550 | {
|
---|
551 |
|
---|
552 | itsId = 0;
|
---|
553 | // itsTagId = 0;
|
---|
554 | itsInit = 0;
|
---|
555 | itsWaiting = 0;
|
---|
556 | itsName = new char[strlen(name)+1];
|
---|
557 | strcpy(itsName,name);
|
---|
558 | itsHandler = this;
|
---|
559 | itsDataSize = 0;
|
---|
560 | itsData = 0;
|
---|
561 | itsDataOutSize = 0;
|
---|
562 | itsDataOut = 0;
|
---|
563 | itsNolinkBuf = new char[nolinksize];
|
---|
564 | itsNolinkSize = nolinksize;
|
---|
565 | memcpy(itsNolinkBuf, nolink, nolinksize);
|
---|
566 | itsNameOut = new char[strlen(name)+1+10];
|
---|
567 | strcpy(itsNameOut,name);
|
---|
568 | strcat(itsNameOut,(char *)"/RpcIn");
|
---|
569 | itsNameIn = new char[strlen(name)+1+10];
|
---|
570 | strcpy(itsNameIn,name);
|
---|
571 | strcat(itsNameIn,(char *)"/RpcOut");
|
---|
572 | itsTimeout = timeout;
|
---|
573 | dim_init();
|
---|
574 | {
|
---|
575 | if(!itsId)
|
---|
576 | {
|
---|
577 | // itsTagId = id_get((void *)itsHandler, SRC_DIC);
|
---|
578 |
|
---|
579 | // itsId = dic_info_service_stamped(itsNameIn,MONIT_ONLY,itsTimeout,
|
---|
580 | itsConnected = 0;
|
---|
581 | // itsId = dic_info_service_stamped(itsNameIn,MONITORED,itsTimeout,
|
---|
582 | itsId = dic_info_service_stamped(itsNameIn,MONIT_FIRST,itsTimeout,
|
---|
583 | 0, 0,
|
---|
584 | // rpc_user_routine, itsTagId,
|
---|
585 | rpc_user_routine, (long)itsHandler,
|
---|
586 | itsNolinkBuf, itsNolinkSize);
|
---|
587 | // dim_usleep(200000);
|
---|
588 | itsInit = 1;
|
---|
589 | }
|
---|
590 | }
|
---|
591 | if(size)
|
---|
592 | {
|
---|
593 | doIt(data, size);
|
---|
594 | }
|
---|
595 | }
|
---|
596 |
|
---|
597 | void DimRpcInfo::doIt(void *data, int size)
|
---|
598 | {
|
---|
599 | int ret;
|
---|
600 |
|
---|
601 | wakeUp = 0;
|
---|
602 | if(DimClient::getNoDataCopy() == 0)
|
---|
603 | {
|
---|
604 | if(!itsDataOut)
|
---|
605 | {
|
---|
606 | itsDataOut = new char[size];
|
---|
607 | itsDataOutSize = size;
|
---|
608 | }
|
---|
609 | else if(itsDataOutSize < size)
|
---|
610 | {
|
---|
611 | delete[] (char *)itsDataOut;
|
---|
612 | itsDataOut = new char[size];
|
---|
613 | itsDataOutSize = size;
|
---|
614 | }
|
---|
615 | memcpy(itsDataOut, data, size);
|
---|
616 | }
|
---|
617 | else
|
---|
618 | {
|
---|
619 | itsDataOut = data;
|
---|
620 | }
|
---|
621 | while(!itsConnected)
|
---|
622 | dim_wait();
|
---|
623 | itsWaiting = 1;
|
---|
624 | if(itsTimeout)
|
---|
625 | start(itsTimeout);
|
---|
626 | //dim_print_date_time();
|
---|
627 | //printf("DIM RPC: Started Timer for %s - %d secs\n", itsName, itsTimeout);
|
---|
628 | ret = DimClient::sendCommand(itsNameOut, itsDataOut, size);
|
---|
629 | if(!ret)
|
---|
630 | {
|
---|
631 | if(itsTimeout)
|
---|
632 | stop();
|
---|
633 | //dim_print_date_time();
|
---|
634 | //printf("DIM RPC: Stopped Timer, Command failed for %s\n", itsName);
|
---|
635 | // rpc_user_routine((int *)&itsTagId, itsNolinkBuf, &itsNolinkSize);
|
---|
636 | rpc_user_routine((long *)&itsHandler, itsNolinkBuf, &itsNolinkSize);
|
---|
637 | }
|
---|
638 | /*
|
---|
639 | else
|
---|
640 | {
|
---|
641 | if(itsTimeout)
|
---|
642 | start(itsTimeout);
|
---|
643 | }
|
---|
644 | */
|
---|
645 | }
|
---|
646 |
|
---|
647 | void *DimRpcInfo::getData()
|
---|
648 | {
|
---|
649 | while(!wakeUp)
|
---|
650 | {
|
---|
651 | #ifdef __VMS
|
---|
652 | sys$hiber();
|
---|
653 | #else
|
---|
654 | dim_wait();
|
---|
655 | #endif
|
---|
656 | }
|
---|
657 | /*
|
---|
658 | if(DimClient::getNoDataCopy() == 1)
|
---|
659 | {
|
---|
660 | if(!DimCore::inCallback)
|
---|
661 | return (void *)0;
|
---|
662 | }
|
---|
663 | */
|
---|
664 | return this->itsData;
|
---|
665 | }
|
---|
666 |
|
---|
667 | DimRpcInfo::~DimRpcInfo()
|
---|
668 | {
|
---|
669 | // if(itsTagId)
|
---|
670 | // id_free(itsTagId, SRC_DIC);
|
---|
671 | //dim_print_date_time();
|
---|
672 | //printf("DIM RPC: Deleting RPC and Timer for %s\n", itsName);
|
---|
673 | if(itsId)
|
---|
674 | dic_release_service(itsId);
|
---|
675 | delete[] (char *)itsNolinkBuf;
|
---|
676 | if(itsDataSize)
|
---|
677 | delete[] (char *)itsData;
|
---|
678 | if(itsDataOutSize)
|
---|
679 | delete[] (char *)itsDataOut;
|
---|
680 | delete[] itsName;
|
---|
681 | delete[] itsNameIn;
|
---|
682 | delete[] itsNameOut;
|
---|
683 | }
|
---|
684 |
|
---|
685 | DimBrowser::DimBrowser()
|
---|
686 | {
|
---|
687 | int i;
|
---|
688 | for(i = 0; i<5; i++)
|
---|
689 | {
|
---|
690 | itsData[i] = 0;
|
---|
691 | itsData[i] = 0;
|
---|
692 | }
|
---|
693 | currIndex = -1;
|
---|
694 | none = 0;
|
---|
695 | browserRpc = 0;
|
---|
696 | }
|
---|
697 |
|
---|
698 | DimBrowser::~DimBrowser()
|
---|
699 | {
|
---|
700 | int i;
|
---|
701 | for(i = 0; i<5; i++)
|
---|
702 | {
|
---|
703 | if(itsData[i])
|
---|
704 | delete itsData[i];
|
---|
705 | }
|
---|
706 | if(browserRpc)
|
---|
707 | delete browserRpc;
|
---|
708 | }
|
---|
709 |
|
---|
710 | int DimBrowser::getServices(const char * serviceName)
|
---|
711 | {
|
---|
712 | return getServices(serviceName, 0);
|
---|
713 | }
|
---|
714 |
|
---|
715 | int DimBrowser::getServices(const char * serviceName, int timeout)
|
---|
716 | {
|
---|
717 | char *str;
|
---|
718 |
|
---|
719 | // DimRpcInfo rpc((char *)"DIS_DNS/SERVICE_INFO",(char *)"\0");
|
---|
720 | // rpc.setData((char *)serviceName);
|
---|
721 | // str = rpc.getString();
|
---|
722 | if(!browserRpc)
|
---|
723 | browserRpc = new DimRpcInfo((char *)"DIS_DNS/SERVICE_INFO",timeout,(char *)"\0");
|
---|
724 | browserRpc->setData((char *)serviceName);
|
---|
725 | str = browserRpc->getString();
|
---|
726 | if(itsData[0])
|
---|
727 | delete itsData[0];
|
---|
728 | itsData[0] = new TokenString(str,(char *)"|\n");
|
---|
729 | currIndex = 0;
|
---|
730 | if(!itsData[0]->getNTokens())
|
---|
731 | return(0);
|
---|
732 | return( itsData[0]->getNTokens((char *)"\n") + 1);
|
---|
733 | }
|
---|
734 |
|
---|
735 | int DimBrowser::getServers()
|
---|
736 | {
|
---|
737 | return getServers(0);
|
---|
738 | }
|
---|
739 |
|
---|
740 | int DimBrowser::getServers(int timeout)
|
---|
741 | {
|
---|
742 | char *str, *pid_str;
|
---|
743 | int size, totsize;
|
---|
744 | DimCurrentInfo srv((char *)"DIS_DNS/SERVER_LIST", timeout, (char *)"\0");
|
---|
745 | str = srv.getString();
|
---|
746 | size = strlen(str)+1;
|
---|
747 | totsize = srv.getSize();
|
---|
748 |
|
---|
749 | if(itsData[1])
|
---|
750 | delete itsData[1];
|
---|
751 | itsData[1] = new TokenString(str,(char *)"|@\n");
|
---|
752 | currIndex = 1;
|
---|
753 | if(!str[0])
|
---|
754 | return(0);
|
---|
755 | if(totsize > size)
|
---|
756 | {
|
---|
757 | pid_str = str + strlen(str) + 1;
|
---|
758 | if(itsData[4])
|
---|
759 | delete itsData[4];
|
---|
760 | itsData[4] = new TokenString(pid_str,(char *)"|");
|
---|
761 | }
|
---|
762 | return(itsData[1]->getNTokens((char *)"|") +1);
|
---|
763 | }
|
---|
764 |
|
---|
765 | int DimBrowser::getServerServices(const char *serverName)
|
---|
766 | {
|
---|
767 | return getServerServices(serverName, 0);
|
---|
768 | }
|
---|
769 |
|
---|
770 | int DimBrowser::getServerServices(const char *serverName, int timeout)
|
---|
771 | {
|
---|
772 | char *str;
|
---|
773 | char *name = new char[strlen(serverName) + 20];
|
---|
774 | strcpy(name,(char *)serverName);
|
---|
775 | strcat(name,(char *)"/SERVICE_LIST");
|
---|
776 | DimCurrentInfo srv(name, timeout, (char *)"\0");
|
---|
777 | delete[] name;
|
---|
778 | str = srv.getString();
|
---|
779 | if(itsData[2])
|
---|
780 | delete itsData[2];
|
---|
781 | itsData[2] = new TokenString(str,(char *)"|\n");
|
---|
782 | currIndex = 2;
|
---|
783 | if(!itsData[2]->getNTokens())
|
---|
784 | return(0);
|
---|
785 | return(itsData[2]->getNTokens((char *)"\n") + 1);
|
---|
786 | }
|
---|
787 |
|
---|
788 | int DimBrowser::getServerClients(const char *serverName)
|
---|
789 | {
|
---|
790 | return getServerClients(serverName, 0);
|
---|
791 | }
|
---|
792 |
|
---|
793 | int DimBrowser::getServerClients(const char *serverName, int timeout)
|
---|
794 | {
|
---|
795 | char *str;
|
---|
796 | char *name = new char[strlen(serverName) + 20];
|
---|
797 | strcpy(name,(char *)serverName);
|
---|
798 | strcat(name,(char *)"/CLIENT_LIST");
|
---|
799 | DimCurrentInfo srv(name, timeout, (char *)"\0");
|
---|
800 | delete[] name;
|
---|
801 | str = srv.getString();
|
---|
802 | if(itsData[3])
|
---|
803 | delete itsData[3];
|
---|
804 | itsData[3] = new TokenString(str,(char *)"|@\n");
|
---|
805 | currIndex = 3;
|
---|
806 | return(itsData[3]->getNTokens((char *)"@") );
|
---|
807 | }
|
---|
808 |
|
---|
809 | int DimBrowser::getNextService(char *&service, char *&format)
|
---|
810 | {
|
---|
811 | int ret, type;
|
---|
812 |
|
---|
813 | service = format = &none;
|
---|
814 | ret = itsData[0]->getToken(currToken);
|
---|
815 | if(!ret) return 0;
|
---|
816 | service = currToken;
|
---|
817 | ret = itsData[0]->getToken(currToken);
|
---|
818 | if(!itsData[0]->cmpToken((char *)"|"))
|
---|
819 | return 0;
|
---|
820 | ret = itsData[0]->getToken(currToken);
|
---|
821 | if(!itsData[0]->cmpToken((char *)"|"))
|
---|
822 | {
|
---|
823 | format = currToken;
|
---|
824 | ret = itsData[0]->getToken(currToken);
|
---|
825 | if(!itsData[0]->cmpToken((char *)"|"))
|
---|
826 | return 0;
|
---|
827 | }
|
---|
828 | ret = itsData[0]->getToken(currToken);
|
---|
829 | type = DimSERVICE;
|
---|
830 | if(!itsData[0]->cmpToken((char *)"\n"))
|
---|
831 | {
|
---|
832 | if(itsData[0]->cmpToken((char *)"CMD"))
|
---|
833 | type = DimCOMMAND;
|
---|
834 | if(itsData[0]->cmpToken((char *)"RPC"))
|
---|
835 | type = DimRPC;
|
---|
836 | ret = itsData[0]->getToken(currToken);
|
---|
837 | if(!itsData[0]->cmpToken((char *)"\n"))
|
---|
838 | return 0;
|
---|
839 | }
|
---|
840 | return type;
|
---|
841 | }
|
---|
842 |
|
---|
843 | int DimBrowser::getNextServer(char *&server, char *&node)
|
---|
844 | {
|
---|
845 | int ret;
|
---|
846 |
|
---|
847 | server = node = &none;
|
---|
848 | ret = itsData[1]->getToken(currToken);
|
---|
849 | if(!ret) return 0;
|
---|
850 | server = currToken;
|
---|
851 | ret = itsData[1]->getToken(currToken);
|
---|
852 | if(!itsData[1]->cmpToken((char *)"@"))
|
---|
853 | return 0;
|
---|
854 | while(1)
|
---|
855 | {
|
---|
856 | ret = itsData[1]->getToken(currToken);
|
---|
857 | node = currToken;
|
---|
858 | itsData[1]->pushToken();
|
---|
859 | ret = itsData[1]->getToken(currToken);
|
---|
860 | if(itsData[1]->cmpToken((char *)"@"))
|
---|
861 | {
|
---|
862 | strcat(server,"@");
|
---|
863 | strcat(server,node);
|
---|
864 | }
|
---|
865 | else
|
---|
866 | break;
|
---|
867 | }
|
---|
868 | if(!itsData[1]->cmpToken((char *)"|"))
|
---|
869 | itsData[1]->popToken();
|
---|
870 | return 1;
|
---|
871 | }
|
---|
872 |
|
---|
873 | int DimBrowser::getNextServer(char *&server, char *&node, int &pid)
|
---|
874 | {
|
---|
875 | int ret, lpid = 0;
|
---|
876 | char *tok;
|
---|
877 |
|
---|
878 | ret = getNextServer(server, node);
|
---|
879 | if(ret && itsData[4])
|
---|
880 | {
|
---|
881 | ret = itsData[4]->getToken(tok);
|
---|
882 | if(ret)
|
---|
883 | {
|
---|
884 | sscanf(tok,"%d",&lpid);
|
---|
885 | pid = lpid;
|
---|
886 | }
|
---|
887 | }
|
---|
888 | if(!ret)
|
---|
889 | return 0;
|
---|
890 | ret = itsData[4]->getToken(tok);
|
---|
891 | return 1;
|
---|
892 | }
|
---|
893 |
|
---|
894 | int DimBrowser::getNextServerService(char *&service, char *&format)
|
---|
895 | {
|
---|
896 | int ret, type;
|
---|
897 |
|
---|
898 | service = format = &none;
|
---|
899 | ret = itsData[2]->getToken(currToken);
|
---|
900 | if(!ret) return 0;
|
---|
901 | service = currToken;
|
---|
902 | ret = itsData[2]->getToken(currToken);
|
---|
903 | if(!itsData[2]->cmpToken((char *)"|"))
|
---|
904 | return 0;
|
---|
905 | ret = itsData[2]->getToken(currToken);
|
---|
906 | if(!itsData[2]->cmpToken((char *)"|"))
|
---|
907 | {
|
---|
908 | format = currToken;
|
---|
909 | ret = itsData[2]->getToken(currToken);
|
---|
910 | if(!itsData[2]->cmpToken((char *)"|"))
|
---|
911 | return 0;
|
---|
912 | }
|
---|
913 | ret = itsData[2]->getToken(currToken);
|
---|
914 | type = DimSERVICE;
|
---|
915 | if(!itsData[2]->cmpToken((char *)"\n"))
|
---|
916 | {
|
---|
917 | if(itsData[2]->cmpToken((char *)"CMD"))
|
---|
918 | type = DimCOMMAND;
|
---|
919 | if(itsData[2]->cmpToken((char *)"RPC"))
|
---|
920 | type = DimRPC;
|
---|
921 | ret = itsData[2]->getToken(currToken);
|
---|
922 | if(!itsData[2]->cmpToken((char *)"\n"))
|
---|
923 | return 0;
|
---|
924 | }
|
---|
925 | return type;
|
---|
926 | }
|
---|
927 |
|
---|
928 | int DimBrowser::getNextServerClient(char *&client, char *&node)
|
---|
929 | {
|
---|
930 | int ret;
|
---|
931 |
|
---|
932 | client = node = &none;
|
---|
933 | ret = itsData[3]->getToken(currToken);
|
---|
934 | if(!ret) return 0;
|
---|
935 | client = currToken;
|
---|
936 | ret = itsData[3]->getToken(currToken);
|
---|
937 | if(!itsData[3]->cmpToken((char *)"@"))
|
---|
938 | return 0;
|
---|
939 | ret = itsData[3]->getToken(currToken);
|
---|
940 | node = currToken;
|
---|
941 | itsData[3]->pushToken();
|
---|
942 | ret = itsData[3]->getToken(currToken);
|
---|
943 | if(!itsData[3]->cmpToken((char *)"|"))
|
---|
944 | itsData[3]->popToken();
|
---|
945 | return 1;
|
---|
946 | }
|
---|
947 |
|
---|
948 | DimClient::DimClient()
|
---|
949 | {
|
---|
950 | itsCltError = this;
|
---|
951 | }
|
---|
952 |
|
---|
953 | DimClient::~DimClient()
|
---|
954 | {
|
---|
955 | if(dimDnsNode)
|
---|
956 | delete[] dimDnsNode;
|
---|
957 | }
|
---|
958 |
|
---|
959 | int DimClient::sendCommand(const char *name, int data)
|
---|
960 | {
|
---|
961 | DimCmnd a;
|
---|
962 | return a.send((char *)name, &data, sizeof(int));
|
---|
963 | }
|
---|
964 |
|
---|
965 | int DimClient::sendCommand(const char *name, float data)
|
---|
966 | {
|
---|
967 | DimCmnd a;
|
---|
968 | return a.send((char *)name, &data, sizeof(float));
|
---|
969 | }
|
---|
970 |
|
---|
971 | int DimClient::sendCommand(const char *name, double data)
|
---|
972 | {
|
---|
973 | DimCmnd a;
|
---|
974 | return a.send((char *)name, &data, sizeof(double));
|
---|
975 | }
|
---|
976 |
|
---|
977 | int DimClient::sendCommand(const char *name, longlong data)
|
---|
978 | {
|
---|
979 | DimCmnd a;
|
---|
980 | return a.send((char *)name, &data, sizeof(longlong));
|
---|
981 | }
|
---|
982 |
|
---|
983 | int DimClient::sendCommand(const char *name, short data)
|
---|
984 | {
|
---|
985 | DimCmnd a;
|
---|
986 | return a.send((char *)name, &data, sizeof(short));
|
---|
987 | }
|
---|
988 |
|
---|
989 | int DimClient::sendCommand(const char *name, const char *data)
|
---|
990 | {
|
---|
991 | DimCmnd a;
|
---|
992 | return a.send((char *)name, (char *)data, strlen(data)+1);
|
---|
993 | }
|
---|
994 |
|
---|
995 | int DimClient::sendCommand(const char *name, void *data, int datasize)
|
---|
996 | {
|
---|
997 | DimCmnd a;
|
---|
998 | return a.send((char *)name, data, datasize);
|
---|
999 | }
|
---|
1000 |
|
---|
1001 | void DimClient::sendCommandNB(const char *name, int data)
|
---|
1002 | {
|
---|
1003 | DimCmnd a;
|
---|
1004 | a.sendNB((char *)name, &data, sizeof(int));
|
---|
1005 | }
|
---|
1006 |
|
---|
1007 | void DimClient::sendCommandNB(const char *name, float data)
|
---|
1008 | {
|
---|
1009 | DimCmnd a;
|
---|
1010 | a.sendNB((char *)name, &data, sizeof(float));
|
---|
1011 | }
|
---|
1012 |
|
---|
1013 | void DimClient::sendCommandNB(const char *name, double data)
|
---|
1014 | {
|
---|
1015 | DimCmnd a;
|
---|
1016 | a.sendNB((char *)name, &data, sizeof(double));
|
---|
1017 | }
|
---|
1018 |
|
---|
1019 | void DimClient::sendCommandNB(const char *name, longlong data)
|
---|
1020 | {
|
---|
1021 | DimCmnd a;
|
---|
1022 | a.sendNB((char *)name, &data, sizeof(longlong));
|
---|
1023 | }
|
---|
1024 |
|
---|
1025 | void DimClient::sendCommandNB(const char *name, short data)
|
---|
1026 | {
|
---|
1027 | DimCmnd a;
|
---|
1028 | a.sendNB((char *)name, &data, sizeof(short));
|
---|
1029 | }
|
---|
1030 |
|
---|
1031 | void DimClient::sendCommandNB(const char *name, char *data)
|
---|
1032 | {
|
---|
1033 | DimCmnd a;
|
---|
1034 | a.sendNB((char *)name, data, strlen(data)+1);
|
---|
1035 | }
|
---|
1036 |
|
---|
1037 | void DimClient::sendCommandNB(const char *name, void *data, int datasize)
|
---|
1038 | {
|
---|
1039 | DimCmnd a;
|
---|
1040 | a.sendNB((char *)name, data, datasize);
|
---|
1041 | }
|
---|
1042 |
|
---|
1043 | int DimClient::setExitHandler(const char *srvName)
|
---|
1044 | {
|
---|
1045 | DimCmnd a;
|
---|
1046 | int ret, tag = 1;
|
---|
1047 | char *name = new char[strlen(srvName) + 20];
|
---|
1048 | strcpy(name,(char *)srvName);
|
---|
1049 | strcat(name,"/SET_EXIT_HANDLER");
|
---|
1050 | ret = a.send(name, &tag, sizeof(int));
|
---|
1051 | delete[] name;
|
---|
1052 | return ret;
|
---|
1053 | }
|
---|
1054 |
|
---|
1055 | int DimClient::killServer(const char *srvName)
|
---|
1056 | {
|
---|
1057 | DimCmnd a;
|
---|
1058 | int ret, tag = 1;
|
---|
1059 | char *name = new char[strlen(srvName) + 20];
|
---|
1060 | strcpy(name,(char *)srvName);
|
---|
1061 | strcat(name,"/EXIT");
|
---|
1062 | ret = a.send(name, &tag, sizeof(int));
|
---|
1063 | delete[] name;
|
---|
1064 | return ret;
|
---|
1065 | }
|
---|
1066 |
|
---|
1067 | int DimClient::setDnsNode(const char *node)
|
---|
1068 | {
|
---|
1069 | dic_set_dns_node((char *)node);
|
---|
1070 | dic_close_dns();
|
---|
1071 | return 1;
|
---|
1072 | }
|
---|
1073 |
|
---|
1074 | int DimClient::setDnsNode(const char *node, int port)
|
---|
1075 | {
|
---|
1076 | dic_set_dns_port(port);
|
---|
1077 | dic_set_dns_node((char *)node);
|
---|
1078 | dic_close_dns();
|
---|
1079 | return 1;
|
---|
1080 | }
|
---|
1081 |
|
---|
1082 | char *DimClient::getDnsNode()
|
---|
1083 | {
|
---|
1084 | if(!dimDnsNode)
|
---|
1085 | dimDnsNode = new char[256];
|
---|
1086 | if(dic_get_dns_node(dimDnsNode))
|
---|
1087 | return dimDnsNode;
|
---|
1088 | else
|
---|
1089 | return 0;
|
---|
1090 | }
|
---|
1091 |
|
---|
1092 | int DimClient::getDnsPort()
|
---|
1093 | {
|
---|
1094 | return dic_get_dns_port();
|
---|
1095 | }
|
---|
1096 |
|
---|
1097 | void DimClient::setNoDataCopy()
|
---|
1098 | {
|
---|
1099 | dicNoCopy = 1;
|
---|
1100 | }
|
---|
1101 |
|
---|
1102 | int DimClient::getNoDataCopy()
|
---|
1103 | {
|
---|
1104 | return dicNoCopy;
|
---|
1105 | }
|
---|
1106 |
|
---|
1107 | extern "C" {
|
---|
1108 | //static void clt_error_user_routine(char*, int);
|
---|
1109 | static void clt_error_user_routine(int severity, int code, char *msg)
|
---|
1110 | {
|
---|
1111 |
|
---|
1112 | DimCore::inCallback = 2;
|
---|
1113 | DimClient::itsCltError->errorHandler(severity, code, msg);
|
---|
1114 | DimCore::inCallback = 0;
|
---|
1115 | }
|
---|
1116 | }
|
---|
1117 |
|
---|
1118 | void DimClient::addErrorHandler(DimErrorHandler *handler)
|
---|
1119 | {
|
---|
1120 | DimClient::itsCltError = handler;
|
---|
1121 | dic_add_error_handler(clt_error_user_routine);
|
---|
1122 | }
|
---|
1123 |
|
---|
1124 | void DimClient::addErrorHandler()
|
---|
1125 | {
|
---|
1126 | DimClient::itsCltError = this;
|
---|
1127 | dic_add_error_handler(clt_error_user_routine);
|
---|
1128 | }
|
---|
1129 |
|
---|
1130 | int DimClient::getServerId()
|
---|
1131 | {
|
---|
1132 | if(!serverName)
|
---|
1133 | serverName = new char[128];
|
---|
1134 | serverName[0] = '\0';
|
---|
1135 | return dic_get_server(serverName);
|
---|
1136 | }
|
---|
1137 |
|
---|
1138 | int DimClient::getServerPid()
|
---|
1139 | {
|
---|
1140 | int pid, ret;
|
---|
1141 |
|
---|
1142 | ret = dic_get_server_pid(&pid);
|
---|
1143 | if(!ret)
|
---|
1144 | return 0;
|
---|
1145 | return pid;
|
---|
1146 | }
|
---|
1147 |
|
---|
1148 | char *DimClient::getServerName()
|
---|
1149 | {
|
---|
1150 | if(!serverName)
|
---|
1151 | serverName = new char[128];
|
---|
1152 | serverName[0] = '\0';
|
---|
1153 | dic_get_server(serverName);
|
---|
1154 | return(serverName);
|
---|
1155 | }
|
---|
1156 |
|
---|
1157 | /*
|
---|
1158 | char *DimClient::getServerServices(int serverId)
|
---|
1159 | {
|
---|
1160 | return dic_get_server_services(serverId);
|
---|
1161 | }
|
---|
1162 |
|
---|
1163 | char *DimClient::getServerServices()
|
---|
1164 | {
|
---|
1165 | int id;
|
---|
1166 | if((id = dic_get_conn_id()))
|
---|
1167 | return dic_get_server_services(id);
|
---|
1168 | return (char *)0;
|
---|
1169 | }
|
---|
1170 | */
|
---|
1171 | char **DimClient::getServerServices()
|
---|
1172 | {
|
---|
1173 | static TokenString *data = 0;
|
---|
1174 | int id, len = 0, index = 0;
|
---|
1175 | char *services;
|
---|
1176 | static char** list = 0;
|
---|
1177 | char *sep;
|
---|
1178 |
|
---|
1179 | if(data)
|
---|
1180 | {
|
---|
1181 | delete data;
|
---|
1182 | data = 0;
|
---|
1183 | }
|
---|
1184 | if(list)
|
---|
1185 | {
|
---|
1186 | delete[] list;
|
---|
1187 | list = 0;
|
---|
1188 | }
|
---|
1189 | if((id = dic_get_conn_id()))
|
---|
1190 | {
|
---|
1191 | services = dic_get_server_services(id);
|
---|
1192 | if(services)
|
---|
1193 | {
|
---|
1194 | data = new TokenString(services,(char *)"\n");
|
---|
1195 | len = data->getNTokens();
|
---|
1196 | list = new char*[len];
|
---|
1197 | while(data->getToken(list[index]))
|
---|
1198 | {
|
---|
1199 | data->getToken(sep);
|
---|
1200 | index++;
|
---|
1201 | }
|
---|
1202 | }
|
---|
1203 | }
|
---|
1204 | if(!len)
|
---|
1205 | list = new char*[1];
|
---|
1206 | list[index] = 0;
|
---|
1207 | return list;
|
---|
1208 | }
|
---|