source: trunk/FACT++/dim/src/util/dim_get_service.c@ 11069

Last change on this file since 11069 was 10614, checked in by tbretz, 13 years ago
New release V19 r20
File size: 1.8 KB
Line 
1#include <ctype.h>
2#include <stdio.h>
3#include <dic.h>
4
5int no_link = 0x0afefead;
6int version;
7
8char str[132];
9int type, mode;
10int received = 0;
11
12void rout(tag, buffer, size)
13int *tag, *size;
14int *buffer;
15{
16void print_service();
17
18 if(tag){}
19 if((*size == 4 ) && (*buffer == no_link))
20 {
21 printf("Service %s Not Available\n", str);
22 }
23 else
24 {
25 printf("Service %s Contents :\n", str);
26 print_service(buffer, ((*size - 1)/4) + 1);
27 }
28 fflush(stdout);
29 received = 1;
30#ifdef WIN32
31 wake_up();
32#endif
33}
34
35int main(argc,argv)
36int argc;
37char **argv;
38{
39
40 if(argc < 2)
41 {
42 printf("Service Name > ");
43 fflush(stdout);
44 scanf("%s", str);
45 }
46 else
47 {
48 sprintf(str,argv[1]);
49 }
50 dic_info_service(str,ONCE_ONLY,60,0,0,rout,0,&no_link,4);
51 while(!received)
52 dim_wait();
53 return(1);
54}
55
56void print_service(buff, size)
57int *buff, size;
58{
59int i,j;
60char *asc;
61int last[4];
62
63 asc = (char *)buff;
64 for( i = 0; i < size; i++)
65 {
66 if(!(i%4))
67 printf("H");
68 printf(" %08X ",buff[i]);
69 last[i%4] = buff[i];
70 if(i%4 == 3)
71 {
72 printf(" '");
73 for(j = 0; j <16; j++)
74 {
75 if(isprint(asc[j]))
76 printf("%c",asc[j]);
77 else
78 printf(".");
79 }
80 printf("'\n");
81 for(j = 0; j <4; j++)
82 {
83 if(j == 0)
84 printf("D");
85 printf("%11d ",last[j]);
86 }
87 printf("\n");
88 asc = (char *)&buff[i+1];
89 }
90 }
91 if(i%4)
92 {
93
94 for(j = 0; j < 4 - (i%4); j++)
95 printf(" ");
96 printf(" '");
97 for(j = 0; j < (i%4) * 4; j++)
98 {
99 if(isprint(asc[j]))
100 printf("%c",asc[j]);
101 else
102 printf(".");
103 }
104 printf("'\n");
105 for(j = 0; j < (i%4); j++)
106 {
107 if(j == 0)
108 printf("D");
109 printf("%11d ",last[j]);
110 }
111 printf("\n");
112 }
113}
Note: See TracBrowser for help on using the repository browser.