static int read_rule(xmlNode *rn, cp_rule_t **dst, cp_read_actions_func read_actions, cp_free_actions_func free_actions) { xmlNode *n; int res = RES_OK; if ((!rn) || (!dst)) return RES_INTERNAL_ERR; *dst = (cp_rule_t*)cds_malloc(sizeof(cp_rule_t)); if (!*dst) return RES_MEMORY_ERR; memset(*dst, 0, sizeof(cp_rule_t)); get_str_attr(rn, "id", &(*dst)->id); n = find_node(rn, "actions", common_policy_ns); if (n && (res == 0) && read_actions) res = read_actions(n, &(*dst)->actions); n = find_node(rn, "conditions", common_policy_ns); if (n && (res == 0)) res = read_conditions(n, &(*dst)->conditions); n = find_node(rn, "transformations", common_policy_ns); if (n && (res == 0)) res = read_transformations(n, &(*dst)->transformations); if (res != 0) { free_cp_rule(*dst, free_actions); *dst = NULL; return res; } return 0; }
int main(int argc, char **argv) { int int_max_alfa,step; int pipe_disp[2], pid; FILE *output; printf("%s",triangle_4); getopt_dec(argc, argv); if ((input = fopen(filein, "r")) == NULL) fatal("\n Can't open input file"); unpack(-2,input); /*Initialize unpack */ N_BITALFA = (int)unpack(4,input); N_BITBETA = (int)unpack(4,input); min_size = (int)unpack(7,input); max_size = (int)unpack(7,input); SHIFT = (int)unpack(6,input); image_width = (int)unpack(12,input); image_height = (int)unpack(12,input); int_max_alfa = (int)unpack(8,input); bits_per_coordinate_w = ceil(log(image_width / SHIFT ) / log(2.0)); bits_per_coordinate_h = ceil(log(image_height / SHIFT ) / log(2.0)); zeroalfa = 0; MAX_ALFA = (double) int_max_alfa / (double)(1 << 8) * ( 8.0) ; max = image_height; min = image_width; if(image_width > image_height ) { min = image_height; max = image_width; } virtual_size = 1 << (int) ceil(log((double) max) / log(2.0)); trans = &fractal_code; printf("\n Reading %s ... ",filein); fflush(stdout); read_transformations(0,0,virtual_size); printf("done\n"); fflush(stdout); printf(" Original image size: %dx%d\n",image_width,image_height); image_width = (int) rint((zoom * image_width)); image_height = (int) rint((zoom * image_height)); if(zoom != 1.0) { printf(" Zooming image to : %dx%d\n",image_width,image_height); fflush(stdout); } matrix_allocate(image,2+image_width,2+image_height,PIXEL) matrix_allocate(image1,2+image_width,2+image_height,PIXEL) if(piramidal) { min *= zoom; step = SHIFT * floor(zoom); if(step == 0) step = 1; lev = 0; while(1){ if(min < 200 || (step & 1)) break; min >>= 1; step >>= 1; lev++; } printf("\n %d level piramid\n",lev); iterative_decoding(lev,iterations,zoom); /* Decode at low resolution */ piramidal_decoding(lev); /* Increase resolution */ if(quality) iterative_decoding(0,2,1.0); } else