source: trunk/FACT++/dim/src/util/dim_send_command.c@ 13778

Last change on this file since 13778 was 11071, checked in by tbretz, 13 years ago
Replaced v19r21 by a version extracted with 'unzip -a' to get proper unix text format.
File size: 1.9 KB
Line 
1#include <ctype.h>
2#include <stdio.h>
3#include <string.h>
4#include <stdlib.h>
5#include <dic.h>
6
7int received = 0;
8char str[132] = {'\0'};
9
10void rout(tag, code)
11int *tag;
12int *code;
13{
14 int silent;
15
16 silent = *tag;
17 if(!silent)
18 dim_print_date_time();
19 if(*code)
20 {
21 if(!silent)
22 printf(" Command %s Successfully Sent\n", str);
23 }
24 else
25 {
26 if(!silent)
27 printf(" Command %s Unsuccessfull\n", str);
28 }
29 received = 1;
30#ifdef WIN32
31 wake_up();
32#endif
33}
34/*
35main(argc,argv)
36int argc;
37char **argv;
38{
39 char data[1024] = {'\0'};
40 int silent = 0;
41
42 if(argc < 2)
43 {
44 printf("Command Name > ");
45 fflush(stdout);
46 scanf("%s", str);
47 printf("Command String > ");
48 fflush(stdout);
49 scanf("%s", data);
50 }
51 else
52 {
53 sprintf(str,argv[1]);
54 if(argc < 3)
55 data[0] = '\0';
56 else
57 {
58 sprintf(data,argv[2]);
59 if(argc > 3)
60 silent = 1;
61 }
62 }
63 dic_cmnd_callback(str,data,strlen(data)+1, rout, silent);
64 while(!received)
65 dim_wait();
66 sleep(1);
67}
68*/
69int main(argc,argv)
70int argc;
71char **argv;
72{
73int i;
74int silent = 0;
75char data[1024] = {'\0'};
76char dns_node[128], *ptr;
77int dns_port = 0;
78
79 dns_node[0] = '\0';
80 for(i = 1; i < argc; i++)
81 {
82 if(!strcmp(argv[i],"-dns"))
83 {
84 strcpy(dns_node,argv[i+1]);
85 if((ptr = strchr(dns_node,':')))
86 {
87 *ptr = '\0';
88 ptr++;
89 sscanf(ptr,"%d",&dns_port);
90 }
91 i++;
92 }
93 else if(!strcmp(argv[i],"-s"))
94 {
95 silent = 1;
96 }
97 else
98 {
99 if(!str[0])
100 {
101 strcpy(str, argv[i]);
102 }
103 else if(!data[0])
104 strcpy(data,argv[i]);
105 }
106 }
107 if(dns_node[0])
108 {
109 dic_set_dns_node(dns_node);
110 }
111 if(dns_port)
112 {
113 dic_set_dns_port(dns_port);
114 }
115 if(!str[0])
116 {
117 printf("dim_send_command: Insufficient parameters\n");
118 printf("usage: dim_send_command <cmnd_name> [<data>] [-dns <dns_node>] [-s]\n");
119 exit(0);
120 }
121 if(!data[0])
122 data[0] = '\0';
123 dic_cmnd_callback(str,data,strlen(data)+1, rout, silent);
124 while(!received)
125 dim_wait();
126 sleep(1);
127 return(1);
128}
Note: See TracBrowser for help on using the repository browser.