void generator::orbit_element_rank(INT depth, INT &orbit_idx, INT &rank, INT *set, INT f_implicit_fusion, INT verbose_level) { INT f_v = (verbose_level >= 1); INT f_vv = (verbose_level >= 2); INT *Elt1; INT *the_set; INT *canonical_set; INT i; if (f_v) { cout << "generator::orbit_element_rank depth=" << depth << " "; INT_vec_print(cout, set, depth); cout << endl; } Elt1 = NEW_INT(A->elt_size_in_INT); the_set = NEW_INT(depth); canonical_set = NEW_INT(depth); for (i = 0; i < depth; i++) { the_set[i] = set[i]; } orbit_idx = trace_set(the_set, depth, depth, canonical_set, Elt1, f_implicit_fusion, verbose_level - 3); // now Elt1 is the transporter element that moves // the given set to the orbit representative if (f_vv) { cout << "generator::orbit_element_rank after trace_set, orbit_idx = " << orbit_idx << endl; cout << "transporter:" << endl; A->element_print_quick(Elt1, cout); cout << "as permutation:" << endl; A2->element_print_as_permutation(Elt1, cout); } if (f_v) { cout << "calling coset_rank" << endl; } rank = coset_rank(depth, orbit_idx, Elt1, verbose_level); if (f_v) { cout << "after coset_rank, rank=" << rank << endl; } FREE_INT(Elt1); FREE_INT(the_set); FREE_INT(canonical_set); if (f_v) { cout << "generator::orbit_element_rank orbit_idx=" << orbit_idx << " rank=" << rank << endl; } }
int main(int argc, char *argv[]) { extern char *optarg; extern int optind; int opt; char hostname[MAXHOSTNAMELEN]; IPAddress ip_address; IPAddress my_ip_addr; Oid *enterprise; int generic, specific, level; SNMP_variable *variables; struct hostent *hp; int trap_port = -1; u_long time_stamp = (u_long)-1; int enterprise_flag= 0, a_flag = 0, i_flag = 0; optind = 1; /* the default host name is local host */ gethostname(hostname, sizeof(hostname)); /* default Oid for enterprise is sun */ enterprise = &sun_oid; /* generic, specific */ generic = 6; specific = 1; { char domain_path[MAXPATHLEN]; setlocale(LC_ALL, ""); sprintf(domain_path, SEA_LOCALE_PATH); bindtextdomain(DOMAIN_MGET, domain_path); bindtextdomain(DOMAIN_SGET, domain_path); bindtextdomain(DOMAIN_LIBGET, domain_path); bindtextdomain(DOMAIN_LGET, domain_path); bindtextdomain(DOMAIN_FGET, domain_path); /* formatting string */ } /* get command-line options */ while ((opt = getopt(argc, argv, "h:c:e:E:g:s:i:t:a:T:p:")) != EOF) { switch (opt) { case 'T': level = atoi(optarg); if(trace_set(level, error_label)){ fprintf(stderr, " %d is not a valid trace level!\n", level); usage(); } break; case 'h': /* host to send trap to */ if (strlcpy(hostname, optarg, sizeof (hostname)) > MAXHOSTNAMELEN) { fprintf(stderr, "%s: hostname too long!\ \n", optarg); exit(1); } case 'c': trap_community = optarg; break; case 'e': if (enterprise_flag) { usage(); } enterprise = SSAOidStrToOid(optarg,error_label); if (!enterprise){ /* error */ fprintf(stderr, "%s: not a valid enterprise oid string!\n", optarg); usage(); } enterprise_flag = 1; break; case 'E': if (enterprise_flag) { usage(); } enterprise = get_oid(optarg); if (!enterprise) { usage(); } enterprise_flag = 1; break; case 'g': /* generic trap type */ if (is_number(optarg)) usage(); generic = atoi(optarg); if ((generic > 6 ) || (generic < 0)) usage(); break; case 's': /* specific trap type */ if (is_number(optarg)) usage(); specific = atoi(optarg); break; case 'i': if (name_to_ip_address(optarg, &my_ip_addr, error_label)) { usage(); } i_flag = 1; break; case 't': /* timestamp */ time_stamp = atol(optarg); break; case 'p': if (is_number(optarg)) usage(); trap_port = atoi(optarg); break; case 'a': /* attribute information */ if ((variables = get_variable(optarg))== NULL){ fprintf(stderr, "%s: not a valid variable!\n", optarg); usage(); } a_flag = 1; break; case '?': /* usage help */ usage(); break; default: usage(); break; } /* switch */ }/* while */
void generator::trace_all_k_subsets(INT *the_set, INT n, INT k, INT &nCk, INT *&isotype, INT verbose_level) { INT f_v = (verbose_level >= 1); INT f_vv = (verbose_level >= 2); INT *index_set; INT *subset; INT *canonical_subset; INT *Elt; INT subset_rk, local_idx, i; INT f_implicit_fusion = TRUE; nCk = INT_n_choose_k(n, k); if (f_v) { cout << "generator::trace_all_k_subsets n = " << n << " k = " << k << " nCk = " << nCk << endl; } Elt = NEW_INT(A->elt_size_in_INT); index_set = NEW_INT(k); subset = NEW_INT(k); canonical_subset = NEW_INT(k); isotype = NEW_INT(nCk); INT_vec_zero(isotype, nCk); first_k_subset(index_set, n, k); subset_rk = 0; while (TRUE) { if (f_vv && ((subset_rk % 100) == 0)) { cout << "generator::trace_all_k_subsets k=" << k << " testing set " << subset_rk << " / " << nCk << " = " << 100. * (double) subset_rk / (double) nCk << " % : "; INT_vec_print(cout, index_set, k); cout << endl; } for (i = 0; i < k; i++) { subset[i] = the_set[index_set[i]]; } INT_vec_copy(subset, set[0], k); if (FALSE /*f_v2*/) { cout << "generator::trace_all_k_subsets corresponding to set "; INT_vec_print(cout, subset, k); cout << endl; } A->element_one(transporter->ith(0), 0); if (k == 0) { isotype[0] = 0; } else { if (FALSE) { cout << "generator::trace_all_k_subsets before trace_set" << endl; } local_idx = trace_set(subset, k, k, canonical_subset, Elt, f_implicit_fusion, 0 /*verbose_level - 3*/); if (FALSE) { cout << "generator::trace_all_k_subsets after trace_set, local_idx = " << local_idx << endl; } if (FALSE /*f_vvv*/) { cout << "generator::trace_all_k_subsets local_idx=" << local_idx << endl; } isotype[subset_rk] = local_idx; if (FALSE) { cout << "generator::trace_all_k_subsets the transporter is" << endl; A->element_print(Elt, cout); cout << endl; } } subset_rk++; if (!next_k_subset(index_set, n, k)) { break; } } if (subset_rk != nCk) { cout << "generator::trace_all_k_subsets subset_rk != nCk" << endl; exit(1); } FREE_INT(index_set); FREE_INT(subset); FREE_INT(canonical_subset); FREE_INT(Elt); if (f_v) { cout << "generator::trace_all_k_subsets done" << endl; } }
void generator::map_to_canonical_k_subset(INT *the_set, INT set_size, INT subset_size, INT subset_rk, INT *reduced_set, INT *transporter, INT &local_idx, INT verbose_level) // fills reduced_set[set_size - subset_size], transporter and local_idx // local_idx is the index of the orbit that the subset belongs to // (in the list of orbit of subsets of size subset_size) { INT f_v = (verbose_level >= 1); INT f_vv = (verbose_level >= 2); if (f_v) { cout << "generator::map_to_canonical_k_subset" << endl; } INT *our_set; INT *subset; INT *canonical_subset; INT *Elt1; INT f, i, j, k, idx; INT reduced_set_size; INT f_implicit_fusion = TRUE; our_set = NEW_INT(set_size); subset = NEW_INT(set_size); canonical_subset = NEW_INT(set_size); Elt1 = NEW_INT(A->elt_size_in_INT); reduced_set_size = set_size - subset_size; // unrank the k-subset and its complement to our_set[set_size]: unrank_k_subset(subset_rk, our_set, set_size, subset_size); j = 0; k = 0; for (i = 0; i < set_size; i++) { if (j < subset_size && our_set[j] == i) { j++; continue; } our_set[subset_size + k] = i; k++; } for (i = 0; i < set_size; i++) { subset[i] = the_set[our_set[i]]; set[0][i] = subset[i]; } A->element_one(generator::transporter->ith(0), FALSE); // trace the subset: f = first_oracle_node_at_level[subset_size]; if (f_vv) { cout << "generator::map_to_canonical_k_subset before trace_set" << endl; } local_idx = trace_set(subset, set_size, subset_size, canonical_subset, Elt1, f_implicit_fusion, verbose_level - 3); idx = local_idx + f; if (f_vv) { cout << "generator::map_to_canonical_k_subset after trace_set local_idx=" << local_idx << endl; } if (FALSE) { cout << "the transporter is" << endl; A->element_print(Elt1, cout); cout << endl; } A->element_move(Elt1, transporter, FALSE); for (i = 0; i < reduced_set_size; i++) { reduced_set[i] = canonical_subset[subset_size + i]; } if (FALSE) { cout << "generator::map_to_canonical_k_subset reduced set = "; INT_vec_print(cout, reduced_set, reduced_set_size); cout << endl; } FREE_INT(Elt1); FREE_INT(our_set); FREE_INT(subset); FREE_INT(canonical_subset); if (f_v) { cout << "generator::map_to_canonical_k_subset done" << endl; } }
int main(int argc, char *argv[]) { int arg; int Fails ; char *str; int level; char *error_file = NULL; extern char *optarg; extern int optind; int opt; error_init(argv[0], application_end); optind = 1; { char domain_path[MAXPATHLEN]; setlocale(LC_ALL, ""); sprintf(domain_path, SEA_LOCALE_PATH); bindtextdomain(DOMAIN_MGET, domain_path); bindtextdomain(DOMAIN_SGET, domain_path); bindtextdomain(DOMAIN_LIBGET, domain_path); bindtextdomain(DOMAIN_LGET, domain_path); bindtextdomain(DOMAIN_FGET, domain_path); /* formatting string */ } /* parse arguments */ while((opt = getopt(argc,argv,"c:i:hr:m:o:p:a:d:yf:n:?"))!=EOF){ switch(opt){ case 'h': case '?': print_usage(); break; case 'f': Fails = strtol (optarg, &str, 10) ; if (optarg == str) { fprintf (stderr, "Invalid number following the -t option: %s\n", optarg ) ; print_usage () ; } else { SetFailThreshold (Fails) ; } break ; case 'y': recovery_on=TRUE; break; case 'p': port = strtol(optarg, &str, 10); if(optarg == str) { fprintf(stderr, "Not a valid integer following the -p option: %s\n", optarg); print_usage(); } break; case 'n': relay_agent_name = strdup(optarg); if(relay_agent_name == NULL) { fprintf(stderr, "%s\n", ERR_MSG_ALLOC); exit(1); } break; case 'o': if(optind > argc) { fprintf(stderr, "must have the enterprise name-oid file\n"); print_usage(); } name_oid_file= strdup(optarg); if(name_oid_file == NULL) { fprintf(stderr, "%s\n", ERR_MSG_ALLOC); exit(1); } break; case 'c': if(optind > argc) { fprintf(stderr, "Must have a configuration directory name following the -c option\n"); print_usage(); } config_dir = strdup(optarg); if(config_dir == NULL) { fprintf(stderr, "%s\n", ERR_MSG_ALLOC); exit(1); } break; case 'a': if(optind > argc) { fprintf(stderr, "Must have a access control filename following the -a option\n"); print_usage(); } sec_config_file = strdup(optarg); if(sec_config_file == NULL) { fprintf(stderr, "%s\n", ERR_MSG_ALLOC); exit(1); } break; case 'r': if(optind > argc) { fprintf(stderr, "Must have a resource file name following the -r option\n"); print_usage(); } resource_file = strdup(optarg); if(resource_file == NULL) { fprintf(stderr, "%s\n", ERR_MSG_ALLOC); exit(1); } break; case 'i': if(optind > argc) { fprintf(stderr, "Must have a pid file name following the -i option\n"); print_usage(); } pid_file = strdup(optarg); if(pid_file == NULL) { fprintf(stderr, "%s\n", ERR_MSG_ALLOC); exit(1); } break; case 'd': if(optind> argc) { fprintf(stderr, "Must have a trace-level following the -d option\n"); print_usage(); } level = strtol(optarg, &str, 10); if(optarg == str) { fprintf(stderr, "Not a valid integer following the -d option: %s\n", optarg); print_usage(); } if(trace_set(level, error_label)) { print_usage(); } break; case 'm': if(optind > argc) { fprintf(stderr, "Must have GROUP or SPLIT following the -m option\n"); print_usage(); } if(strcmp(optarg, "GROUP") == 0) { mode = MODE_GROUP; } else if(strcmp(optarg, "SPLIT") == 0) { mode = MODE_SPLIT; } else { fprintf(stderr, "Invalid mode: %s\n", optarg); print_usage(); } break; default: fprintf(stderr, "Invalid Option: -%c\n", optarg); print_usage(); break; } } /* if(error_file == NULL) { error_file = default_error_file; } error_open(error_file); */ if(trace_level == 0) { /* run the daemon in backgound */ int pid; pid = fork(); switch(pid) { case -1: error_exit(ERR_MSG_FORK, errno_string()); break; case 0: /* child process */ break; default: /* parent process */ exit(0); break; } } if(fclose(stdin) == EOF) { error(ERR_MSG_FCLOSE, "stdin", errno_string()); } dispatcher_init(); if(signals_init(signals_sighup, signals_exit, error_label)) { error_exit("signals_init() failed: %s", error_label); } if(trace_level == 0) { if(fclose(stdout) == EOF) { error(ERR_MSG_FCLOSE, "stdout", errno_string()); } } if(trace_level == 0) { /* background */ if(chdir("/") == -1) { error(ERR_MSG_CHDIR, "/", errno_string()); } /* set process group ID */ setpgrp(); error_close_stderr(); } dispatcher_loop(); return (0); }