Magellan Linux

Diff of /mcore-src/trunk/mcore-tools/src/include/daemon.global.class.in

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2258 by niro, Mon Jan 13 14:25:18 2014 UTC revision 2269 by niro, Tue Jan 14 10:34:57 2014 UTC
# Line 54  stop_service() Line 54  stop_service()
54  # run_class $method $caller $argv1 $argv2 ... $argvN  # run_class $method $caller $argv1 $argv2 ... $argvN
55  run_class()  run_class()
56  {  {
57   local method="$1"   local method="${GLOBAL_ARGV[0]"
58   local caller="$2"   local caller="${GLOBAL_ARGV[1]"
59   local class   local class
60   local cmd   local cmd
61   local argv   local i
62     local count
63    
64   if valid_session   if valid_session
65   then   then
66   class="${caller%.*}"   class="${caller%.*}"
67   cmd="${caller#*.}"   cmd="${caller#*.}"
  argv="${@/${caller}/}" # remove caller  
  argv="${argv/${method}/}" # remove method  
68    
69  # echo "method=${method}"   # copy GLOBAL_ARGV to CLASS_ARGV array without method and caller.class
70  # echo "caller=${caller}"   unset CLASS_ARGV
71  # echo "class=${class}"   count="${#GLOBAL_ARGV[*]}"
72  # echo "cmd=${cmd}"   for (( i=2; i<count; i++ ))
73  # echo "argv=${argv}"   do
74     CLASS_ARGV[${i}-2]="${GLOBAL_ARGV[${i}]}"
75     done
76    
77    # decho "method=${method}"
78    # decho "caller=${caller}"
79    # decho "class=${class}"
80    # decho "cmd=${cmd}"
81    # decho "class argv=$(printf '\"%s\" ' ${CLASS_ARGV[*]}; printf '\n')"
82    
83   # check if class.cmd exist   # check if class.cmd exist
84   if [[ ! -z $(typeset -f "${method}"_"${class}"_"${cmd}") ]]   if [[ ! -z $(typeset -f "${method}"_"${class}"_"${cmd}") ]]
85   then   then
86   "${method}"_"${class}"_"${cmd}" ${argv}   "${method}"_"${class}"_"${cmd}"
87   else   else
88   eecho "unknown method '${method}' . class '${class}' . cmd '${cmd}'"   eecho "unknown method '${method}' . class '${class}' . cmd '${cmd}'"
89   fi   fi

Legend:
Removed from v.2258  
changed lines
  Added in v.2269