static int do_print( FILE *ff, const tdop_type &tdop, const operator_type op ) throw() { if(op.is_category()) { category_type cat; unsigned lower_bound(0); if(op.match(cat, lower_bound)) { int num(do_print(ff, tdop, cat)); num += fprintf(ff, "(%u)", lower_bound); return num; } else if(op.match(cat)) { return do_print(ff, tdop, cat); } else { assert(false); } } else if(op.is_symbol()) { int num(0); if(op.is_symbol_predicate()) { num += fprintf(ff, "&"); } symbol_type sym; op.match(sym); return num + do_print(ff, tdop, sym); } return 0; }
static void do_log( void *_c, const char *msg, bool user_log ) { mcontext *c = (mcontext*)_c; if( user_log ) { c->r->content_type = "text/plain"; do_print(c,"Error : ",8); do_print(c,msg,(int)strlen(msg)); } else ap_log_rerror(__FILE__, __LINE__, APLOG_WARNING, LOG_SUCCESS c->r, "[mod_tora] %s", msg); }
/** * @brief checks the entry using subfunctions based on params, if passed, prints it * * @param path the path to be processed * @param params the parsed parameters * @param attr the entry attributes from lstat * * @returns EXIT_SUCCESS, EXIT_FAILURE */ int do_file(char *path, params_t *params, struct stat attr) { int printed = 0; do { /* ### FB: Mit ENUM Feld könnte hier ein switch genutzt werden und für mehr Übersicht sorgen. */ /* filtering */ if (params->type) { if (do_type(params->type, attr) != EXIT_SUCCESS) { return EXIT_SUCCESS; /* the entry didn't pass the check, do not print it */ } } if (params->nouser) { if (do_nouser(attr) != EXIT_SUCCESS) { return EXIT_SUCCESS; } } if (params->user) { if (do_user(params->userid, attr) != EXIT_SUCCESS) { return EXIT_SUCCESS; } } if (params->name) { if (do_name(path, params->name) != EXIT_SUCCESS) { return EXIT_SUCCESS; } } if (params->path) { if (do_path(path, params->path) != EXIT_SUCCESS) { return EXIT_SUCCESS; } } /* printing */ if (params->print) { if (do_print(path) != EXIT_SUCCESS) { return EXIT_FAILURE; /* a fatal error occurred */ } printed = 1; } if (params->ls) { if (do_ls(path, attr) != EXIT_SUCCESS) { return EXIT_FAILURE; } printed = 1; } params = params->next; } while (params); if (printed == 0) { if (do_print(path) != EXIT_SUCCESS) { return EXIT_FAILURE; } } return EXIT_SUCCESS; }
/** * @brief checks the entry using subfunctions based on params, if passed, prints it * * @param path the path to be processed * @param params the parsed parameters * @param attr the entry attributes from lstat * * @returns EXIT_SUCCESS, EXIT_FAILURE */ int do_file(char *path, params_t *params, struct stat attr) { int printed = 0; do { /* filtering */ if (params->type) { if (do_type(params->type, attr) != EXIT_SUCCESS) { return EXIT_SUCCESS; /* the entry didn't pass the check, do not print it */ } } if (params->nouser) { if (do_nouser(attr) != EXIT_SUCCESS) { return EXIT_SUCCESS; } } if (params->user) { if (do_user(params->userid, attr) != EXIT_SUCCESS) { return EXIT_SUCCESS; } } if (params->name) { if (do_name(path, params->name) != EXIT_SUCCESS) { return EXIT_SUCCESS; } } if (params->path) { if (do_path(path, params->path) != EXIT_SUCCESS) { return EXIT_SUCCESS; } } /* printing */ if (params->print) { if (do_print(path) != EXIT_SUCCESS) { return EXIT_FAILURE; /* a fatal error occurred */ } printed = 1; } if (params->ls) { if (do_ls(path, attr) != EXIT_SUCCESS) { return EXIT_FAILURE; } printed = 1; } params = params->next; } while (params); if (printed == 0) { if (do_print(path) != EXIT_SUCCESS) { return EXIT_FAILURE; } } return EXIT_SUCCESS; }
void do_print( node_type * r, std::ostream & os, const size_t level) const { if(r == NULL) { return; } do_print(r->left(), os, level + 1); for(size_t i=0; i < level; ++i) os << " "; os << r->value() << " (level=" << level << ")" << std::endl; do_print(r->right(), os, level + 1); }
int do_print(char *name, char *size) { if (debug) printf("%s\n", __func__); printf("\nDirectory: %s\n", dirPtr->dirName); //print out files???????????????????????????????????????? for(int i = 0; i < dirPtr->files.size(); i++) printf("%s\n", dirPtr->files[i].fileName); //if there are no subdirectories if(dirPtr->firstSub == NULL) return 0; //if there is only one subdirectory if(dirPtr->firstSub->nextSub == NULL) { printf("%s\n", dirPtr->firstSub->dirName); } else { dirPtr = dirPtr->firstSub; printf("%s\n", dirPtr->dirName); while(dirPtr->nextSub != NULL) { dirPtr = dirPtr->nextSub; printf("%s\n", dirPtr->dirName); } //change back to previous directory dirPtr = dirPtr->prevDir; } //at this point, the files in the directory are printed //now print the subdirectories, if any //recurse over first subdirectory dirPtr = dirPtr->firstSub; do_print("dummy", 0); //recurse over the rest of the subdirectories while(dirPtr->nextSub != NULL) { dirPtr = dirPtr->nextSub; do_print("dummy", 0); } //change back to previous directory dirPtr = dirPtr->prevDir; return 0; }
static int do_print( FILE *ff, const tdop_type &tdop, const term_type term ) throw() { category_type cat; symbol_type sym; if(term.match(cat)) { return do_print(ff, tdop, cat); } else if(term.match(sym)) { return do_print(ff, tdop, sym); } else { return 0; } }
void process_line(longint_t vars[], char *line) { int varnum, optype, status; longint_t second_value; /* determine the LHS variable, it * must be first character in line */ varnum = to_varnum(line[0]); if (varnum==ERROR) { printf("Invalid LHS variable\n"); return; } /* more testing for validity */ if (strlen(line)<2) { printf("No operator supplied\n"); return; } /* determine the operation to be performed, it * must be second character in line */ optype = line[1]; if (strchr(ALLOPS, optype) == NULL) { printf("Unknown operator\n"); return; } /* determine the RHS argument (if one is required), * it must start in third character of line */ if (optype != PRINT) { if (strlen(line)<3) { printf("No RHS supplied\n"); return; } status = get_second_value(vars, line+2, &second_value); if (status==ERROR) { printf("RHS argument is invalid\n"); return; } } /* finally, do the actual operation */ if (optype == PRINT) { do_print(vars+varnum); } else if (optype == ASSIGN) { do_assign(vars+varnum, &second_value); } else if (optype == PLUS) { do_plus(vars+varnum, &second_value); } else if (optype == MULT) { do_mult(vars+varnum, &second_value); } else if (optype == POWER) { do_power(vars+varnum, &second_value); } return; }
int main (int argc, char **argv) { program_name = basename (argv[0]); scan_options (argc, argv); stack *stack = new_stack (); bool quit = false; yy_flex_debug = false; while (! quit) { int token = yylex(); if (token == YYEOF) break; switch (token) { case NUMBER: do_push (stack, yytext); break; case '+': do_binop (stack, add_bigint); break; case '-': do_binop (stack, sub_bigint); break; case '*': do_binop (stack, mul_bigint); break; case 'c': do_clear (stack); break; case 'f': do_print_all (stack); break; case 'p': do_print (stack); break; case 'q': quit = true; break; default: unimplemented (token); break; } } yycleanup(); DEBUGF ('m', "EXIT %d\n", exit_status); do_clear(stack); free_stack(stack); return EXIT_SUCCESS; }
/*==========================================================================================* ###### ######## ####### ######## ###### ###### ## ## ######## ######## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ###### ## ## ## ######## ###### ## ######### ###### ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ###### ## ####### ## ####### ###### ###### ## ## ######## ######## *==========================================================================================*/ PUBLIC int do_stop_scheduling(message *m_ptr) { register struct schedproc *rmp; int err, proc_nr_n; do_print("CMPS111", "do_stop_scheduling"); /* check who can send you requests */ if (!accept_message(m_ptr)) return EPERM; if (sched_isokendpt(m_ptr->SCHEDULING_ENDPOINT, &proc_nr_n) != OK) { printf("do_stop_scheduling: WARNING: got an invalid endpoint in OOQ msg " "%ld\n", m_ptr->SCHEDULING_ENDPOINT); return EBADEPT; } rmp = &schedproc[proc_nr_n]; do_print_process(rmp, "do_stop_scheduling", DEBUG); rmp->flags &= ~IN_USE; /*if ((err = schedule_process(rmp, "do_stop_scheduling")) != OK) { printf("ERROROROAROAROROR\n"); }*/ if (rmp->priority == MAX_USER_Q) { do_lottery(); } return OK; }
int main (int argc, char **argv) { program_name = basename (argv[0]); scan_options (argc, argv); stack *stack = new_stack (); token *scanner = new_token (stdin); for (;;) { int token = scan_token (scanner); if (token == EOF) break; switch (token) { case NUMBER: do_push (stack, peek_token (scanner)); break; case '+': do_binop (stack, add_bigint); break; case '-': do_binop (stack, sub_bigint); break; case '*': do_binop (stack, mul_bigint); break; case 'c': do_clear (stack); break; case 'f': do_print_all (stack); break; case 'p': do_print (stack); break; default: unimplemented (token); break; } } do_clear(stack); free_stack(stack); free_token(scanner); DEBUGF ('m', "EXIT %d\n", exit_status); return EXIT_SUCCESS; }
static void rprint_func_die (void *vo) { struct rprint_instance *o = vo; do_print(o->i, o->args, o->ln); NCDModuleInst_Backend_Dead(o->i); }
bool make_stable_training_sets_by_personal(const list <Record> & all_records, const unsigned int limit, const vector <string> & training_filenames) { //if ( training_filenames.size() != 2 ) //throw cException_Other("Training: there should be 2 changeable training sets."); cGroup_Value rare_firstname_set; cGroup_Value rare_lastname_set; std::ofstream outfile; cPrint_Pair do_print(outfile, cUnique_Record_ID::static_get_class_name()); const char * current_file; vector<cGroup_Value *> rare_pointer_vec; rare_pointer_vec.push_back(&rare_firstname_set); rare_pointer_vec.push_back(&rare_lastname_set); const vector< const cGroup_Value * > const_rare_pointer_vec(rare_pointer_vec.begin(), rare_pointer_vec.end()); list < const Record*> record_pointers; for ( list<Record>::const_iterator p = all_records.begin(); p != all_records.end(); ++p ) record_pointers.push_back(&(*p)); find_rare_names_v2(rare_pointer_vec, record_pointers); list<pointer_pairs> pair_list; vector <string> rare_column_names; rare_column_names.push_back(string(cFirstname::static_get_class_name())); rare_column_names.push_back(string(cLastname::static_get_class_name())); //xset03 pair_list.clear(); create_xset03(pair_list, record_pointers, const_rare_pointer_vec, limit); current_file = training_filenames.at(0).c_str(); outfile.open(current_file); if ( ! outfile.good() ) throw cException_File_Not_Found(current_file); std::cout << "Creating " << current_file << " ..." << std::endl; std::for_each(pair_list.begin(), pair_list.end(), do_print); outfile.close(); std::cout << "Done" << std::endl; //tset02 pair_list.clear(); create_tset02(pair_list, record_pointers, rare_column_names, const_rare_pointer_vec, limit); current_file = training_filenames.at(1).c_str(); outfile.open(current_file); if ( ! outfile.good() ) throw cException_File_Not_Found(current_file); std::cout << "Creating " << current_file << " ..." << std::endl; std::for_each(pair_list.begin(), pair_list.end(), do_print); outfile.close(); std::cout << "Done" << std::endl; return true; }
void do_operator (stack *the_stack, const char *oper) { switch (oper[0]) { case '+': do_binop (the_stack, '+'); break; case '-': do_binop (the_stack, '-'); break; case '*': do_binop (the_stack, '*'); break; case '/': do_binop (the_stack, '/'); break; case ';': do_print (the_stack); break; case '@': do_clear (the_stack); break; default : bad_operator (oper); break; } }
void do_operator (stack *the_stack, const char *oper) { switch (*oper) { case '+': do_binop (the_stack, '+'); break; case '-': do_binop (the_stack, '-'); break; case '*': do_binop (the_stack, '*'); break; case '/': do_binop (the_stack, '/'); break; case ';': do_print (the_stack); break; case '@': do_clear (the_stack); break; default : bad_operator (oper); break; } //printf ("the_stack=%p, top=%d, oper=\"%s\"\n", // the_stack, the_stack->top, oper); }
void do_print(MENU_NODE *root) { MENU_NODE *current; current = root; while (current) { if (current->child) do_print(current->child); current = current->next; } print_menu_list(root); }
static void println_func_new (void *unused, NCDModuleInst *i, const struct NCDModuleInst_new_params *params) { if (!check_args(i, params)) { goto fail0; } do_print(i, params->args, 1); NCDModuleInst_Backend_Up(i); return; fail0: NCDModuleInst_Backend_DeadError(i); }
static grub_err_t grub_cmd_sleep (grub_extcmd_context_t ctxt, int argc, char **args) { struct grub_arg_list *state = ctxt->state; int n; if (argc != 1) return grub_error (GRUB_ERR_BAD_ARGUMENT, "missing operand"); n = grub_strtoul (args[0], 0, 10); if (n == 0) { /* Either `0' or broken input. */ return 0; } pos = grub_term_save_pos (); for (; n; n--) { if (state[0].set) do_print (n); if (state[1].set) { if (grub_interruptible_millisleep (1000)) return 1; } else grub_millisleep (1000); } if (state[0].set) do_print (0); return 0; }
/// print out an operator string static int do_print( FILE *ff, const tdop_type &tdop, const operator_string_type ops ) throw() { int num(0); unsigned i(0); for(; i < ops.length(); ++i) { if(0 < i) { num += fprintf(ff, " "); } num += do_print(ff, tdop, ops[i]); } return num; }
int main(int argc, char **argv) { int c; int status; int global_status = 0; while (1) { c = getopt(argc, argv, "nqyH"); if (c == -1) break; switch (c) { case 'n': global_suppress_output = 1; break; case 'q': global_quiet = 1; break; case 'y': global_fail_verify_ok = 1; break; case 'H': global_halt_on_error = 1; break; default: break; } } stp_init(); output = stdout; while (1) { status = do_print(); if (status == 1) break; else if (status != 0) global_status = 1; } close_output(); if (passes + failures + skipped > 1) fprintf(stderr, "%d pass, %d fail, %d skipped\n", passes, failures, skipped); return global_status; }
static void resolve_callback( __unused DNSServiceRef sdRef, __unused DNSServiceFlags flags, __unused uint32_t interfaceIndex, __unused DNSServiceErrorType errorCode, Dused const char *fullName, const char *hostTarget, Dused uint16_t port, Dused uint16_t txtLen, Dused const unsigned char *txtRecord, void *context) { struct cbinfo *info = context; #ifdef DEBUG const char *p; char *q, *s; int len; printf("resolve: %s %s:%d TXT %d\n", fullName, hostTarget, port, txtLen); if ((txtLen > 1) && ((s = malloc(txtLen+2)))) { p = txtRecord; q = s; len = txtLen; while (len > 0) { strncpy(q, p+1, *p); len -= *p + 1; q += *p; p += *p + 1; } *q = '\0'; printf(" %s\n", s); free(s); } #endif do_print(hostTarget); CFRunLoopRemoveSource(CFRunLoopGetCurrent(), info->rls, kCFRunLoopDefaultMode); CFRelease(info->rls); CFSocketInvalidate(info->sockref); CFRelease(info->sockref); DNSServiceRefDeallocate(info->sdref); free(info); }
/** update domain to file */ static int do_update(char* domain, char* file) { struct ub_ctx* ctx; struct ub_result* result; int r; printf("updating %s to %s\n", domain, file); ctx = ub_ctx_create(); if(!ctx) fatal("ub_ctx_create failed"); if((r=ub_ctx_add_ta_file(ctx, file))) { printf("%s\n", ub_strerror(r)); fatal("ub_ctx_add_ta_file failed"); } if(!(result=do_lookup(ctx, domain))) { ub_ctx_delete(ctx); return 1; } ub_ctx_delete(ctx); do_print(result, file); ub_resolve_free(result); return 0; }
std::ostream& print(std::ostream& out) const { return do_print(out); }
static int swisseph(char *buf) { char serr[AS_MAXCH*2], serr_save[AS_MAXCH], serr_warn[AS_MAXCH]; char s[AS_MAXCH]; char s1[AS_MAXCH], s2[AS_MAXCH]; char star[AS_MAXCH]; char *sp, *sp2; char se_pname[AS_MAXCH]; char *spnam, *spnam2 = ""; char *fmt = "PZBRS"; char *plsel, *psp; char *gap = " "; double jut = 0.0, y_frac; int i, j; double hpos; int jday, jmon, jyear, jhour, jmin, jsec; int ipl, ipldiff = SE_SUN; double x[6], xequ[6], xcart[6], xcartq[6]; double cusp[12+1]; /* cusp[0] + 12 houses */ double ascmc[10]; /* asc, mc, vertex ...*/ double ar, sinp; double a, sidt, armc, lon, lat; double eps_true, eps_mean, nutl, nuto; char ephepath[AS_MAXCH]; char fname[AS_MAXCH]; char splan[100], sast[AS_MAXCH]; int nast, iast; long astno[100]; long iflag = 0, iflag2; /* external flag: helio, geo... */ long iflgret; long whicheph = SEFLG_SWIEPH; AS_BOOL universal_time = FALSE; AS_BOOL calc_house_pos = FALSE; short gregflag; AS_BOOL diff_mode = FALSE; int round_flag = 0; double tjd_ut = 2415020.5; double tjd_et, t2; double delt; char bc[20]; char *jul; int hsys = (int) *pd.hsysname; *serr = *serr_save = *serr_warn = '\0'; strcpy(ephepath, SE_EPHE_PATH); if (strcmp(pd.ephe, ephe[1]) == 0) { whicheph = SEFLG_JPLEPH; strcpy(fname, SE_FNAME_DE406); } else if (strcmp(pd.ephe, ephe[0]) == 0) whicheph = SEFLG_SWIEPH; else whicheph = SEFLG_MOSEPH; if (strcmp(pd.etut, "UT") == 0) universal_time = TRUE; if (strcmp(pd.plansel, plansel[0]) == 0) { plsel = PLSEL_D; } else if (strcmp(pd.plansel, plansel[1]) == 0) { plsel = PLSEL_P; } else if (strcmp(pd.plansel, plansel[2]) == 0) { plsel = PLSEL_A; } if (strcmp(pd.ctr, ctr[0]) == 0) calc_house_pos = TRUE; else if (strcmp(pd.ctr, ctr[1]) == 0) { iflag |= SEFLG_TOPOCTR; calc_house_pos = TRUE; } else if (strcmp(pd.ctr, ctr[2]) == 0) { iflag |= SEFLG_HELCTR; } else if (strcmp(pd.ctr, ctr[3]) == 0) { iflag |= SEFLG_BARYCTR; } else if (strcmp(pd.ctr, ctr[4]) == 0) { iflag |= SEFLG_SIDEREAL; swe_set_sid_mode(SE_SIDM_FAGAN_BRADLEY, 0, 0); } else if (strcmp(pd.ctr, ctr[5]) == 0) { iflag |= SEFLG_SIDEREAL; swe_set_sid_mode(SE_SIDM_LAHIRI, 0, 0); #if 0 } else { iflag &= ~(SEFLG_HELCTR | SEFLG_BARYCTR | SEFLG_TOPOCTR); #endif } lon = pd.lon_deg + pd.lon_min / 60.0 + pd.lon_sec / 3600.0; if (*pd.lon_e_w == 'W') lon = -lon; lat = pd.lat_deg + pd.lat_min / 60.0 + pd.lat_sec / 3600.0; if (*pd.lat_n_s == 'S') lat = -lat; sprintf(s, "Planet Positions from %s \n\n", pd.ephe); do_print(buf, s); if (whicheph & SEFLG_JPLEPH) swe_set_jpl_file(fname); iflag = (iflag & ~SEFLG_EPHMASK) | whicheph; iflag |= SEFLG_SPEED; #if 0 if (pd.helio) iflag |= SEFLG_HELCTR; #endif if ((long) pd.year * 10000L + (long) pd.mon * 100L + (long) pd.mday < 15821015L) gregflag = FALSE; else gregflag = TRUE; jday = pd.mday; jmon = pd.mon; jyear = pd.year; jhour = pd.hour; jmin = pd.min; jsec = pd.sec; jut = jhour + jmin / 60.0 + jsec / 3600.0; tjd_ut = swe_julday(jyear,jmon,jday,jut,gregflag); swe_revjul(tjd_ut, gregflag, &jyear, &jmon, &jday, &jut); jut += 0.5 / 3600; jhour = (int) jut; jmin = (int) fmod(jut * 60, 60); jsec = (int) fmod(jut * 3600, 60); *bc = '\0'; if (pd.year <= 0) sprintf(bc, "(%d B.C.)", 1 - jyear); if (jyear * 10000L + jmon * 100L + jday <= 15821004) jul = "jul."; else jul = ""; sprintf(s, "%d.%d.%d %s %s %#02d:%#02d:%#02d %s\n", jday, jmon, jyear, bc, jul, jhour, jmin, jsec, pd.etut); do_print(buf, s); jut = jhour + jmin / 60.0 + jsec / 3600.0; if (universal_time) { delt = swe_deltat(tjd_ut); sprintf(s, " delta t: %f sec", delt * 86400.0); do_print(buf, s); tjd_et = tjd_ut + delt; } else tjd_et = tjd_ut; sprintf(s, " jd (ET) = %f\n", tjd_et); do_print(buf, s); iflgret = swe_calc(tjd_et, SE_ECL_NUT, iflag, x, serr); eps_true = x[0]; eps_mean = x[1]; strcpy(s1, dms(eps_true, round_flag)); strcpy(s2, dms(eps_mean, round_flag)); sprintf(s, "\n%-15s %s%s%s (true, mean)", "Ecl. obl.", s1, gap, s2); do_print(buf, s); nutl = x[2]; nuto = x[3]; strcpy(s1, dms(nutl, round_flag)); strcpy(s2, dms(nuto, round_flag)); sprintf(s, "\n%-15s %s%s%s (dpsi, deps)", "Nutation", s1, gap, s2); do_print(buf, s); do_print(buf, "\n\n"); do_print(buf, " ecl. long. ecl. lat. "); do_print(buf, " dist. speed"); if (calc_house_pos) do_print(buf, " house"); do_print(buf, "\n"); if (iflag & SEFLG_TOPOCTR) swe_set_topo(lon, lat, pd.alt); sidt = swe_sidtime(tjd_ut) + lon / 15; if (sidt >= 24) sidt -= 24; if (sidt < 0) sidt += 24; armc = sidt * 15; /* additional asteroids */ strcpy(splan, plsel); if (strcmp(plsel,PLSEL_P) == 0) { char *cpos[40]; strcpy(sast, pd.sast); j = cut_str_any(sast, ",;. \t", cpos, 40); for (i = 0, nast = 0; i < j; i++) { if ((astno[nast] = atol(cpos[i])) > 0) { nast++; strcat(splan, "+"); } } } for (psp = splan, iast = 0; *psp != '\0'; psp++) { if (*psp == '+') { ipl = SE_AST_OFFSET + (int) astno[iast]; iast++; } else ipl = letter_to_ipl(*psp); if (iflag & SEFLG_HELCTR) { if (ipl == SE_SUN || ipl == SE_MEAN_NODE || ipl == SE_TRUE_NODE || ipl == SE_MEAN_APOG || ipl == SE_OSCU_APOG) continue; } else if (iflag & SEFLG_BARYCTR) { if (ipl == SE_MEAN_NODE || ipl == SE_TRUE_NODE || ipl == SE_MEAN_APOG || ipl == SE_OSCU_APOG) continue; } else /* geocentric */ if (ipl == SE_EARTH) continue; /* ecliptic position */ if (ipl == SE_FIXSTAR) { iflgret = swe_fixstar(star, tjd_et, iflag, x, serr); strcpy(se_pname, star); } else { iflgret = swe_calc(tjd_et, ipl, iflag, x, serr); swe_get_planet_name(ipl, se_pname); if (ipl > SE_AST_OFFSET) { sprintf(s, "#%d", (int) astno[iast-1]); strcat(se_pname, " "); strcpy(se_pname + 11 - strlen(s), s); } } if (iflgret >= 0) { if (calc_house_pos) { hpos = swe_house_pos(armc, lat, eps_true, hsys, x, serr); if (hpos == 0) iflgret = ERR; } } if (iflgret < 0) { if (*serr != '\0' && strcmp(serr, serr_save) != 0) { strcpy (serr_save, serr); do_print(buf, "error: "); do_print(buf, serr); do_print(buf, "\n"); } } else if (*serr != '\0' && *serr_warn == '\0') strcpy(serr_warn, serr); /* equator position */ if (strpbrk(fmt, "aADdQ") != NULL) { iflag2 = iflag | SEFLG_EQUATORIAL; if (ipl == SE_FIXSTAR) iflgret = swe_fixstar(star, tjd_et, iflag2, xequ, serr); else iflgret = swe_calc(tjd_et, ipl, iflag2, xequ, serr); } /* ecliptic cartesian position */ if (strpbrk(fmt, "XU") != NULL) { iflag2 = iflag | SEFLG_XYZ; if (ipl == SE_FIXSTAR) iflgret = swe_fixstar(star, tjd_et, iflag2, xcart, serr); else iflgret = swe_calc(tjd_et, ipl, iflag2, xcart, serr); } /* equator cartesian position */ if (strpbrk(fmt, "xu") != NULL) { iflag2 = iflag | SEFLG_XYZ | SEFLG_EQUATORIAL; if (ipl == SE_FIXSTAR) iflgret = swe_fixstar(star, tjd_et, iflag2, xcartq, serr); else iflgret = swe_calc(tjd_et, ipl, iflag2, xcartq, serr); } spnam = se_pname; /* * The string fmt contains a sequence of format specifiers; * each character in fmt creates a column, the columns are * sparated by the gap string. */ for (sp = fmt; *sp != '\0'; sp++) { if (sp != fmt) do_print(buf, gap); switch(*sp) { case 'y': sprintf(s, "%d", jyear); do_print(buf, s); break; case 'Y': jut = 0; t2 = swe_julday(jyear,1,1,jut,gregflag); y_frac = (tjd_ut - t2) / 365.0; sprintf(s, "%.2lf", jyear + y_frac); do_print(buf, s); break; case 'p': if (diff_mode) sprintf(s, "%d-%d", ipl, ipldiff); else sprintf(s, "%d", ipl); do_print(buf, s); break; case 'P': if (diff_mode) sprintf(s, "%.3s-%.3s", spnam, spnam2); else sprintf(s, "%-11s", spnam); do_print(buf, s); break; case 'J': case 'j': sprintf(s, "%.2f", tjd_ut); do_print(buf, s); break; case 'T': sprintf(s, "%02d.%02d.%d", jday, jmon, jyear); do_print(buf, s); break; case 't': sprintf(s, "%02d%02d%02d", jyear % 100, jmon, jday); do_print(buf, s); break; case 'L': do_print(buf, dms(x[0], round_flag)); break; case 'l': sprintf(s, "%# 11.7f", x[0]); do_print(buf, s); break; case 'Z': do_print(buf, dms(x[0], round_flag|BIT_ZODIAC)); break; case 'S': case 's': if (*(sp+1) == 'S' || *(sp+1) == 's' || strpbrk(fmt, "XUxu") != NULL) { for (sp2 = fmt; *sp2 != '\0'; sp2++) { if (sp2 != fmt) do_print(buf, gap); switch(*sp2) { case 'L': /* speed! */ case 'Z': /* speed! */ do_print(buf, dms(x[3], round_flag)); break; case 'l': /* speed! */ sprintf(s, "%11.7f", x[3]); do_print(buf, s); break; case 'B': /* speed! */ do_print(buf, dms(x[4], round_flag)); break; case 'b': /* speed! */ sprintf(s, "%11.7f", x[4]); do_print(buf, s); break; case 'A': /* speed! */ do_print(buf, dms(xequ[3]/15, round_flag|SEFLG_EQUATORIAL)); break; case 'a': /* speed! */ sprintf(s, "%11.7f", xequ[3]); do_print(buf, s); break; case 'D': /* speed! */ do_print(buf, dms(xequ[4], round_flag)); break; case 'd': /* speed! */ sprintf(s, "%11.7f", xequ[4]); do_print(buf, s); break; case 'R': /* speed! */ case 'r': /* speed! */ sprintf(s, "%# 14.9f", x[5]); do_print(buf, s); break; case 'U': /* speed! */ case 'X': /* speed! */ if (*sp =='U') ar = sqrt(square_sum(xcart)); else ar = 1; sprintf(s, "%# 14.9f%s", xcart[3]/ar, gap); do_print(buf, s); sprintf(s, "%# 14.9f%s", xcart[4]/ar, gap); do_print(buf, s); sprintf(s, "%# 14.9f", xcart[5]/ar); do_print(buf, s); break; case 'u': /* speed! */ case 'x': /* speed! */ if (*sp =='u') ar = sqrt(square_sum(xcartq)); else ar = 1; sprintf(s, "%# 14.9f%s", xcartq[3]/ar, gap); do_print(buf, s); sprintf(s, "%# 14.9f%s", xcartq[4]/ar, gap); do_print(buf, s); sprintf(s, "%# 14.9f", xcartq[5]/ar); do_print(buf, s); break; default: break; } } if (*(sp+1) == 'S' || *(sp+1) == 's') sp++; } else { do_print(buf, dms(x[3], round_flag)); } break; case 'B': do_print(buf, dms(x[1], round_flag)); break; case 'b': sprintf(s, "%# 11.7f", x[1]); do_print(buf, s); break; case 'A': /* rectascensio */ do_print(buf, dms(xequ[0]/15, round_flag|SEFLG_EQUATORIAL)); break; case 'a': /* rectascensio */ sprintf(s, "%# 11.7f", xequ[0]); do_print(buf, s); break; case 'D': /* declination */ do_print(buf, dms(xequ[1], round_flag)); break; case 'd': /* declination */ sprintf(s, "%# 11.7f", xequ[1]); do_print(buf, s); break; case 'R': sprintf(s, "%# 14.9f", x[2]); do_print(buf, s); break; case 'r': if ( ipl == SE_MOON ) { /* for moon print parallax */ sinp = 8.794 / x[2]; /* in seconds of arc */ ar = sinp * (1 + sinp * sinp * 3.917402e-12); /* the factor is 1 / (3600^2 * (180/pi)^2 * 6) */ sprintf(s, "%# 13.5f\"", ar); } else { sprintf(s, "%# 14.9f", x[2]); } do_print(buf, s); break; case 'U': case 'X': if (*sp =='U') ar = sqrt(square_sum(xcart)); else ar = 1; sprintf(s, "%# 14.9f%s", xcart[0]/ar, gap); do_print(buf, s); sprintf(s, "%# 14.9f%s", xcart[1]/ar, gap); do_print(buf, s); sprintf(s, "%# 14.9f", xcart[2]/ar); do_print(buf, s); break; case 'u': case 'x': if (*sp =='u') ar = sqrt(square_sum(xcartq)); else ar = 1; sprintf(s, "%# 14.9f%s", xcartq[0]/ar, gap); do_print(buf, s); sprintf(s, "%# 14.9f%s", xcartq[1]/ar, gap); do_print(buf, s); sprintf(s, "%# 14.9f", xcartq[2]/ar); do_print(buf, s); break; case 'Q': sprintf(s, "%-15s", spnam); do_print(buf, s); do_print(buf, dms(x[0], round_flag)); do_print(buf, dms(x[1], round_flag)); sprintf(s, " %# 14.9f", x[2]); do_print(buf, s); do_print(buf, dms(x[3], round_flag)); do_print(buf, dms(x[4], round_flag)); sprintf(s, " %# 14.9f\n", x[5]); do_print(buf, s); sprintf(s, " %s", dms(xequ[0], round_flag)); do_print(buf, s); do_print(buf, dms(xequ[1], round_flag)); sprintf(s, " %s", dms(xequ[3], round_flag)); do_print(buf, s); do_print(buf, dms(xequ[4], round_flag)); break; } /* switch */ } /* for sp */ if (calc_house_pos) { sprintf(s, " %# 6.4f", hpos); sprintf(s, "%# 9.4f", hpos); do_print(buf, s); } do_print(buf, "\n"); } /* for psp */ if (*serr_warn != '\0') { do_print(buf, "\nwarning: "); do_print(buf, serr_warn); do_print(buf, "\n"); } /* houses */ sprintf(s, "\nHouse Cusps (%s)\n\n", pd.hsysname); do_print(buf, s); a = sidt + 0.5 / 3600; sprintf(s, "sid. time : %4d:%#02d:%#02d ", (int) a, (int) fmod(a * 60, 60), (int) fmod(a * 3600, 60)); do_print(buf, s); a = armc + 0.5 / 3600; sprintf(s, "armc : %4d%c%#02d'%#02d\"\n", (int) armc, ODEGREE_CHAR, (int) fmod(armc * 60, 60), (int) fmod(a * 3600, 60)); do_print(buf, s); sprintf(s, "geo. lat. : %4d%c%#02d'%#02d\" ", pd.lat_deg, *pd.lat_n_s, pd.lat_min, pd.lat_sec); do_print(buf, s); sprintf(s, "geo. long.: %4d%c%#02d'%#02d\"\n\n", pd.lon_deg, *pd.lon_e_w, pd.lon_min, pd.lon_sec); do_print(buf, s); swe_houses_ex(tjd_ut, iflag, lat, lon, hsys, cusp, ascmc); round_flag |= BIT_ROUND_SEC; #if FALSE sprintf(s, "AC : %s\n", dms(ascmc[0], round_flag)); do_print(buf, s); sprintf(s, "MC : %s\n", dms(ascmc[1], round_flag)); do_print(buf, s); for (i = 1; i <= 12; i++) { sprintf(s, "house %2d: %s\n", i, dms(cusp[i], round_flag)); do_print(buf, s); } sprintf(s, "Vertex : %s\n", dms(ascmc[3], round_flag)); do_print(buf, s); #else sprintf(s, "AC : %s\n", dms(ascmc[0], round_flag|BIT_ZODIAC)); do_print(buf, s); sprintf(s, "MC : %s\n", dms(ascmc[1], round_flag|BIT_ZODIAC)); do_print(buf, s); for (i = 1; i <= 12; i++) { sprintf(s, "house %2d: %s\n", i, dms(cusp[i], round_flag|BIT_ZODIAC)); do_print(buf, s); } sprintf(s, "Vertex : %s\n", dms(ascmc[3], round_flag|BIT_ZODIAC)); do_print(buf, s); #endif return 0; }
void print_list(const int debuglvl, struct vrmr_list *list, char *title, int height, int width, int starty, int startx, char utf8) { WINDOW *boxwin = NULL, *printwin = NULL; PANEL *panel[2]; int ch; helpword *hw = NULL; size_t start_print = 1, end_print = 1; char done = 0; int i = 0; size_t size = 0; end_print = (size_t)height - 2; if(!(boxwin = create_newwin(height, width, starty, startx, title, vccnf.color_win))) { vrmr_error(-1, VR_ERR, "could not create window (in: %s:%d).", __FUNC__, __LINE__); return; } if(!(panel[0] = new_panel(boxwin))) { vrmr_error(-1, VR_ERR, "could not create panel (in: %s:%d).", __FUNC__, __LINE__); return; } if(!(printwin = newwin(height-2, width-4, starty+1, startx+2))) { vrmr_error(-1, VR_ERR, "could not create window (in: %s:%d).", __FUNC__, __LINE__); return; } (void)wbkgd(printwin, vccnf.color_win); if(!(panel[1] = new_panel(printwin))) { vrmr_error(-1, VR_ERR, "could not create panel (in: %s:%d).", __FUNC__, __LINE__); return; } keypad(printwin, TRUE); size = StrLen(gettext("Press <F10> to close this window.")); mvwprintw(boxwin, height-1, (int)(width-size)/2, " %s ", gettext("Press <F10> to close this window.")); wrefresh(boxwin); while(!done) { werase(printwin); if(list->len == 0) { wprintw(printwin, gettext("The requested helptext was not found.\n")); } #ifdef USE_WIDEC if(utf8 == UTF8_TRUE) do_wide_print(debuglvl, printwin, list, start_print, end_print); else #endif /* USE_WIDEC */ do_print(debuglvl, printwin, list, start_print, end_print); update_panels(); doupdate(); /* get user input */ ch = wgetch(printwin); switch(ch) { case KEY_DOWN: if(list->len > 0) { if(!(hw = list->bot->data)) { vrmr_error(-1, VR_INTERR, "NULL pointer (in: %s:%d).", __FUNC__, __LINE__); return; } if(end_print < hw->line_num) { start_print++; end_print++; } } break; case KEY_UP: if(list->len > 0) { if(start_print > 1) { start_print--; end_print--; } } break; case KEY_PPAGE: if(list->len > 0) { i = (height - 2)/3; while((start_print - i) < 1) i--; start_print = start_print - i; end_print = end_print - i; } break; case KEY_NPAGE: if(list->len > 0) { i = (height - 2)/3; if(!(hw = list->bot->data)) { vrmr_error(-1, VR_INTERR, "NULL pointer (in: %s:%d).", __FUNC__, __LINE__); return; } while((end_print + i) > hw->line_num) i--; start_print = start_print + i; end_print = end_print + i; } break; default: done = 1; break; } } del_panel(panel[0]); del_panel(panel[1]); destroy_win(printwin); destroy_win(boxwin); update_panels(); doupdate(); return; }
bool make_changable_training_sets_by_assignee(const list <const cRecord*> & record_pointers, const vector<string >& blocking_column_names, const vector < const cString_Manipulator *> & pstring_oper, const unsigned int limit, const vector <string> & training_filenames) { if ( training_filenames.size() != 2 ) throw cException_Other("Training: there should be 2 changeable training sets."); const string uid_identifier = cUnique_Record_ID::static_get_class_name(); cBlocking_For_Training bft (record_pointers, blocking_column_names, pstring_oper, uid_identifier, limit); cString_Remain_Same donotchange; cString_NoSpace_Truncate operator_truncate_firstname; cString_NoSpace_Truncate operator_truncate_lastname; vector <const cString_Manipulator*> t_extract_equal, t_extract_nonequal, x_extract_equal, x_extract_nonequal; std::ofstream outfile; //xset01 /* x_extract_nonequal.push_back(& donotchange); x_extract_equal.push_back(&donotchange); const string xset01_equal_name_array[] = {cApplyYear::static_get_class_name() }; const string xset01_nonequal_name_array[] = { cCity::static_get_class_name() }; const vector <string> xset01_equal_name_vec (xset01_equal_name_array, xset01_equal_name_array + sizeof(xset01_equal_name_array)/sizeof(string)); const vector <string> xset01_nonequal_name_vec (xset01_nonequal_name_array, xset01_nonequal_name_array + sizeof(xset01_nonequal_name_array)/sizeof(string)); bft.create_set(&cBlocking_For_Training::create_xset01_on_block, xset01_equal_name_vec, x_extract_equal, xset01_nonequal_name_vec, x_extract_nonequal); const char * current_file = training_filenames.at(0).c_str(); outfile.open(current_file); if ( ! outfile.good() ) throw cException_File_Not_Found(current_file); std::cout << "Creating " << current_file << " ..." << std::endl; bft.print(outfile, uid_identifier); outfile.close(); std::cout << "Done" << std::endl; */ outfile.open(training_filenames.at(0).c_str()); list < std::pair< const cRecord*, const cRecord*> > chosen_pairs; cPrint_Pair do_print(outfile, cUnique_Record_ID::static_get_class_name()); create_xset01( chosen_pairs, record_pointers, limit); std::for_each(chosen_pairs.begin(), chosen_pairs.end(), do_print); outfile.close(); std::cout << "Done" << std::endl; // tset05 operator_truncate_firstname.set_truncater(0, 1, true); operator_truncate_lastname.set_truncater(0, 2, true); t_extract_equal.push_back(& operator_truncate_firstname); t_extract_equal.push_back(& operator_truncate_lastname); bft.reset(blocking_column_names.size()); const string tset05_equal_name_array[] = { cFirstname::static_get_class_name(), cLastname::static_get_class_name()}; const string tset05_nonequal_name_array[] = {}; const vector <string> tset05_equal_name_vec (tset05_equal_name_array, tset05_equal_name_array + sizeof(tset05_equal_name_array)/sizeof(string)); const vector <string> tset05_nonequal_name_vec (tset05_nonequal_name_array, tset05_nonequal_name_array + sizeof(tset05_nonequal_name_array)/sizeof(string)); bft.create_set(&cBlocking_For_Training::create_tset05_on_block, tset05_equal_name_vec, t_extract_equal, tset05_nonequal_name_vec, t_extract_nonequal ); const char * current_file = training_filenames.at(1).c_str(); outfile.open(current_file); if ( ! outfile.good() ) throw cException_File_Not_Found(current_file); std::cout << "Creating " << current_file << " ..." << std::endl; bft.print(outfile, uid_identifier); outfile.close(); std::cout << "Done" << std::endl; return true; }
int storage_get_keys(ST_STORAGE_API *api, char *buf, int buf_sz, char *key, int key_sz) { if(api->get_keys) return api->get_keys(api->storage_data, buf, buf_sz, key, key_sz); do_print("GET_KEYS", NULL, 0, NULL, 0); return -1; }
static int cgc_eval_statements(interp_t *interp, stmt_t *stmt) { for (; stmt != NULL; stmt = stmt->next) { int result; switch (stmt->type) { case STMT_IF: if (!cgc_eval_expression(interp, stmt->s_if.cond)) return EVAL_ERROR; if (coerce_bool(interp, &interp->result)) { result = cgc_eval_statements(interp, stmt->s_if.child); if (result != EVAL_FINISHED) return result; } break; case STMT_WHILE: if (!stmt->s_while.post) { if (!cgc_eval_expression(interp, stmt->s_while.cond)) return EVAL_ERROR; if (!coerce_bool(interp, &interp->result)) break; } do { result = cgc_eval_statements(interp, stmt->s_while.child); if (result == EVAL_BREAK) break; if (result != EVAL_CONTINUE && result != EVAL_FINISHED) return result; if (!cgc_eval_expression(interp, stmt->s_while.cond)) return EVAL_ERROR; } while (coerce_bool(interp, &interp->result)); break; case STMT_FOR: if (!cgc_eval_expression(interp, stmt->s_for.init)) return EVAL_ERROR; if (!cgc_eval_expression(interp, stmt->s_for.cond)) return EVAL_ERROR; while (coerce_bool(interp, &interp->result)) { result = cgc_eval_statements(interp, stmt->s_for.child); if (result == EVAL_BREAK) break; if (result != EVAL_CONTINUE && result != EVAL_FINISHED) return result; if (!cgc_eval_expression(interp, stmt->s_for.post)) return EVAL_ERROR; if (!cgc_eval_expression(interp, stmt->s_for.cond)) return EVAL_ERROR; } break; case STMT_CONTINUE: return EVAL_CONTINUE; case STMT_BREAK: return EVAL_BREAK; case STMT_NEXT: return EVAL_NEXT; case STMT_EXIT: return EVAL_EXIT; case STMT_PRINT: if (!do_print(interp, stmt)) return EVAL_ERROR; break; case STMT_EXPR: if (!cgc_eval_expression(interp, stmt->s_expr.expr)) return EVAL_ERROR; break; } } return EVAL_FINISHED; }
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths) { static const std::string example = Strings::format( "The argument should be a substring to search for, or no argument to display all libraries.\n%s", Commands::Help::create_example_string("search png")); args.check_max_arg_count(1, example); const std::unordered_set<std::string> options = args.check_and_get_optional_command_arguments({OPTION_GRAPH, OPTION_FULLDESC}); auto sources_and_errors = Paragraphs::try_load_all_ports(paths.get_filesystem(), paths.ports); if (!sources_and_errors.errors.empty()) { if (vcpkg::g_debugging) { print_error_message(sources_and_errors.errors); } else { for (auto&& error : sources_and_errors.errors) { System::println( System::Color::warning, "Warning: an error occurred while parsing '%s'", error->name); } System::println(System::Color::warning, "Use '--debug' to get more information about the parse failures.\n"); } } auto& source_paragraphs = sources_and_errors.paragraphs; if (options.find(OPTION_GRAPH) != options.cend()) { const std::string graph_as_string = create_graph_as_string(source_paragraphs); System::println(graph_as_string); Checks::exit_success(VCPKG_LINE_INFO); } if (args.command_arguments.empty()) { for (const auto& source_control_file : source_paragraphs) { do_print(*source_control_file->core_paragraph, options.find(OPTION_FULLDESC) != options.cend()); for (auto&& feature_paragraph : source_control_file->feature_paragraphs) { do_print(source_control_file->core_paragraph->name, *feature_paragraph, options.find(OPTION_FULLDESC) != options.cend()); } } } else { const auto& icontains = Strings::case_insensitive_ascii_contains; // At this point there is 1 argument auto&& args_zero = args.command_arguments[0]; for (const auto& source_control_file : source_paragraphs) { auto&& sp = *source_control_file->core_paragraph; bool contains_name = icontains(sp.name, args_zero); if (contains_name || icontains(sp.description, args_zero)) { do_print(sp, options.find(OPTION_FULLDESC) != options.cend()); } for (auto&& feature_paragraph : source_control_file->feature_paragraphs) { if (contains_name || icontains(feature_paragraph->name, args_zero) || icontains(feature_paragraph->description, args_zero)) { do_print(sp.name, *feature_paragraph, options.find(OPTION_FULLDESC) != options.cend()); } } } } System::println( "\nIf your library is not listed, please open an issue at and/or consider making a pull request:\n" " https://github.com/Microsoft/vcpkg/issues"); Checks::exit_success(VCPKG_LINE_INFO); }
void print( ostream& out ) const { do_print( out); }