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 | if(DimClient::getNoDataCopy() == 0)
|
---|
455 | memcpy(t->itsData, buf, size);
|
---|
456 | else
|
---|
457 | t->itsData = buf;
|
---|
458 | t->itsSize = size;
|
---|
459 | t->wakeUp = 1;
|
---|
460 | if(t->itsInit)
|
---|
461 | {
|
---|
462 | t->itsWaiting = 1;
|
---|
463 | t->itsHandler->rpcInfoHandler();
|
---|
464 | }
|
---|
465 | if(t->itsWaiting != 2)
|
---|
466 | t->itsWaiting = 0;
|
---|
467 | }
|
---|
468 | #ifdef __VMS
|
---|
469 | sys$wake(0,0);
|
---|
470 | #endif
|
---|
471 | #ifdef WIN32
|
---|
472 | wake_up();
|
---|
473 | #endif
|
---|
474 | }
|
---|
475 | }
|
---|
476 |
|
---|
477 | void DimRpcInfo::timerHandler()
|
---|
478 | {
|
---|
479 | char *buf;
|
---|
480 | int size;
|
---|
481 |
|
---|
482 | buf = (char *)itsNolinkBuf;
|
---|
483 | size = itsNolinkSize;
|
---|
484 |
|
---|
485 | if(DimClient::getNoDataCopy() == 0)
|
---|
486 | {
|
---|
487 | if(!itsDataSize)
|
---|
488 | {
|
---|
489 | itsData = new char[size];
|
---|
490 | itsDataSize = size;
|
---|
491 | }
|
---|
492 | else if(itsDataSize < size)
|
---|
493 | {
|
---|
494 | delete[] (char *)(itsData);
|
---|
495 | itsData = new char[size];
|
---|
496 | itsDataSize = size;
|
---|
497 | }
|
---|
498 | }
|
---|
499 | if(itsWaiting)
|
---|
500 | {
|
---|
501 | if(DimClient::getNoDataCopy() == 0)
|
---|
502 | memcpy(itsData, buf, size);
|
---|
503 | else
|
---|
504 | itsData = buf;
|
---|
505 | itsSize = size;
|
---|
506 | wakeUp = 1;
|
---|
507 | if(itsInit)
|
---|
508 | {
|
---|
509 | itsWaiting = 1;
|
---|
510 | itsHandler->rpcInfoHandler();
|
---|
511 | }
|
---|
512 | if(itsWaiting != 2)
|
---|
513 | itsWaiting = 0;
|
---|
514 | }
|
---|
515 | #ifdef __VMS
|
---|
516 | sys$wake(0,0);
|
---|
517 | #endif
|
---|
518 | #ifdef WIN32
|
---|
519 | wake_up();
|
---|
520 | #endif
|
---|
521 | }
|
---|
522 |
|
---|
523 | void DimRpcInfo::rpcInfoHandler()
|
---|
524 | {
|
---|
525 | char *data;
|
---|
526 | if(DimClient::getNoDataCopy() == 1)
|
---|
527 | {
|
---|
528 | data = (char *)itsData;
|
---|
529 | if(!itsDataSize)
|
---|
530 | {
|
---|
531 | itsData = new char[itsSize];
|
---|
532 | itsDataSize = itsSize;
|
---|
533 | }
|
---|
534 | else if(itsDataSize < itsSize)
|
---|
535 | {
|
---|
536 | delete[] (char *)(itsData);
|
---|
537 | itsData = new char[itsSize];
|
---|
538 | itsDataSize = itsSize;
|
---|
539 | }
|
---|
540 | memcpy(itsData, data, itsSize);
|
---|
541 | }
|
---|
542 | }
|
---|
543 |
|
---|
544 | void DimRpcInfo::subscribe(char *name, void *data, int size,
|
---|
545 | void *nolink, int nolinksize, int timeout)
|
---|
546 | {
|
---|
547 |
|
---|
548 | itsId = 0;
|
---|
549 | // itsTagId = 0;
|
---|
550 | itsInit = 0;
|
---|
551 | itsWaiting = 0;
|
---|
552 | itsName = new char[strlen(name)+1];
|
---|
553 | strcpy(itsName,name);
|
---|
554 | itsHandler = this;
|
---|
555 | itsDataSize = 0;
|
---|
556 | itsData = 0;
|
---|
557 | itsDataOutSize = 0;
|
---|
558 | itsDataOut = 0;
|
---|
559 | itsNolinkBuf = new char[nolinksize];
|
---|
560 | itsNolinkSize = nolinksize;
|
---|
561 | memcpy(itsNolinkBuf, nolink, nolinksize);
|
---|
562 | itsNameOut = new char[strlen(name)+1+10];
|
---|
563 | strcpy(itsNameOut,name);
|
---|
564 | strcat(itsNameOut,(char *)"/RpcIn");
|
---|
565 | itsNameIn = new char[strlen(name)+1+10];
|
---|
566 | strcpy(itsNameIn,name);
|
---|
567 | strcat(itsNameIn,(char *)"/RpcOut");
|
---|
568 | itsTimeout = timeout;
|
---|
569 | dim_init();
|
---|
570 | {
|
---|
571 | if(!itsId)
|
---|
572 | {
|
---|
573 | // itsTagId = id_get((void *)itsHandler, SRC_DIC);
|
---|
574 |
|
---|
575 | // itsId = dic_info_service_stamped(itsNameIn,MONIT_ONLY,itsTimeout,
|
---|
576 | itsConnected = 0;
|
---|
577 | // itsId = dic_info_service_stamped(itsNameIn,MONITORED,itsTimeout,
|
---|
578 | itsId = dic_info_service_stamped(itsNameIn,MONIT_FIRST,itsTimeout,
|
---|
579 | 0, 0,
|
---|
580 | // rpc_user_routine, itsTagId,
|
---|
581 | rpc_user_routine, (long)itsHandler,
|
---|
582 | itsNolinkBuf, itsNolinkSize);
|
---|
583 | // dim_usleep(200000);
|
---|
584 | itsInit = 1;
|
---|
585 | }
|
---|
586 | }
|
---|
587 | if(size)
|
---|
588 | {
|
---|
589 | doIt(data, size);
|
---|
590 | }
|
---|
591 | }
|
---|
592 |
|
---|
593 | void DimRpcInfo::doIt(void *data, int size)
|
---|
594 | {
|
---|
595 | int ret;
|
---|
596 |
|
---|
597 | wakeUp = 0;
|
---|
598 | if(DimClient::getNoDataCopy() == 0)
|
---|
599 | {
|
---|
600 | if(!itsDataOut)
|
---|
601 | {
|
---|
602 | itsDataOut = new char[size];
|
---|
603 | itsDataOutSize = size;
|
---|
604 | }
|
---|
605 | else if(itsDataOutSize < size)
|
---|
606 | {
|
---|
607 | delete[] (char *)itsDataOut;
|
---|
608 | itsDataOut = new char[size];
|
---|
609 | itsDataOutSize = size;
|
---|
610 | }
|
---|
611 | memcpy(itsDataOut, data, size);
|
---|
612 | }
|
---|
613 | else
|
---|
614 | {
|
---|
615 | itsDataOut = data;
|
---|
616 | }
|
---|
617 | while(!itsConnected)
|
---|
618 | dim_wait();
|
---|
619 | itsWaiting = 1;
|
---|
620 | ret = DimClient::sendCommand(itsNameOut, itsDataOut, size);
|
---|
621 | if(!ret)
|
---|
622 | {
|
---|
623 | // rpc_user_routine((int *)&itsTagId, itsNolinkBuf, &itsNolinkSize);
|
---|
624 | rpc_user_routine((long *)&itsHandler, itsNolinkBuf, &itsNolinkSize);
|
---|
625 | }
|
---|
626 | else
|
---|
627 | {
|
---|
628 | if(itsTimeout)
|
---|
629 | start(itsTimeout);
|
---|
630 | }
|
---|
631 | }
|
---|
632 |
|
---|
633 | void *DimRpcInfo::getData()
|
---|
634 | {
|
---|
635 | while(!wakeUp)
|
---|
636 | {
|
---|
637 | #ifdef __VMS
|
---|
638 | sys$hiber();
|
---|
639 | #else
|
---|
640 | dim_wait();
|
---|
641 | #endif
|
---|
642 | }
|
---|
643 | /*
|
---|
644 | if(DimClient::getNoDataCopy() == 1)
|
---|
645 | {
|
---|
646 | if(!DimCore::inCallback)
|
---|
647 | return (void *)0;
|
---|
648 | }
|
---|
649 | */
|
---|
650 | return this->itsData;
|
---|
651 | }
|
---|
652 |
|
---|
653 | DimRpcInfo::~DimRpcInfo()
|
---|
654 | {
|
---|
655 | // if(itsTagId)
|
---|
656 | // id_free(itsTagId, SRC_DIC);
|
---|
657 | if(itsId)
|
---|
658 | dic_release_service(itsId);
|
---|
659 | delete[] (char *)itsNolinkBuf;
|
---|
660 | if(itsDataSize)
|
---|
661 | delete[] (char *)itsData;
|
---|
662 | if(itsDataOutSize)
|
---|
663 | delete[] (char *)itsDataOut;
|
---|
664 | delete[] itsName;
|
---|
665 | delete[] itsNameIn;
|
---|
666 | delete[] itsNameOut;
|
---|
667 | }
|
---|
668 |
|
---|
669 | DimBrowser::DimBrowser()
|
---|
670 | {
|
---|
671 | int i;
|
---|
672 | for(i = 0; i<5; i++)
|
---|
673 | {
|
---|
674 | itsData[i] = 0;
|
---|
675 | itsData[i] = 0;
|
---|
676 | }
|
---|
677 | currIndex = -1;
|
---|
678 | none = 0;
|
---|
679 | browserRpc = 0;
|
---|
680 | }
|
---|
681 |
|
---|
682 | DimBrowser::~DimBrowser()
|
---|
683 | {
|
---|
684 | int i;
|
---|
685 | for(i = 0; i<5; i++)
|
---|
686 | {
|
---|
687 | if(itsData[i])
|
---|
688 | delete itsData[i];
|
---|
689 | }
|
---|
690 | if(browserRpc)
|
---|
691 | delete browserRpc;
|
---|
692 | }
|
---|
693 |
|
---|
694 | int DimBrowser::getServices(const char * serviceName)
|
---|
695 | {
|
---|
696 | return getServices(serviceName, 0);
|
---|
697 | }
|
---|
698 |
|
---|
699 | int DimBrowser::getServices(const char * serviceName, int timeout)
|
---|
700 | {
|
---|
701 | char *str;
|
---|
702 |
|
---|
703 | // DimRpcInfo rpc((char *)"DIS_DNS/SERVICE_INFO",(char *)"\0");
|
---|
704 | // rpc.setData((char *)serviceName);
|
---|
705 | // str = rpc.getString();
|
---|
706 | if(!browserRpc)
|
---|
707 | browserRpc = new DimRpcInfo((char *)"DIS_DNS/SERVICE_INFO",timeout,(char *)"\0");
|
---|
708 | browserRpc->setData((char *)serviceName);
|
---|
709 | str = browserRpc->getString();
|
---|
710 | if(itsData[0])
|
---|
711 | delete itsData[0];
|
---|
712 | itsData[0] = new TokenString(str,(char *)"|\n");
|
---|
713 | currIndex = 0;
|
---|
714 | if(!itsData[0]->getNTokens())
|
---|
715 | return(0);
|
---|
716 | return( itsData[0]->getNTokens((char *)"\n") + 1);
|
---|
717 | }
|
---|
718 |
|
---|
719 | int DimBrowser::getServers()
|
---|
720 | {
|
---|
721 | return getServers(0);
|
---|
722 | }
|
---|
723 |
|
---|
724 | int DimBrowser::getServers(int timeout)
|
---|
725 | {
|
---|
726 | char *str, *pid_str;
|
---|
727 | int size, totsize;
|
---|
728 | DimCurrentInfo srv((char *)"DIS_DNS/SERVER_LIST", timeout, (char *)"\0");
|
---|
729 | str = srv.getString();
|
---|
730 | size = strlen(str)+1;
|
---|
731 | totsize = srv.getSize();
|
---|
732 |
|
---|
733 | if(itsData[1])
|
---|
734 | delete itsData[1];
|
---|
735 | itsData[1] = new TokenString(str,(char *)"|@\n");
|
---|
736 | currIndex = 1;
|
---|
737 | if(!str[0])
|
---|
738 | return(0);
|
---|
739 | if(totsize > size)
|
---|
740 | {
|
---|
741 | pid_str = str + strlen(str) + 1;
|
---|
742 | if(itsData[4])
|
---|
743 | delete itsData[4];
|
---|
744 | itsData[4] = new TokenString(pid_str,(char *)"|");
|
---|
745 | }
|
---|
746 | return(itsData[1]->getNTokens((char *)"|") +1);
|
---|
747 | }
|
---|
748 |
|
---|
749 | int DimBrowser::getServerServices(const char *serverName)
|
---|
750 | {
|
---|
751 | return getServerServices(serverName, 0);
|
---|
752 | }
|
---|
753 |
|
---|
754 | int DimBrowser::getServerServices(const char *serverName, int timeout)
|
---|
755 | {
|
---|
756 | char *str;
|
---|
757 | char *name = new char[strlen(serverName) + 20];
|
---|
758 | strcpy(name,(char *)serverName);
|
---|
759 | strcat(name,(char *)"/SERVICE_LIST");
|
---|
760 | DimCurrentInfo srv(name, timeout, (char *)"\0");
|
---|
761 | delete[] name;
|
---|
762 | str = srv.getString();
|
---|
763 | if(itsData[2])
|
---|
764 | delete itsData[2];
|
---|
765 | itsData[2] = new TokenString(str,(char *)"|\n");
|
---|
766 | currIndex = 2;
|
---|
767 | if(!itsData[2]->getNTokens())
|
---|
768 | return(0);
|
---|
769 | return(itsData[2]->getNTokens((char *)"\n") + 1);
|
---|
770 | }
|
---|
771 |
|
---|
772 | int DimBrowser::getServerClients(const char *serverName)
|
---|
773 | {
|
---|
774 | return getServerClients(serverName, 0);
|
---|
775 | }
|
---|
776 |
|
---|
777 | int DimBrowser::getServerClients(const char *serverName, int timeout)
|
---|
778 | {
|
---|
779 | char *str;
|
---|
780 | char *name = new char[strlen(serverName) + 20];
|
---|
781 | strcpy(name,(char *)serverName);
|
---|
782 | strcat(name,(char *)"/CLIENT_LIST");
|
---|
783 | DimCurrentInfo srv(name, timeout, (char *)"\0");
|
---|
784 | delete[] name;
|
---|
785 | str = srv.getString();
|
---|
786 | if(itsData[3])
|
---|
787 | delete itsData[3];
|
---|
788 | itsData[3] = new TokenString(str,(char *)"|@\n");
|
---|
789 | currIndex = 3;
|
---|
790 | return(itsData[3]->getNTokens((char *)"@") );
|
---|
791 | }
|
---|
792 |
|
---|
793 | int DimBrowser::getNextService(char *&service, char *&format)
|
---|
794 | {
|
---|
795 | int ret, type;
|
---|
796 |
|
---|
797 | service = format = &none;
|
---|
798 | ret = itsData[0]->getToken(currToken);
|
---|
799 | if(!ret) return 0;
|
---|
800 | service = currToken;
|
---|
801 | ret = itsData[0]->getToken(currToken);
|
---|
802 | if(!itsData[0]->cmpToken((char *)"|"))
|
---|
803 | return 0;
|
---|
804 | ret = itsData[0]->getToken(currToken);
|
---|
805 | if(!itsData[0]->cmpToken((char *)"|"))
|
---|
806 | {
|
---|
807 | format = currToken;
|
---|
808 | ret = itsData[0]->getToken(currToken);
|
---|
809 | if(!itsData[0]->cmpToken((char *)"|"))
|
---|
810 | return 0;
|
---|
811 | }
|
---|
812 | ret = itsData[0]->getToken(currToken);
|
---|
813 | type = DimSERVICE;
|
---|
814 | if(!itsData[0]->cmpToken((char *)"\n"))
|
---|
815 | {
|
---|
816 | if(itsData[0]->cmpToken((char *)"CMD"))
|
---|
817 | type = DimCOMMAND;
|
---|
818 | if(itsData[0]->cmpToken((char *)"RPC"))
|
---|
819 | type = DimRPC;
|
---|
820 | ret = itsData[0]->getToken(currToken);
|
---|
821 | if(!itsData[0]->cmpToken((char *)"\n"))
|
---|
822 | return 0;
|
---|
823 | }
|
---|
824 | return type;
|
---|
825 | }
|
---|
826 |
|
---|
827 | int DimBrowser::getNextServer(char *&server, char *&node)
|
---|
828 | {
|
---|
829 | int ret;
|
---|
830 |
|
---|
831 | server = node = &none;
|
---|
832 | ret = itsData[1]->getToken(currToken);
|
---|
833 | if(!ret) return 0;
|
---|
834 | server = currToken;
|
---|
835 | ret = itsData[1]->getToken(currToken);
|
---|
836 | if(!itsData[1]->cmpToken((char *)"@"))
|
---|
837 | return 0;
|
---|
838 | while(1)
|
---|
839 | {
|
---|
840 | ret = itsData[1]->getToken(currToken);
|
---|
841 | node = currToken;
|
---|
842 | itsData[1]->pushToken();
|
---|
843 | ret = itsData[1]->getToken(currToken);
|
---|
844 | if(itsData[1]->cmpToken((char *)"@"))
|
---|
845 | {
|
---|
846 | strcat(server,"@");
|
---|
847 | strcat(server,node);
|
---|
848 | }
|
---|
849 | else
|
---|
850 | break;
|
---|
851 | }
|
---|
852 | if(!itsData[1]->cmpToken((char *)"|"))
|
---|
853 | itsData[1]->popToken();
|
---|
854 | return 1;
|
---|
855 | }
|
---|
856 |
|
---|
857 | int DimBrowser::getNextServer(char *&server, char *&node, int &pid)
|
---|
858 | {
|
---|
859 | int ret, lpid = 0;
|
---|
860 | char *tok;
|
---|
861 |
|
---|
862 | ret = getNextServer(server, node);
|
---|
863 | if(ret && itsData[4])
|
---|
864 | {
|
---|
865 | ret = itsData[4]->getToken(tok);
|
---|
866 | if(ret)
|
---|
867 | {
|
---|
868 | sscanf(tok,"%d",&lpid);
|
---|
869 | pid = lpid;
|
---|
870 | }
|
---|
871 | }
|
---|
872 | if(!ret)
|
---|
873 | return 0;
|
---|
874 | ret = itsData[4]->getToken(tok);
|
---|
875 | return 1;
|
---|
876 | }
|
---|
877 |
|
---|
878 | int DimBrowser::getNextServerService(char *&service, char *&format)
|
---|
879 | {
|
---|
880 | int ret, type;
|
---|
881 |
|
---|
882 | service = format = &none;
|
---|
883 | ret = itsData[2]->getToken(currToken);
|
---|
884 | if(!ret) return 0;
|
---|
885 | service = currToken;
|
---|
886 | ret = itsData[2]->getToken(currToken);
|
---|
887 | if(!itsData[2]->cmpToken((char *)"|"))
|
---|
888 | return 0;
|
---|
889 | ret = itsData[2]->getToken(currToken);
|
---|
890 | if(!itsData[2]->cmpToken((char *)"|"))
|
---|
891 | {
|
---|
892 | format = currToken;
|
---|
893 | ret = itsData[2]->getToken(currToken);
|
---|
894 | if(!itsData[2]->cmpToken((char *)"|"))
|
---|
895 | return 0;
|
---|
896 | }
|
---|
897 | ret = itsData[2]->getToken(currToken);
|
---|
898 | type = DimSERVICE;
|
---|
899 | if(!itsData[2]->cmpToken((char *)"\n"))
|
---|
900 | {
|
---|
901 | if(itsData[2]->cmpToken((char *)"CMD"))
|
---|
902 | type = DimCOMMAND;
|
---|
903 | if(itsData[2]->cmpToken((char *)"RPC"))
|
---|
904 | type = DimRPC;
|
---|
905 | ret = itsData[2]->getToken(currToken);
|
---|
906 | if(!itsData[2]->cmpToken((char *)"\n"))
|
---|
907 | return 0;
|
---|
908 | }
|
---|
909 | return type;
|
---|
910 | }
|
---|
911 |
|
---|
912 | int DimBrowser::getNextServerClient(char *&client, char *&node)
|
---|
913 | {
|
---|
914 | int ret;
|
---|
915 |
|
---|
916 | client = node = &none;
|
---|
917 | ret = itsData[3]->getToken(currToken);
|
---|
918 | if(!ret) return 0;
|
---|
919 | client = currToken;
|
---|
920 | ret = itsData[3]->getToken(currToken);
|
---|
921 | if(!itsData[3]->cmpToken((char *)"@"))
|
---|
922 | return 0;
|
---|
923 | ret = itsData[3]->getToken(currToken);
|
---|
924 | node = currToken;
|
---|
925 | itsData[3]->pushToken();
|
---|
926 | ret = itsData[3]->getToken(currToken);
|
---|
927 | if(!itsData[3]->cmpToken((char *)"|"))
|
---|
928 | itsData[3]->popToken();
|
---|
929 | return 1;
|
---|
930 | }
|
---|
931 |
|
---|
932 | DimClient::DimClient()
|
---|
933 | {
|
---|
934 | itsCltError = this;
|
---|
935 | }
|
---|
936 |
|
---|
937 | DimClient::~DimClient()
|
---|
938 | {
|
---|
939 | if(dimDnsNode)
|
---|
940 | delete[] dimDnsNode;
|
---|
941 | }
|
---|
942 |
|
---|
943 | int DimClient::sendCommand(const char *name, int data)
|
---|
944 | {
|
---|
945 | DimCmnd a;
|
---|
946 | return a.send((char *)name, &data, sizeof(int));
|
---|
947 | }
|
---|
948 |
|
---|
949 | int DimClient::sendCommand(const char *name, float data)
|
---|
950 | {
|
---|
951 | DimCmnd a;
|
---|
952 | return a.send((char *)name, &data, sizeof(float));
|
---|
953 | }
|
---|
954 |
|
---|
955 | int DimClient::sendCommand(const char *name, double data)
|
---|
956 | {
|
---|
957 | DimCmnd a;
|
---|
958 | return a.send((char *)name, &data, sizeof(double));
|
---|
959 | }
|
---|
960 |
|
---|
961 | int DimClient::sendCommand(const char *name, longlong data)
|
---|
962 | {
|
---|
963 | DimCmnd a;
|
---|
964 | return a.send((char *)name, &data, sizeof(longlong));
|
---|
965 | }
|
---|
966 |
|
---|
967 | int DimClient::sendCommand(const char *name, short data)
|
---|
968 | {
|
---|
969 | DimCmnd a;
|
---|
970 | return a.send((char *)name, &data, sizeof(short));
|
---|
971 | }
|
---|
972 |
|
---|
973 | int DimClient::sendCommand(const char *name, const char *data)
|
---|
974 | {
|
---|
975 | DimCmnd a;
|
---|
976 | return a.send((char *)name, (char *)data, strlen(data)+1);
|
---|
977 | }
|
---|
978 |
|
---|
979 | int DimClient::sendCommand(const char *name, void *data, int datasize)
|
---|
980 | {
|
---|
981 | DimCmnd a;
|
---|
982 | return a.send((char *)name, data, datasize);
|
---|
983 | }
|
---|
984 |
|
---|
985 | void DimClient::sendCommandNB(const char *name, int data)
|
---|
986 | {
|
---|
987 | DimCmnd a;
|
---|
988 | a.sendNB((char *)name, &data, sizeof(int));
|
---|
989 | }
|
---|
990 |
|
---|
991 | void DimClient::sendCommandNB(const char *name, float data)
|
---|
992 | {
|
---|
993 | DimCmnd a;
|
---|
994 | a.sendNB((char *)name, &data, sizeof(float));
|
---|
995 | }
|
---|
996 |
|
---|
997 | void DimClient::sendCommandNB(const char *name, double data)
|
---|
998 | {
|
---|
999 | DimCmnd a;
|
---|
1000 | a.sendNB((char *)name, &data, sizeof(double));
|
---|
1001 | }
|
---|
1002 |
|
---|
1003 | void DimClient::sendCommandNB(const char *name, longlong data)
|
---|
1004 | {
|
---|
1005 | DimCmnd a;
|
---|
1006 | a.sendNB((char *)name, &data, sizeof(longlong));
|
---|
1007 | }
|
---|
1008 |
|
---|
1009 | void DimClient::sendCommandNB(const char *name, short data)
|
---|
1010 | {
|
---|
1011 | DimCmnd a;
|
---|
1012 | a.sendNB((char *)name, &data, sizeof(short));
|
---|
1013 | }
|
---|
1014 |
|
---|
1015 | void DimClient::sendCommandNB(const char *name, char *data)
|
---|
1016 | {
|
---|
1017 | DimCmnd a;
|
---|
1018 | a.sendNB((char *)name, data, strlen(data)+1);
|
---|
1019 | }
|
---|
1020 |
|
---|
1021 | void DimClient::sendCommandNB(const char *name, void *data, int datasize)
|
---|
1022 | {
|
---|
1023 | DimCmnd a;
|
---|
1024 | a.sendNB((char *)name, data, datasize);
|
---|
1025 | }
|
---|
1026 |
|
---|
1027 | int DimClient::setExitHandler(const char *srvName)
|
---|
1028 | {
|
---|
1029 | DimCmnd a;
|
---|
1030 | int ret, tag = 1;
|
---|
1031 | char *name = new char[strlen(srvName) + 20];
|
---|
1032 | strcpy(name,(char *)srvName);
|
---|
1033 | strcat(name,"/SET_EXIT_HANDLER");
|
---|
1034 | ret = a.send(name, &tag, sizeof(int));
|
---|
1035 | delete[] name;
|
---|
1036 | return ret;
|
---|
1037 | }
|
---|
1038 |
|
---|
1039 | int DimClient::killServer(const char *srvName)
|
---|
1040 | {
|
---|
1041 | DimCmnd a;
|
---|
1042 | int ret, tag = 1;
|
---|
1043 | char *name = new char[strlen(srvName) + 20];
|
---|
1044 | strcpy(name,(char *)srvName);
|
---|
1045 | strcat(name,"/EXIT");
|
---|
1046 | ret = a.send(name, &tag, sizeof(int));
|
---|
1047 | delete[] name;
|
---|
1048 | return ret;
|
---|
1049 | }
|
---|
1050 |
|
---|
1051 | int DimClient::setDnsNode(const char *node)
|
---|
1052 | {
|
---|
1053 | dic_set_dns_node((char *)node);
|
---|
1054 | dic_close_dns();
|
---|
1055 | return 1;
|
---|
1056 | }
|
---|
1057 |
|
---|
1058 | int DimClient::setDnsNode(const char *node, int port)
|
---|
1059 | {
|
---|
1060 | dic_set_dns_port(port);
|
---|
1061 | dic_set_dns_node((char *)node);
|
---|
1062 | dic_close_dns();
|
---|
1063 | return 1;
|
---|
1064 | }
|
---|
1065 |
|
---|
1066 | char *DimClient::getDnsNode()
|
---|
1067 | {
|
---|
1068 | if(!dimDnsNode)
|
---|
1069 | dimDnsNode = new char[256];
|
---|
1070 | if(dic_get_dns_node(dimDnsNode))
|
---|
1071 | return dimDnsNode;
|
---|
1072 | else
|
---|
1073 | return 0;
|
---|
1074 | }
|
---|
1075 |
|
---|
1076 | int DimClient::getDnsPort()
|
---|
1077 | {
|
---|
1078 | return dic_get_dns_port();
|
---|
1079 | }
|
---|
1080 |
|
---|
1081 | void DimClient::setNoDataCopy()
|
---|
1082 | {
|
---|
1083 | dicNoCopy = 1;
|
---|
1084 | }
|
---|
1085 |
|
---|
1086 | int DimClient::getNoDataCopy()
|
---|
1087 | {
|
---|
1088 | return dicNoCopy;
|
---|
1089 | }
|
---|
1090 |
|
---|
1091 | extern "C" {
|
---|
1092 | //static void clt_error_user_routine(char*, int);
|
---|
1093 | static void clt_error_user_routine(int severity, int code, char *msg)
|
---|
1094 | {
|
---|
1095 |
|
---|
1096 | DimCore::inCallback = 2;
|
---|
1097 | DimClient::itsCltError->errorHandler(severity, code, msg);
|
---|
1098 | DimCore::inCallback = 0;
|
---|
1099 | }
|
---|
1100 | }
|
---|
1101 |
|
---|
1102 | void DimClient::addErrorHandler(DimErrorHandler *handler)
|
---|
1103 | {
|
---|
1104 | DimClient::itsCltError = handler;
|
---|
1105 | dic_add_error_handler(clt_error_user_routine);
|
---|
1106 | }
|
---|
1107 |
|
---|
1108 | void DimClient::addErrorHandler()
|
---|
1109 | {
|
---|
1110 | DimClient::itsCltError = this;
|
---|
1111 | dic_add_error_handler(clt_error_user_routine);
|
---|
1112 | }
|
---|
1113 |
|
---|
1114 | int DimClient::getServerId()
|
---|
1115 | {
|
---|
1116 | if(!serverName)
|
---|
1117 | serverName = new char[128];
|
---|
1118 | serverName[0] = '\0';
|
---|
1119 | return dic_get_server(serverName);
|
---|
1120 | }
|
---|
1121 |
|
---|
1122 | int DimClient::getServerPid()
|
---|
1123 | {
|
---|
1124 | int pid, ret;
|
---|
1125 |
|
---|
1126 | ret = dic_get_server_pid(&pid);
|
---|
1127 | if(!ret)
|
---|
1128 | return 0;
|
---|
1129 | return pid;
|
---|
1130 | }
|
---|
1131 |
|
---|
1132 | char *DimClient::getServerName()
|
---|
1133 | {
|
---|
1134 | if(!serverName)
|
---|
1135 | serverName = new char[128];
|
---|
1136 | serverName[0] = '\0';
|
---|
1137 | dic_get_server(serverName);
|
---|
1138 | return(serverName);
|
---|
1139 | }
|
---|
1140 |
|
---|
1141 | /*
|
---|
1142 | char *DimClient::getServerServices(int serverId)
|
---|
1143 | {
|
---|
1144 | return dic_get_server_services(serverId);
|
---|
1145 | }
|
---|
1146 |
|
---|
1147 | char *DimClient::getServerServices()
|
---|
1148 | {
|
---|
1149 | int id;
|
---|
1150 | if((id = dic_get_conn_id()))
|
---|
1151 | return dic_get_server_services(id);
|
---|
1152 | return (char *)0;
|
---|
1153 | }
|
---|
1154 | */
|
---|
1155 | char **DimClient::getServerServices()
|
---|
1156 | {
|
---|
1157 | static TokenString *data = 0;
|
---|
1158 | int id, len = 0, index = 0;
|
---|
1159 | char *services;
|
---|
1160 | static char** list = 0;
|
---|
1161 | char *sep;
|
---|
1162 |
|
---|
1163 | if(data)
|
---|
1164 | {
|
---|
1165 | delete data;
|
---|
1166 | data = 0;
|
---|
1167 | }
|
---|
1168 | if(list)
|
---|
1169 | {
|
---|
1170 | delete[] list;
|
---|
1171 | list = 0;
|
---|
1172 | }
|
---|
1173 | if((id = dic_get_conn_id()))
|
---|
1174 | {
|
---|
1175 | services = dic_get_server_services(id);
|
---|
1176 | if(services)
|
---|
1177 | {
|
---|
1178 | data = new TokenString(services,(char *)"\n");
|
---|
1179 | len = data->getNTokens();
|
---|
1180 | list = new char*[len];
|
---|
1181 | while(data->getToken(list[index]))
|
---|
1182 | {
|
---|
1183 | data->getToken(sep);
|
---|
1184 | index++;
|
---|
1185 | }
|
---|
1186 | }
|
---|
1187 | }
|
---|
1188 | if(!len)
|
---|
1189 | list = new char*[1];
|
---|
1190 | list[index] = 0;
|
---|
1191 | return list;
|
---|
1192 | }
|
---|