+
+ function cmd_deregister($cmd_cls)
+ {
+ if (get_class($cmd_cls) != 'CDS_cmd_cls' && is_subclass_of($cmd_cls, 'CDS_cmd_cls') == FALSE)
+ return FALSE;
+ if (!isset($this->cmd_cls[$cmd_cls->name]))
+ return FALSE;
+
+ unset($this->cmd_cls[$cmd_cls->name]);
+ return TRUE;
+ }
+
+ function cmd_deregister_all()
+ {
+ $this->cmd_cls = array();
+ }
+
+ function execute()
+ {
+ $args = func_get_args();
+
+ if ($this->dbg > 1) {
+ printf("CDS_cmd_cls::execute ARGS:\n");
+ print_r($args);
+ }
+ do {
+ if (($name = array_shift($args)) === NULL)
+ break;
+ array_unshift($args, $this);
+
+ if (!isset($this->cmd_cls[$name]))
+ break;
+
+ $cmd_cls = $this->cmd_cls[$name];
+
+ if (($inst = call_user_func_array(array($cmd_cls, "create"), $args)) == FALSE)
+ break;
+
+ array_push($this->cmd, $inst);
+ if ($this->dbg > 1) {
+ printf("CDS_cmd_cls::process - execute push cmd\n");
+ print_r($this->cmd);
+ }
+ return TRUE;
+ } while (FALSE);
+
+ return FALSE;
+ }
+
+ function process()
+ {
+ if ($this->dbg > 1) {
+ printf("CDS_cmd_cls::process - begin\n");
+ }
+ $running = NULL;
+ $ret = curl_multi_exec($this->mh, $running);
+ $msgs_in_queue = NULL;
+
+ do {
+ if ($ret = curl_multi_info_read ($this->mh, $msgs_in_queue)) {
+ if ($this->dbg > 1)
+ printf("Info_read miq: %d\n", $msgs_in_queue);
+
+ foreach($this->cmd as $cmd) {
+ if ($cmd->ch == $ret['handle']) {
+ $cmd->cmd_cls->cb($cmd, $ret);
+ break;
+ }
+ }
+ $info = curl_getinfo($ret['handle']);
+ if ($this->dbg > 1) {
+ printf("Getinfo:\n");
+ print_r($info);
+ }
+ }
+ } while ($msgs_in_queue > 0);
+ if ($this->dbg > 1) {
+ printf("CDS_cmd_cls::process - end (queue: %d)\n", $msgs_in_queue);
+ }
+ }
+