char *ft_s_itoa(int nb) { int div; char *ret; int len; int i; i = 0; len = calc_len(nb); div = calc_div(len); ret = ft_strnew(len + 1); if (nb < 0) { ret[i] = '-'; nb *= -1; i++; } else if (nb == 0) return ("0"); while (len--) { ret[i] = ((nb / div) + 48); nb -= ((nb / div) * div); div /= 10; i++; } return (ret); }
void aff_tty(char **tab, int len) { int len_total; int len_total_divided; int *tab_space; int *most_space_tab; int divid; t_ws col_len; len_total = calc_len(tab, len); tab_space = calc_tab_space(tab, len); divid = 1; most_space_tab = find_most_len(tab_space, divid, len); len_total_divided = sum_space(most_space_tab, len / divid); xioctl(0, TIOCGWINSZ, &col_len); while (len_total_divided >= col_len.ws_col) { free(most_space_tab); divid++; most_space_tab = find_most_len(tab_space, divid, len); len_total_divided = sum_space(most_space_tab, len / divid); } aff_divided(tab, divid, len, most_space_tab); free(most_space_tab); free(tab_space); free_argv(tab); }
// --------------------------------------------------------------------------- // // ----------- void bToolLength::clic(CGPoint pt, int count){ if(count>1){ clearTempPathContext(true); validTempPathContext(); _len=0; } bStdToolNav::clic(pt,count); if(count==1){ calc_len(); report_len(); } }
static void list_scan(prop_dictionary_t env) { u_int8_t buf[64*1024 - 1]; struct ieee80211req ireq; char ssid[IEEE80211_NWID_LEN+1]; const u_int8_t *cp; int len, ssidmax; const struct ieee80211req_scan_result *sr; memset(&ireq, 0, sizeof(ireq)); ireq.i_type = IEEE80211_IOC_SCAN_RESULTS; ireq.i_data = buf; ireq.i_len = sizeof(buf); if (direct_ioctl(env, SIOCG80211, &ireq) < 0) errx(EXIT_FAILURE, "unable to get scan results"); len = ireq.i_len; if (len < (int)sizeof(*sr)) return; ssidmax = calc_len(buf, len); printf("%-*.*s %-17.17s %4s %4s %-7s %3s %4s\n" , ssidmax, ssidmax, "SSID" , "BSSID" , "CHAN" , "RATE" , "S:N" , "INT" , "CAPS" ); cp = buf; while (len >= (int)sizeof(*sr)) { const uint8_t *vp; sr = (const struct ieee80211req_scan_result *) cp; vp = (const u_int8_t *)(sr+1); (void)copy_essid(ssid, sizeof(ssid), vp, sr->isr_ssid_len); printf("%-*.*s %s %3d %3dM %3d:%-3d %3d %-4.4s" , ssidmax, ssidmax, ssid , ether_ntoa((const struct ether_addr *) sr->isr_bssid) , ieee80211_mhz2ieee(sr->isr_freq, sr->isr_flags) , getmaxrate(sr->isr_rates, sr->isr_nrates) , sr->isr_rssi, sr->isr_noise , sr->isr_intval , getcaps(sr->isr_capinfo) ); printies(vp + sr->isr_ssid_len, sr->isr_ie_len, 24); printf("\n"); cp += sr->isr_len, len -= sr->isr_len; } }
// --------------------------------------------------------------------------- // // ----------- bool bToolLength::set_key(int k){ bool b=false; switch(k){ case kEnterCharCode: case kReturnCharCode: action(0); (void)bStdToolNav::set_key(k); clearTempPathContext(true); validTempPathContext(); k=0; WriteMessage(_gapp,""); b=true; break; case kEscapeCharCode: (void)bStdToolNav::set_key(k); clearTempPathContext(true); validTempPathContext(); k=0; WriteMessage(_gapp,""); b=true; break; case kBackspaceCharCode: if(get_locs()->count()<2){ break; } (void)bStdToolNav::set_key(k); clearTempPathContext(true); track_draw(); validTempPathContext(); k=0; calc_len(); report_len(); break; } (void)bStdToolNav::set_key(k); return(b); }
constexpr size_t length() const noexcept { return calc_len(_data); }