/*virtual*/ void gui_filterbar_c::created() { set_theme_rect(CONSTASTR("filter"), false); filtereditheight = gui->theme().conf().get_int(CONSTASTR("filtereditheight"), 25); if (prf().get_options().is(UIOPT_SHOW_SEARCH_BAR)) { gui_textfield_c &e = (MAKE_CHILD<gui_textfield_c>(getrid(), L"", MAX_PATH, 0, false) << (gui_textedit_c::TEXTCHECKFUNC)DELEGATE(this, update_filter)); edit = &e; e.set_placeholder(TOOLTIP(TTT("Search", 277)), get_default_text_color(COL_PLACEHOLDER)); e.register_kbd_callback(DELEGATE(this, cancel_filter), SSK_ESC, false); } if (prf().get_options().is(UIOPT_TAGFILETR_BAR)) { fill_tags(); } search_in_messages = prf().is_loaded() && prf().get_options().is(MSGOP_FULL_SEARCH); if (!is_all()) refresh_list(); __super::created(); }
void active_protocol_c::save_config( const ts::blob_c &cfg_ ) { tableview_active_protocol_s &t = prf().get_table_active_protocol(); if (auto *r = t.find<true>(id)) { if ( r->other.config != cfg_) { time_t n = now(); if ( (n-last_backup_time) > prf().backup_period() ) { last_backup_time = n; tableview_backup_protocol_s &backup = prf().get_table_backup_protocol(); auto &row = backup.getcreate(0); row.other.time = now(); row.other.tick = GetTickCount(); row.other.protoid = id; row.other.config = r->other.config; } } r->other.config = cfg_; r->other.config.set_size(cfg_.size()); // copy content r->changed(); prf().changed(); } }
int GUI_printf(const char * fmt, ...) { va_list ap; va_start(ap, fmt); if (bootArgs->Video.v_display == VGA_TEXT_MODE) { prf(fmt, ap, putchar, 0); } else { vprf(fmt, ap); } /* Kabyl: BooterLog */ struct putc_info pi; if (!msgbuf) return 0; if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE))) return 0; pi.str = cursor; pi.last_str = 0; prf(fmt, ap, sputc, &pi); cursor += strlen((char *)cursor); va_end(ap); return 0; }
int verbose(const char * fmt, ...) { va_list ap; va_start(ap, fmt); if (gVerboseMode) { if (bootArgs->Video.v_display == VGA_TEXT_MODE) prf(fmt, ap, putchar, 0); else vprf(fmt, ap); } { // Kabyl: BooterLog struct putc_info pi; if (!msgbuf) return 0; if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE))) return 0; pi.str = cursor; pi.last_str = 0; prf(fmt, ap, sputc, &pi); cursor += strlen((char *)cursor); } va_end(ap); return(0); }
active_protocol_c::active_protocol_c(int id, const active_protocol_data_s &pd):id(id), lastconfig(ts::Time::past()) { int dspflags = cfg().dsp_flags(); auto w = syncdata.lock_write(); w().data = pd; w().data.config.set_size(pd.config.size()); // copy content due race condition if (w().data.sort_factor == 0) { w().data.sort_factor = id; for(; nullptr != prf().find_ap([&]( const active_protocol_c &oap )->bool { if (&oap == this) return false; return oap.sort_factor() == w().data.sort_factor; }) ; ++w().data.sort_factor ); } g_app->F_PROTOSORTCHANGED = true; w().volume = cfg().vol_talk(); w().dsp_flags = dspflags; w().manual_cos = (contact_online_state_e)prf().manual_cos(); cvt.volume = cfg().vol_mic(); cvt.filter_options.init(fmt_converter_s::FO_NOISE_REDUCTION, FLAG(dspflags, DSP_MIC_NOISE)); cvt.filter_options.init(fmt_converter_s::FO_GAINER, FLAG(dspflags, DSP_MIC_AGC)); }
int error(const char * fmt, ...) { va_list ap; gErrors = true; va_start(ap, fmt); if (bootArgs->Video.v_display == VGA_TEXT_MODE) { prf(fmt, ap, putchar, 0); } else { vprf(fmt, ap); } { // Kabyl: BooterLog struct putc_info pi; if (!msgbuf) { return 0; } if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE))) { return 0; } pi.str = cursor; pi.last_str = 0; prf(fmt, ap, sputc, &pi); cursor += strlen((char *)cursor); } va_end(ap); return(0); }
int verbose(const char * fmt, ...) { va_list ap; va_start(ap, fmt); if (gVerboseMode) { prf(fmt, ap, putchar, 0); } { /* Kabyl: BooterLog */ struct putc_info pi; if (!msgbuf) return 0; if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE))) return 0; pi.str = cursor; pi.last_str = 0; prf(fmt, ap, sputc, &pi); cursor += strlen((char *)cursor); } va_end(ap); return(0); }
bool gui_filterbar_c::option_handler(RID, GUIPARAM p) { search_in_messages = p != nullptr; if (prf().is_loaded()) prf().set_options( search_in_messages ? MSGOP_FULL_SEARCH : 0, MSGOP_FULL_SEARCH ); found_stuff.fsplit.clear(); refresh_list(); return true; }
/* * reader: read from remote: line -> 1 */ static int reader(int oldmask) { /* * 4.3bsd or later and SunOS 4.0 or later use the posiitive * pid; otherwise use the negative. */ pid_t pid = getpid(); int n, remaining; char *bufp = rcvbuf; (void) sigset(SIGTTOU, SIG_IGN); (void) sigset(SIGURG, (void (*)())oob); ppid = getppid(); if (fcntl(rem, F_SETOWN, pid) == -1) perror("fcntl F_SETOWN"); /* * A SIGURG may have been posted before we were completely forked, * which means we may not have received it. To insure we do not miss * any urgent data, we force the signal. The signal hander will be * able to determine if in fact there is urgent data or not. */ (void) kill(pid, SIGURG); (void) setjmp(rcvtop); sigsetmask(oldmask); for (;;) { while ((remaining = rcvcnt - (bufp - rcvbuf)) > 0) { rcvstate = WRITING; n = write(STDOUT_FILENO, bufp, remaining); if (n < 0) { if (errno != EINTR) { prf(gettext( "Write error to terminal: %s"), strerror(errno)); return (-1); } continue; } bufp += n; } bufp = rcvbuf; rcvcnt = 0; rcvstate = READING; rcvcnt = desread(rem, rcvbuf, sizeof (rcvbuf), 0); if (rcvcnt == 0) return (0); if (rcvcnt < 0) { if (errno == EINTR) continue; prf(gettext("Read error from network: %s"), strerror(errno)); return (-1); } } }
// Generate key material from the shared secret created from the ECDHE key exchange. static bool generate_key_material(sptps_t *s, const char *shared, size_t len) { // Initialise cipher and digest structures if necessary if(!s->outstate) { s->incipher = chacha_poly1305_init(); s->outcipher = chacha_poly1305_init(); if(!s->incipher || !s->outcipher) return error(s, EINVAL, "Failed to open cipher"); } // Allocate memory for key material size_t keylen = 2 * CHACHA_POLY1305_KEYLEN; s->key = realloc(s->key, keylen); if(!s->key) return error(s, errno, strerror(errno)); // Create the HMAC seed, which is "key expansion" + session label + server nonce + client nonce char seed[s->labellen + 64 + 13]; strcpy(seed, "key expansion"); if(s->initiator) { memcpy(seed + 13, s->mykex + 1, 32); memcpy(seed + 45, s->hiskex + 1, 32); } else { memcpy(seed + 13, s->hiskex + 1, 32); memcpy(seed + 45, s->mykex + 1, 32); } memcpy(seed + 77, s->label, s->labellen); // Use PRF to generate the key material if(!prf(shared, len, seed, s->labellen + 64 + 13, s->key, keylen)) return error(s, EINVAL, "Failed to generate key material"); return true; }
void active_protocol_c::push_debug_settings() { if (prf().get_options().is(OPTOPT_POWER_USER)) ipcp->send(ipcw(AQ_DEBUG_SETTINGS) << cfg().debug()); else ipcp->send(ipcw(AQ_DEBUG_SETTINGS) << ts::str_c()); }
void prcmd(struct trenod *t) { nonl++; prf(t); nonl = 0; }
int main(void) { Name l[1001]; // l[0][0] stores the size of l[0] int lsize, i; lsize = 0; while(fgets(l[lsize].ori, 90, stdin)) { l[lsize].len = strlen(l[lsize].ori) - 1; l[lsize].ori[ l[lsize].len ] = '\0'; //prf("'%s' len = %d\n", l[lsize].ori, l[lsize].len); if(l[lsize].len == 0) break; for(i = 0; i < l[lsize].len; i++) l[lsize].min[i] = tolower(l[lsize].ori[i]); lsize++; } qsort(l, lsize, sizeof(Name), cmpName); prf("%s\n", l[lsize - 1].ori); return 0; }
static void lostpeer(void) { (void) sigset(SIGPIPE, SIG_IGN); prf(gettext("\aConnection to %.*s closed."), MAXHOSTNAMELEN, host); done(EXIT_FAILURE); }
int main(void) { unsigned long long fib[1503] = {0}, num; char d[10001]; int T, i, len; // Fill up first 1500 fibonacci numbers fib[1] = fib[2] = fib[1501] = fib[1501] = 1; for(i = 2; i < 1500; i++) { fib[i] = (fib[i - 1] + fib[i - 2]) % 1000; } while(scf("%d", &T) != EOF) { while(T--) { scf("%s%n", d, &len); len--; // Christian Bonilian's voodoo to get the modular number for(num = i = 0; i < len; i++) { num *= 2; num += (d[i] - '0'); num %= 1500; } prf("%03lld\n", fib[num]); } } return 0; }
int main(void) { char t[510]; int len; len = read(0, t, 501); prf("%s\n", (len <= 140 ? "TWEET" : "MUTE")); return 0; }
int error(const char * fmt, ...) { va_list ap; gErrors = YES; va_start(ap, fmt); prf(fmt, ap, putchar, 0); va_end(ap); return(0); }
int printf(const char * fmt, ...) { va_list ap; if (bootArgs->graphicsMode != TEXT_MODE) return -1; va_start(ap, fmt); prf(fmt, ap, putchar, 0); va_end(ap); return 0; }
ts::uint32 active_protocol_c::gm_handler(gmsg<ISOGM_CHANGED_SETTINGS>&ch) { if (ch.pass == 0 && ipcp && (ch.protoid == 0 || ch.protoid == id)) { switch (ch.sp) { case PP_USERNAME: if (ch.protoid == id) { syncdata.lock_write()().data.user_name = ch.s; ipcp->send(ipcw(AQ_SET_NAME) << ch.s); } else if (syncdata.lock_read()().data.user_name.is_empty()) ipcp->send(ipcw(AQ_SET_NAME) << ch.s); return GMRBIT_CALLAGAIN; case PP_USERSTATUSMSG: if (ch.protoid == id) { syncdata.lock_write()().data.user_statusmsg = ch.s; ipcp->send(ipcw(AQ_SET_STATUSMSG) << ch.s); } else if (syncdata.lock_read()().data.user_statusmsg.is_empty()) ipcp->send(ipcw(AQ_SET_STATUSMSG) << ch.s); return GMRBIT_CALLAGAIN; case PP_NETWORKNAME: if (ch.protoid == id) syncdata.lock_write()().data.name = ch.s; return GMRBIT_CALLAGAIN; case PP_ONLINESTATUS: if (contact_c *c = contacts().get_self().subget( contact_key_s(0, id) )) set_ostate(c->get_ostate()); break; case PP_PROFILEOPTIONS: if (0 != (ch.bits & UIOPT_PROTOICONS) && !prf().get_options().is(UIOPT_PROTOICONS)) icons_cache.clear(); // FREE MEMORY break; case CFG_TALKVOLUME: syncdata.lock_write()().volume = cfg().vol_talk(); break; case CFG_MICVOLUME: cvt.volume = cfg().vol_mic(); break; case CFG_DSPFLAGS: { int flags = cfg().dsp_flags(); cvt.filter_options.init( fmt_converter_s::FO_NOISE_REDUCTION, FLAG(flags, DSP_MIC_NOISE) ); cvt.filter_options.init( fmt_converter_s::FO_GAINER, FLAG(flags, DSP_MIC_AGC) ); syncdata.lock_write()().dsp_flags = flags; } break; case CFG_DEBUG: push_debug_settings(); break; } } return 0; }
/** * Used for pseudorandom keygeneration, * generates the seed for the WOTS keypair at address addr * * takes n byte sk_seed and returns n byte seed using 32 byte address addr. */ static void get_seed(unsigned char *seed, const unsigned char *sk_seed, int n, uint32_t addr[8]) { unsigned char bytes[32]; // Make sure that chain addr, hash addr, and key bit are 0! setChainADRS(addr,0); setHashADRS(addr,0); setKeyAndMask(addr,0); // Generate pseudorandom value addr_to_byte(bytes, addr); prf(seed, bytes, sk_seed, n); }
int error(const char * fmt, ...) { va_list ap; gErrors = true; va_start(ap, fmt); if (bootArgs->Video.v_display == VGA_TEXT_MODE) prf(fmt, ap, putchar, 0); else vprf(fmt, ap); va_end(ap); return(0); }
void active_protocol_c::set_avatar( const ts::blob_c &ava ) { auto w = syncdata.lock_write(); w().data.avatar = ava; w().data.avatar.set_size(ava.size()); // make copy due refcount not multithreaded w.unlock(); tableview_active_protocol_s &t = prf().get_table_active_protocol(); if (auto *r = t.find<true>(id)) { r->other.avatar = ava; r->changed(); prf().changed(); } ipcp->send(ipcw(AQ_SET_AVATAR) << ava); if (contact_c *c = contacts().find_subself(getid())) c->set_avatar(ava.data(), ava.size(), 1); }
int verbose(const char * fmt, ...) { va_list ap; if (gVerboseMode) { va_start(ap, fmt); prf(fmt, ap, putchar, 0); va_end(ap); } return(0); }
static void derive_mtk(struct candidate *cand) { unsigned char context[84]; unsigned char *p; if (!ampe_conf.mesh->conf->is_secure) return; p = context; if (memcmp(cand->my_nonce, cand->peer_nonce, 32) < 0) { memcpy(p, cand->my_nonce, 32); memcpy(p + 32, cand->peer_nonce, 32); } else { memcpy(p, cand->peer_nonce, 32); memcpy(p + 32, cand->my_nonce, 32); } p += 64; if (le16toh(cand->my_lid) < le16toh(cand->peer_lid)) { memcpy(p, &cand->my_lid, 2); memcpy(p + 2, &cand->peer_lid, 2); } else { memcpy(p, &cand->peer_lid, 2); memcpy(p + 2, &cand->my_lid, 2); } p += 4; memcpy(p, akm_suite_selector, sizeof(akm_suite_selector)); p += sizeof(akm_suite_selector); if (memcmp(cand->my_mac, cand->peer_mac, ETH_ALEN) < 0) { memcpy(p, cand->my_mac, ETH_ALEN); memcpy(p + ETH_ALEN, cand->peer_mac, ETH_ALEN); } else { memcpy(p, cand->peer_mac, ETH_ALEN); memcpy(p + ETH_ALEN, cand->my_mac, ETH_ALEN); } p += 12; assert(p - context <= sizeof(context)); prf(cand->pmk, SHA256_DIGEST_LENGTH, (unsigned char *)"Temporal Key Derivation", strlen("Temporal Key Derivation"), context, sizeof(context), cand->mtk, 16 * 8); sae_hexdump(AMPE_DEBUG_KEYS, "mtk context: ", context, sizeof(context)); sae_hexdump(AMPE_DEBUG_KEYS, "mtk: ", cand->mtk, sizeof(cand->mtk)); }
int printf(const char * fmt, ...) { va_list ap; va_start(ap, fmt); if (bootArgs->Video.v_display == VGA_TEXT_MODE) { prf(fmt, ap, putchar, 0); } va_end(ap); return 0; }
void stop(const char * fmt, ...) { va_list ap; printf("\n"); va_start(ap, fmt); prf(fmt, ap, putchar, 0); va_end(ap); printf("\nThis is a non recoverable error! System HALTED!!!"); halt(); while (1); }
int main(void) { int N; double min, max; while(scf("%d", &N) != EOF) { min = N / log(N); max = 1.25506 * min; prf("%.1f %.1f\n", min, max); } return 0; }
void stop(const char * fmt, ...) { va_list ap; printf("\n"); va_start(ap, fmt); if (bootArgs->Video.v_display == VGA_TEXT_MODE) { prf(fmt, ap, putchar, 0); } else { vprf(fmt, ap); } va_end(ap); printf("\nThis is a non recoverable error! System HALTED!!!"); halt(); while (1); }
void gui_filterbar_c::do_tag_click(int lnk) { if ( lnk < BIT_count ) { // process buildin tags INVERTFLAG( bitags, (1<<lnk) ); prf().bitags( bitags ); } else { lnk -= BIT_count; contacts().toggle_tag(lnk); } refresh_list(); textrect.make_dirty(); getengine().redraw(); }
void active_protocol_c::set_autoconnect( bool v ) { auto w = syncdata.lock_write(); bool oldac = 0 != (w().data.options & active_protocol_data_s::O_AUTOCONNECT); if (oldac != v) { INITFLAG( w().data.options, active_protocol_data_s::O_AUTOCONNECT, v ); auto row = prf().get_table_active_protocol().find<true>(id); if (CHECK(row)) { INITFLAG(row->other.options, active_protocol_data_s::O_AUTOCONNECT, v); row->changed(); } } }