00001
00002
00003
00004 #include "reGlobalsExtern.h"
00005 #include "reHelpers1.h"
00006
00007 int
00008 getActionRecoveryList(char *ruleAction, char *ruleRecovery,
00009 char *actionArray[],char *recoveryArray[])
00010 {
00011 int i,j,k;
00012 char *t1, *t2, *t3, *t4;
00013 char action[MAX_ACTION_SIZE];
00014 char recovery[MAX_ACTION_SIZE];
00015
00016 i = 0;
00017 t1 = ruleAction;
00018 t3 = ruleRecovery;
00019 action[0] = '\0';
00020 recovery[0] = '\0';
00021 j = getNextAction(t1, action, &t2);
00022 k = getNextAction(t3, recovery, &t4);
00023 while(j == 0) {
00024
00025
00026
00027
00028 actionArray[i] = (char *) malloc(MAX_ACTION_SIZE);
00029 recoveryArray[i] = (char *) malloc(MAX_ACTION_SIZE);
00030 strcpy(actionArray[i],action);
00031 strcpy(recoveryArray[i],recovery);
00032
00033 i++;
00034 if (i == MAX_ACTION_IN_RULE)
00035 return (MAX_NUM_OF_ACTION_IN_RULE_EXCEEDED);
00036 t1 = t2;
00037 t3 = t4;
00038 action[0] = '\0';
00039 recovery[0] = '\0';
00040 j = getNextAction(t1, action, &t2);
00041 if (k == 0)
00042 k = getNextAction(t3, recovery, &t4);
00043 }
00044 return(i);
00045 }
00046
00047 int
00048 parseAction(char *inAction,char *action, char *args[], int *argc)
00049 {
00050 char *t, *s;
00051 int i = 0;
00052
00053 char *act;
00054 char *e, *t1;
00055
00056 int found = 0;
00057
00058 act = strdup(inAction);
00059 if ((t = strstr(act,"(")) != NULL) {
00060 *t = '\0';
00061 t++;
00062 s = t;
00063 e = t;
00064 strcpy(action,act);
00065 while (found == 0) {
00066 if (i == MAX_NUM_OF_ARGS_IN_ACTION)
00067 return(MAX_NUM_OF_ARGS_IN_ACTION_EXCEEDED);
00068 if ((t = strstr(s,",")) != NULL ) {
00069 *t = '\0';
00070 t1 = t + 1;
00071 if (goodExpr(e) == 0) {
00072 #if 0
00073 args[i] = e;
00074 trimWS(args[i]);
00075 trimQuotes(args[i]);
00076 #else
00077 trimWS(e);
00078 trimQuotes(e);
00079 args[i] = strdup (e);
00080 #endif
00081 i++;
00082 e=t1;
00083 s=t1;
00084 }
00085 else {
00086 *t = ',';
00087 s = t1+1;
00088 }
00089 }
00090 else {
00091 #if 0
00092 args[i] = e;
00093 args[i][strlen(args[i])-1] = '\0';
00094 #else
00095 e[strlen(e) - 1] = '\0';
00096 trimWS(e);
00097 trimQuotes(e);
00098 args[i] = strdup (e);
00099 #endif
00100 i++;
00101 found = 1;
00102 }
00103 }
00104 *argc = i;
00105
00106 free (act);
00107 return(0);
00108 }
00109 else {
00110 strcpy(action,act);
00111 *argc = 0;
00112
00113 free (act);
00114 return(0);
00115 }
00116 }
00117
00118 int
00119 getNextAction(char *listOfAction, char *action, char **restPtr)
00120 {
00121
00122
00123
00124 if (listOfAction== NULL || strlen(listOfAction) == 0) {
00125 return(-1);
00126 }
00127
00128 splitActions(listOfAction,action, restPtr);
00129 return(0);
00130 }
00131
00132 int
00133 splitActions(char *expr, char *expr1, char **expr2)
00134 {
00135
00136 int found;
00137 char *e, *t, *t1;
00138 found = 0;
00139 e = expr;
00140 while (found == 0) {
00141 if ((t = strstr(e,"##")) != NULL ) {
00142 *t = '\0';
00143 t1 = t + 2;
00144 if (goodExpr(expr) == 0) {
00145 rstrcpy(expr1,expr,MAX_ACTION_SIZE);
00146 *expr2 = t1;
00147 found = 1;
00148 }
00149 else {
00150 *t = '#';
00151 e = t1;
00152 }
00153 }
00154 else {
00155 rstrcpy(expr1,expr,MAX_ACTION_SIZE);
00156 *expr2 = NULL;
00157 found = 1;
00158 }
00159 }
00160 trimWS(expr1);
00161 return(0);
00162 }
00163