00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 #include <stdio.h>
00010 #include <stdlib.h>
00011 
00012 #include "actions.h"
00013 #include "est_ops.h"
00014 #include "global.h"
00015 #include "checksum.h"
00016 #include "options.h"
00017 #include "waa.h"
00018 
00019 
00027 int ac__dispatch(struct estat *sts)
00028 {
00029     int status;
00030 
00031     status=0;
00032     if (!action->local_callback) goto ex;
00033 
00034     
00035 
00036 #if 0
00037     BUG_ON(!(
00038                 S_ISDIR(sts->st.mode) || S_ISREG(sts->st.mode) || 
00039                 S_ISCHR(sts->st.mode) || S_ISBLK(sts->st.mode) || 
00040                 S_ISLNK(sts->st.mode) ),
00041             "%s has mode 0%o", sts->name, sts->st.mode);
00042 #endif
00043 
00044     if (ops__allowed_by_filter(sts) ||
00045             (sts->entry_status & FS_CHILD_CHANGED))
00046     {
00047         
00048 
00049 
00050 
00051 
00052         if (opt__get_int(OPT__ALL_REMOVED) ||
00053                 !sts->parent ||
00054                 (sts->parent->entry_status & FS_REPLACED)!=FS_REMOVED)
00055             STOPIF( action->local_callback(sts), NULL);
00056     }
00057     else 
00058         DEBUGP("%s is not the entry you're looking for", sts->name);
00059 
00060 ex:
00061     return status;
00062 }
00063 
00064 
00068 int act__find_action_by_name(const char *cmd, 
00069         struct actionlist_t **action_p)
00070 {
00071     int i, status;
00072     struct actionlist_t *action_v;
00073     int match_nr;
00074     char const* const* cp;
00075     size_t len;
00076 
00077 
00078     status=0;
00079     len=strlen(cmd);
00080     match_nr=0;
00081     action_v=action_list;
00082 
00083     for (i=action_list_count-1; i >=0; i--)
00084     {
00085         cp=action_list[i].name;
00086         while (*cp)
00087         {
00088             if (strncmp(*cp, cmd, len) == 0)
00089             {
00090                 action_v=action_list+i;
00091 
00092                 
00093 
00094                 if (len == strlen(*cp)) goto done;
00095 
00096                 match_nr++;
00097                 break;
00098             }
00099 
00100             cp++;
00101         }
00102     }
00103 
00104     STOPIF_CODE_ERR( match_nr <1, ENOENT,
00105             "!Action \"%s\" not found. Try \"help\".", cmd);
00106     STOPIF_CODE_ERR( match_nr >=2, EINVAL,
00107             "!Action \"%s\" is ambiguous. Try \"help\".", cmd);
00108 
00109 done:
00110     *action_p=action_v;
00111 
00112 ex:
00113     return status;
00114 }
00115