b5931b983d6ffb37792773a61dadcce9b3487fd4
[curl-de-sac.git] / webtest / cds_test01.php
1 require_once('Obj/curl-de-sac.phh');
2
3 class short_cmd_cls extends CDS_cmd_cls {
4     function short_cmd_cls() 
5     {
6         parent::__construct("short", 10);
7     }
8
9     function cb()
10     {
11         printf("short_cb:\n");
12     }
13 }
14
15 class long_cmd_cls extends CDS_cmd_cls {
16     function long_cmd_cls() 
17     {
18         parent::__construct("long", 15);
19     }
20
21     function cb()
22     {
23         printf("long_cb:\n");
24     }
25 }
26
27 function main()
28 {
29     // create cds
30     $cds = new Curl_de_sac();
31
32     // create cds_cmd 1
33     $cmd_cls1 = new short_cmd_cls();
34
35     // registrer cds_cmd 1
36     if (($cds->cmd_register($cmd_cls1)) == FALSE) {
37         fprintf(STDERR, "cmd_cls1 registration failed\n");
38         exit(1);
39     }
40
41     // create cds_cmd 2
42     $cmd_cls2 = new long_cmd_cls();
43
44     // register cds_cmd 2
45     if (($cds->cmd_register($cmd_cls2)) == FALSE) {
46         fprintf(STDERR, "cmd_cls2 registration failed\n");
47         exit(2);
48     }
49
50     // register cds_cmd 2 (retry)
51     if (($cds->cmd_register($cmd_cls2)) != FALSE) {
52         fprintf(STDERR, "cmd_cls2 re-registration success\n");
53         exit(3);
54     }
55
56     // start loop
57     //   print status
58     //   if input data execute some command
59     //   if end => clean exit
60     exit(0);
61 }
62
63 main();
64
65 ?>