int process_psia_request(request *req) { int status; node_t *root = NULL; /* initialize the device interface */ status = iface_init(req); if(status != R_REQUEST_OK) return 1; /* set up the response buffer */ status = xadd_init(req); if(status != R_REQUEST_OK) return 1; /* set up the parser */ status = xml_init(req); if(status != R_REQUEST_OK) return 1; /* create the root node */ root = add_node(NULL, "/PSIA", M_NULL, NODE_SERVICE, NULL, NULL); desc_get_function(root, "Root service"); add_std_resources(root, &process_index, &process_indexr, &process_description, NULL); status = process_root(req, root); return 0; }
/********************************************************* Start here. **********************************************************/ int main(int argc, char **argv) { TALLOC_CTX *frame = talloc_stackframe(); int local_flags = 0; int ret; #if defined(HAVE_SET_AUTH_PARAMETERS) set_auth_parameters(argc, argv); #endif /* HAVE_SET_AUTH_PARAMETERS */ if (getuid() == 0) { local_flags = LOCAL_AM_ROOT; } smb_init_locale(); local_flags = process_options(argc, argv, local_flags); setup_logging("smbpasswd", DEBUG_STDERR); /* * Set the machine NETBIOS name if not already * set from the config file. */ if (!init_names()) return 1; /* Check the effective uid - make sure we are not setuid */ if (is_setuid_root()) { fprintf(stderr, "smbpasswd must *NOT* be setuid root.\n"); exit(1); } if (local_flags & LOCAL_AM_ROOT) { bool ok; ok = secrets_init(); if (!ok) { return 1; } ret = process_root(local_flags); } else { ret = process_nonroot(local_flags); } TALLOC_FREE(frame); return ret; }
/********************************************************* Start here. **********************************************************/ int main(int argc, char **argv) { int local_flags = 0; AllowDebugChange = False; #if defined(HAVE_SET_AUTH_PARAMETERS) set_auth_parameters(argc, argv); #endif /* HAVE_SET_AUTH_PARAMETERS */ if (getuid() == 0) { local_flags = LOCAL_AM_ROOT; } load_case_tables(); local_flags = process_options(argc, argv, local_flags); setup_logging("smbpasswd", True); /* * Set the machine NETBIOS name if not already * set from the config file. */ if (!init_names()) return 1; /* Check the effective uid - make sure we are not setuid */ if (is_setuid_root()) { fprintf(stderr, "smbpasswd must *NOT* be setuid root.\n"); exit(1); } if (local_flags & LOCAL_AM_ROOT) { secrets_init(); return process_root(local_flags); } return process_nonroot(local_flags); }
void func_fma_steering::dfs (void (*process_forest) (fma_forest *), void (*process_root) (fma_forest *, fma_root_node *), void (*process_node) (fma_forest *, fma_node *), bool free) { vec<fma_node *> to_process; std::list<fma_forest *>::iterator forest_iter; to_process.create (0); /* For each forest. */ for (forest_iter = this->m_fma_forests.begin (); forest_iter != this->m_fma_forests.end (); forest_iter++) { std::list<fma_root_node *>::iterator root_iter; if (process_forest) process_forest (*forest_iter); /* For each tree root in this forest. */ for (root_iter = (*forest_iter)->get_roots ()->begin (); root_iter != (*forest_iter)->get_roots ()->end (); root_iter++) { if (process_root) process_root (*forest_iter, *root_iter); to_process.safe_push (*root_iter); } /* For each tree node in this forest. */ while (!to_process.is_empty ()) { fma_node *node; std::list<fma_node *>::iterator child_iter; node = to_process.pop (); if (process_node) process_node (*forest_iter, node); /* Absence of children might indicate an alternate root of a *chain*. It's ok to skip it here as the chain will be renamed when processing the canonical root for that chain. */ if (node->get_children ()->empty ()) continue; for (child_iter = node->get_children ()->begin (); child_iter != node->get_children ()->end (); child_iter++) to_process.safe_push (*child_iter); if (free) { if (node->root_p ()) delete static_cast<fma_root_node *> (node); else delete node; } } if (free) delete *forest_iter; } to_process.release (); }
// generates code to implement node's action static void implement_node(ast_node node){ if (node != NULL){ if (node->node_type == ROOT){ process_root(node); } // generate code for assignment operator else if (node->node_type == OP_ASSIGN){ process_assign(node); } // generate code for negate operator else if (node->node_type == OP_NEG) { process_negate(node); } // generate code for +, -, *, /, %, =, !=, <, <=, >, >= else if (node->node_type > 0 && node->node_type <= 16 && node->node_type != 14 && node->node_type != 15){ process_math(node); } else if (node->node_type == OP_INC){ process_inc(node, "1"); } else if (node->node_type == OP_DEC){ process_inc(node, "-1"); } else if (node->node_type == IF_STMT){ process_if(node); } else if (node->node_type == IF_ELSE_STMT){ process_ifelse(node); } else if (node->node_type == CMPD){ process_cmpd(node); } else if (node->node_type == WHILE_STMT){ process_while(node); } else if (node->node_type == DO_WHILE_STMT){ process_dowhile(node); } else if (node->node_type == OP_AND){ process_and(node); } else if (node->node_type == OP_OR){ process_or(node); } else if (node->node_type == FOR_STRT || node->node_type == FOR_COND || node->node_type == FOR_UPDT){ process_for_header(node); } else if (node->node_type == FOR_STMT){ process_for(node); } else if (node->node_type == READ_STMT){ process_read(node); } else if (node->node_type == PRINT_STMT){ process_print(node); } else if (node->node_type == RETURN_STMT){ process_return(node); } else if (node->node_type == FUNCDEC){ process_function(node); } else if (node->node_type == PARAMS){ process_params(node); } else if (node->node_type == INT_TYPE || node->node_type == DOUBLE_TYPE){ process_vardec(node); } else if (node->node_type == CALL){ process_call(node); } else if (node->node_type == IDENT){ process_id(node); } else if (node->node_type == ARRAY){ process_array(node); } } }
int main(){ int ix,iy,radius,i,tries,nit; double zx,zy,zxn,zyn,cx,cy,theta, x,y,eps, poly[MAX_ROOTS+1]; _roots roots; _complex z,w,fz,dfz; root_init(&roots); // Number of iteration for each pointer. // The bigger, the less prone to error the program will be. nit=100; // The radius where the points will be looked for. radius=6; // Precision for the roots eps=1E-10; scanf("%d",&roots.grad); for(i=roots.grad;i>=0;i--){ scanf("%lf",&poly[i]); } printf("Coefficients:\n"); for(i=roots.grad;i>=0;i--){ printf(" a%d=%+.2f\n",i,poly[i]); } printf("\n f(0+0i)="); complex_print(f(complex_init(0,0),roots.grad, poly)); printf("df(0+0i)="); complex_print(df(complex_init(0,0),roots.grad, poly)); tries=0; do{ tries++; theta=drand48()*2*M_PI; x=radius*cos(theta); y=radius*sin(theta); z=complex_init(x,y); for(i=0;i<=nit;i++){ fz = f(z,roots.grad,poly); dfz=df(z,roots.grad,poly); if(complex_abs(dfz)<ee){ break; } w=z; z=complex_sub(z,complex_div(fz,dfz)); if(complex_abs(complex_sub(z,w))<=eps){ process_root(z,&roots,eps); break; } } }while(roots.nor<roots.grad); printf("\nTook %d tries to get all %d roots\n",tries,roots.grad); printf("\nZeroes and their images:\n\n"); for(i=0;i<roots.grad;i++){ printf("Root Z%d=%+lf %+lfi \tf(z%d)=",i+1,roots.root[i].x,roots.root[i].y,i+1); complex_print(f(roots.root[i],roots.grad, poly)); } return EXIT_SUCCESS; }
void func_fma_steering::dfs (void (*process_forest) (fma_forest *), void (*process_root) (fma_forest *, fma_root_node *), void (*process_node) (fma_forest *, fma_node *), bool free) { auto_vec<fma_node *> to_process; auto_vec<fma_node *> to_free; std::list<fma_forest *>::iterator forest_iter; /* For each forest. */ for (forest_iter = this->m_fma_forests.begin (); forest_iter != this->m_fma_forests.end (); ++forest_iter) { std::list<fma_root_node *>::iterator root_iter; if (process_forest) process_forest (*forest_iter); /* For each tree root in this forest. */ for (root_iter = (*forest_iter)->get_roots ()->begin (); root_iter != (*forest_iter)->get_roots ()->end (); ++root_iter) { if (process_root) process_root (*forest_iter, *root_iter); to_process.safe_push (*root_iter); } /* For each tree node in this forest. */ while (!to_process.is_empty ()) { fma_node *node; std::list<fma_node *>::iterator child_iter; node = to_process.pop (); if (process_node) process_node (*forest_iter, node); for (child_iter = node->get_children ()->begin (); child_iter != node->get_children ()->end (); ++child_iter) to_process.safe_push (*child_iter); /* Defer freeing so that the process_node callback can access the parent and children of the node being processed. */ if (free) to_free.safe_push (node); } if (free) { delete *forest_iter; while (!to_free.is_empty ()) { fma_node *node = to_free.pop (); if (node->root_p ()) delete static_cast<fma_root_node *> (node); else delete node; } } } }