char *tostr(long l) { static char buf[26]; char *p; ltoa (l, buf, 10); p = strdup (buf); if (p == 0) { fprintf (stderr, "expr error: out of memory.\n"); exit (EXPR_OTHER_ERROR); } return p; }
/* SYNTAX: WINDOW LOG on|off|toggle [<filename>] */ static void cmd_window_log(const char *data) { LOG_REC *log; char *set, *fname, window[MAX_INT_STRLEN]; void *free_arg; int open_log, close_log; if (!cmd_get_params(data, &free_arg, 2, &set, &fname)) return; ltoa(window, active_win->refnum); log = logs_find_item(LOG_ITEM_WINDOW_REFNUM, window, NULL, NULL); open_log = close_log = FALSE; if (g_ascii_strcasecmp(set, "ON") == 0) open_log = TRUE; else if (g_ascii_strcasecmp(set, "OFF") == 0) { close_log = TRUE; } else if (g_ascii_strcasecmp(set, "TOGGLE") == 0) { open_log = log == NULL; close_log = log != NULL; } else { printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_NOT_TOGGLE); cmd_params_free(free_arg); return; } if (open_log && log == NULL) { /* irc.log.<windowname> or irc.log.Window<ref#> */ fname = *fname != '\0' ? g_strdup(fname) : g_strdup_printf("~/irc.log.%s%s", active_win->name != NULL ? active_win->name : "Window", active_win->name != NULL ? "" : window); log = log_create_rec(fname, MSGLEVEL_ALL); log->colorizer = log_colorizer_strip; log_item_add(log, LOG_ITEM_WINDOW_REFNUM, window, NULL); log_update(log); g_free(fname); } if (open_log && log != NULL) { log_start_logging(log); printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_LOG_OPENED, log->fname); } else if (close_log && log != NULL && log->handle != -1) { log_stop_logging(log); printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_LOG_CLOSED, log->fname); } cmd_params_free(free_arg); }
// Updates the display. void CHistogramDlg::set_histo_channel() { HWND hHisto, hTags; BOOL bInv, bMakeTotals; LPDWORD lpHisto; int i, j, iHisto; LONG sum; LONG lMaxEntry; LPDWORD lpdw; char szNum[40]; HWND hDlg = GetSafeHwnd(); bMakeTotals = (m_lpHistos[0] == NULL); lpHisto = get_histo(m_lpHistos, m_wChannel, &bInv, &iHisto); if (!lpHisto) return; // need to compute totals? if (bMakeTotals) { for (j=0;j<5;j++) { lpdw = m_lpHistos[j]; sum = 0L; for (i=0;i<256;i++) sum += *lpdw++; m_lTotals[j] = sum; } } // setup the histo control lMaxEntry = compute_yscale(lpHisto); hHisto = ::GetDlgItem(hDlg, IDC_HISTOGRAM); Histo_Init(hHisto, lpHisto, lMaxEntry, HISTOMARKS, bInv ? HTS_FLIPX:0); // reset marks based on tag hTags = ::GetDlgItem(hDlg, IDC_TAGS); i = Tag_GetMark(hTags,0); Histo_SetMark(hHisto, 0, i, NO); i = Tag_GetMark(hTags,1); Histo_SetMark(hHisto, 1, i, NO); // setup the gradient set_gradient(IDC_HISTO_GRAD, m_wChannel); // setup readouts ::SetDlgItemText(hDlg, IDC_HISTO_TOTAL, ltoa(m_lTotals[iHisto],szNum,10)); ::SetDlgItemText(hDlg, IDC_HISTO_POS, (LPSTR)""); ::SetDlgItemText(hDlg, IDC_HISTO_VALUE, (LPSTR)""); histo_set_HMSvalues(); }
void LongToStr(long lVal, char* strVal, unsigned size) { char buff[20] = ""; int nCopySize = 0; int nStrLen = 0; ltoa(lVal, buff, 10); nCopySize = strlen(buff) > 20 ? 20 : strlen(buff); nStrLen = nCopySize > size ? size : nCopySize; memcpy(strVal, buff, nStrLen); strVal[nStrLen] = '\0'; return; }
//--------------------------------------------------------------------------- // main() //--------------------------------------------------------------------------- void main(void) { char num [32] = {0}; uint32_t ADC_Raw_X[4],ADC_Raw_Y[4]; hardware_init(); // init hardware via Xware inituart(); delay(); delay(); while(1) // forever loop { ltoa(X,num); //UARTprintf(" The value of coordinate X = "); UARTprintf(num); UARTprintf("."); ltoa(Y,num); //UARTprintf(" The value of coordinate Y = "); UARTprintf(num); UARTprintf("\n"); ADCProcessorTrigger(ADC0_BASE, 1); ADCProcessorTrigger(ADC1_BASE, 1); while(!ADCIntStatus(ADC0_BASE, 1, false) && !ADCIntStatus(ADC1_BASE, 1, false)); { } ADCIntClear(ADC0_BASE, 1); ADCIntClear(ADC1_BASE, 1); ADCSequenceDataGet(ADC0_BASE, 1, ADC_Raw_Y); ADCSequenceDataGet(ADC1_BASE, 1, ADC_Raw_X); X = (ADC_Raw_X[0] + ADC_Raw_X[1] + ADC_Raw_X[2] + ADC_Raw_X[3])/4; Y = (ADC_Raw_Y[0] + ADC_Raw_Y[1] + ADC_Raw_Y[2] + ADC_Raw_Y[3])/4; SysCtlDelay(670000*3); } }
static void OutInt( uint width, uint min ) { //============================================== char *number; uint length; uint space; bool minus; intstar4 iorslt; if( UndefIntRtn( width ) ) return; iorslt = IORslt.intstar4; if( ( iorslt == 0 ) && ( min == 0 ) ) { SendChar( ' ', width ); } else { minus = ( iorslt < 0 ); number = IOCB->buffer; if( minus ) { number++; // skip the minus sign } ltoa( iorslt, IOCB->buffer, 10 ); length = strlen( number ); if( length > min ) { min = length; } if( min <= width ) { space = width - min; if( minus || ( IOCB->flags & IOF_PLUS ) ) { if( space != 0 ) { SendChar( ' ', space - 1 ); if( minus ) { Drop( '-' ); } else { Drop( '+' ); } SendChar( '0', min - length ); SendStr( number, length ); } else { SendChar( '*', width ); } } else { SendChar( ' ', space ); SendChar( '0', min - length ); SendStr( number, length ); } } else { SendChar( '*', width ); } } }
static void cmd_log_open(const char *data) { /* /LOG OPEN [-noopen] [-autoopen] [-targets <targets>] [-window] [-rotate hour|day|week|month] <fname> [<levels>] */ char *params, *args, *targetarg, *rotatearg, *fname, *levels; char window[MAX_INT_STRLEN]; LOG_REC *log; int level, rotate; args = "targets rotate"; params = cmd_get_params(data, 5 | PARAM_FLAG_MULTIARGS | PARAM_FLAG_GETREST, &args, &targetarg, &rotatearg, &fname, &levels); if (*fname == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); rotate = LOG_ROTATE_NEVER; if (stristr(args, "-rotate")) { rotate = log_str2rotate(rotatearg); if (rotate < 0) rotate = LOG_ROTATE_NEVER; } level = level2bits(levels); if (level == 0) level = MSGLEVEL_ALL; if (stristr(args, "-window")) { /* log by window ref# */ ltoa(window, active_win->refnum); targetarg = window; } log = log_create_rec(fname, level, targetarg); if (log != NULL) { if (stristr(args, "-autoopen")) log->autoopen = TRUE; log->rotate = rotate; log_update(log); if (log->handle == -1 && stristr(args, "-noopen") == NULL) { /* start logging */ if (log_start_logging(log)) { printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_LOG_OPENED, fname); } else { log_close(log); } } } g_free(params); }
void WdeSetEditWithSINT32( int_32 val, int base, HWND hDlg, int id ) { char temp[35]; ltoa( val, temp, base ); if( base == 16 ) { memmove( temp + 2, temp, 33 ); temp[0] = '0'; temp[1] = 'x'; } else if( base == 8 ) { memmove( temp + 1, temp, 34 ); temp[0] = '0'; } WdeSetEditWithStr( temp, hDlg, id ); }
void signal_process (int sig) { if(sig != SIGALRM){ exit(10); } long offset = ftell(xlogFp); char offsetStr[50]; ltoa(offset, offsetStr, 10); if ( offset != -1 ) { xFile(offset_log, offsetStr, 1); } if (xlogFp) { signal(SIGALRM, signal_process); alarm(1); } }
void CGT_CDiagMsg::intErr( const CG_Edipos* pEdp, const TCHAR* pszCompilerFile, int nLine, const TCHAR* pszReason ) { TCHAR buffer[64]; const TCHAR* ppsz[3]; ppsz[0] = pszCompilerFile ? pszCompilerFile : _T("??"); ppsz[1] = ltoa(nLine, buffer, 10); ppsz[2] = pszReason ? pszReason : _T("??"); msg(CG_E_INTERNAL, pEdp, ppsz); }
static void cmd_window_log(const char *data) { /* /WINDOW LOG ON|OFF|TOGGLE [<filename>] */ LOG_REC *log; char *params, *set, *fname, window[MAX_INT_STRLEN]; int open_log, close_log; params = cmd_get_params(data, 2, &set, &fname); ltoa(window, active_win->refnum); log = log_find_item(window); open_log = close_log = FALSE; if (g_strcasecmp(set, "ON") == 0) open_log = TRUE; else if (g_strcasecmp(set, "OFF") == 0) { close_log = TRUE; } else if (g_strcasecmp(set, "TOGGLE") == 0) { open_log = log == NULL; close_log = log != NULL; } else { printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_NOT_TOGGLE); g_free(params); return; } if (open_log && log == NULL) { /* irc.log.<windowname> or irc.log.Window<ref#> */ fname = *fname != '\0' ? g_strdup(fname) : g_strdup_printf("~/irc.log.%s%s", active_win->name != NULL ? active_win->name : "Window", active_win->name != NULL ? "" : window); log = log_create_rec(fname, MSGLEVEL_ALL, window); if (log != NULL) log_update(log); g_free(fname); } if (open_log && log != NULL) { log_start_logging(log); printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_LOG_OPENED, log->fname); } else if (close_log && log != NULL && log->handle != -1) { log_stop_logging(log); printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_LOG_CLOSED, log->fname); } g_free(params); }
void InitCOMscopeBufferSize(HWND hwndDlg,ULONG ulBuffLen,int iResDevider) { USHORT usCount; SLDCDATA SliderData; WNDPARAMS wprm; CHAR acBuffer[10]; int iExtent = 249; if (iResDevider == 2) iExtent = 125; SliderData.cbSize = sizeof(SLDCDATA); SliderData.usScale1Increments = iExtent; SliderData.usScale1Spacing = 1; SliderData.usScale2Increments = iExtent; // 249 SliderData.usScale2Spacing = 1; wprm.fsStatus = WPM_CTLDATA; wprm.cchText = 0; wprm.cbPresParams = 0; wprm.cbCtlData = 0; wprm.pCtlData = &SliderData; WinSendDlgItemMsg(hwndDlg,PCFG_BUFF_SLIDER, WM_SETWINDOWPARAMS,(MPARAM)&wprm,(MPARAM)NULL ) ; WinSendDlgItemMsg(hwndDlg,PCFG_BUFF_SLIDER,SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE),MPFROMSHORT((ulBuffLen / 128 / iResDevider) - (8 / iResDevider))); WinSendDlgItemMsg(hwndDlg,PCFG_BUFF_SLIDER, SLM_SETTICKSIZE,MPFROM2SHORT(0,5),NULL); WinSendDlgItemMsg(hwndDlg,PCFG_BUFF_SLIDER,SLM_SETSCALETEXT, MPFROMSHORT(0), MPFROMP("1k")); for (usCount = 1; usCount < 4; usCount++ ) { WinSendDlgItemMsg(hwndDlg,PCFG_BUFF_SLIDER, SLM_SETTICKSIZE,MPFROM2SHORT(((usCount * 64 / iResDevider) - (8 / iResDevider)),5),NULL); sprintf(acBuffer,"%uK",(usCount * 8)); WinSendDlgItemMsg(hwndDlg,PCFG_BUFF_SLIDER,SLM_SETSCALETEXT, MPFROMSHORT(((usCount * 64 / iResDevider) - (8 / iResDevider))), MPFROMP(acBuffer)); } WinSendDlgItemMsg(hwndDlg,PCFG_BUFF_SLIDER, SLM_SETTICKSIZE,MPFROM2SHORT((iExtent - 1),5),NULL); WinSendDlgItemMsg(hwndDlg,PCFG_BUFF_SLIDER,SLM_SETSCALETEXT, MPFROMSHORT(iExtent - 1), MPFROMP("32K")); WinSetDlgItemText(hwndDlg,PCFG_BUFF_DATA, ltoa(ulBuffLen,acBuffer,10)); }
char *get_all_fset(void) { int i; char *ret = NULL; IrcVariable *ptr; FsetNumber *tmp = numeric_fset; for (i = 0; i < NUMBER_OF_FSET; i++) m_s3cat(&ret, space, fset_array[i].name); for (i = 0; i < ext_fset_list.max; i++) { ptr = ext_fset_list.list[i]; m_s3cat(&ret, space, ptr->name); } for (tmp = numeric_fset; tmp; tmp = tmp->next) m_s3cat(&ret, space, ltoa(tmp->numeric)); return ret; }
static void log_single_line(WINDOW_REC *window, const char *server_tag, const char *target, int level, const char *text) { char windownum[MAX_INT_STRLEN]; LOG_REC *log; if (window != NULL) { /* save to log created with /WINDOW LOG */ ltoa(windownum, window->refnum); log = logs_find_item(LOG_ITEM_WINDOW_REFNUM, windownum, NULL, NULL); if (log != NULL) log_write_rec(log, text, level); } log_file_write(server_tag, target, level, text, FALSE); }
/* SYNTAX: WINDOW SIZE <lines> */ static void cmd_window_size(const char *data) { char sizestr[MAX_INT_STRLEN]; int size; if (!is_numeric(data, 0)) return; size = atoi(data); size -= WINDOW_GUI(active_win)->parent->lines; if (size == 0) return; ltoa(sizestr, size < 0 ? -size : size); if (size < 0) cmd_window_shrink(sizestr); else cmd_window_grow(sizestr); }
bool WSetEditWithSINT32( HWND edit, int_32 val, int base ) { char temp[35]; ltoa( val, temp, base ); if( base == 16 ) { memmove( temp + 2, temp, 33 ); temp[0] = '0'; temp[1] = 'x'; } else if( base == 8 ) { memmove( temp + 1, temp, 34 ); temp[0] = '0'; } return( WSetEditWithStr( edit, temp ) ); }
void JabberGetAvatarFileName( HANDLE hContact, char* pszDest, int cbLen ) { JCallService( MS_DB_GETPROFILEPATH, cbLen, LPARAM( pszDest )); int tPathLen = strlen( pszDest ); tPathLen += mir_snprintf( pszDest + tPathLen, MAX_PATH - tPathLen, "\\Jabber\\" ); CreateDirectoryA( pszDest, NULL ); char* szFileType; switch( JGetByte( hContact, "AvatarType", PA_FORMAT_PNG )) { case PA_FORMAT_JPEG: szFileType = "jpg"; break; case PA_FORMAT_GIF: szFileType = "gif"; break; case PA_FORMAT_BMP: szFileType = "bmp"; break; case PA_FORMAT_PNG: szFileType = "png"; break; default: szFileType = "bin"; } if ( hContact != NULL ) { char str[ 256 ]; DBVARIANT dbv; if ( !JGetStringUtf( hContact, "jid", &dbv )) { strncpy( str, dbv.pszVal, sizeof str ); str[ sizeof(str)-1 ] = 0; JFreeVariant( &dbv ); } else ltoa(( long )hContact, str, 10 ); char* hash = JabberSha1( str ); mir_snprintf( pszDest + tPathLen, MAX_PATH - tPathLen, "%s.%s", hash, szFileType ); mir_free( hash ); } else if ( jabberThreadInfo != NULL ) { mir_snprintf( pszDest + tPathLen, MAX_PATH - tPathLen, TCHAR_STR_PARAM"@%s avatar.%s", jabberThreadInfo->username, jabberThreadInfo->server, szFileType ); } else { DBVARIANT dbv1, dbv2; BOOL res1 = DBGetContactSetting( NULL, jabberProtoName, "LoginName", &dbv1 ); BOOL res2 = DBGetContactSetting( NULL, jabberProtoName, "LoginServer", &dbv2 ); mir_snprintf( pszDest + tPathLen, MAX_PATH - tPathLen, "%s@%s avatar.%s", res1 ? "noname" : dbv1.pszVal, res2 ? jabberProtoName : dbv2.pszVal, szFileType ); if (!res1) JFreeVariant( &dbv1 ); if (!res2) JFreeVariant( &dbv2 ); } }
void testListingFiles(){ RuntimeErrorValidator * validator = buildErrorSuccessValidator(); List l = getAllFiles("VDA1", validator); if(hasError(validator)){ error(validator->errorDescription); return ; } Iterator * ite = buildIterator(l); char * element = NULL; while( hasMoreElements(ite)){ element = next(ite); info( concatAll(4, "Archivo: " , element , " con tamaño: " , ltoa(getCurrentFileSize("VDA1" , element , validator)))); } }
void DeviceConnection::send(Command cmd, bool complete){ if(!conn || processing) return; long values[] = {cmd.type, cmd.id, cmd.deviceID, cmd.value}; conn->write(START_BIT); char vbuffer[3]; for (int i = 0; i < 4; ++i) { ltoa(values[i], vbuffer, 10); conn->write(vbuffer); if(complete && i == 3){ conn->write(ACK_BIT); }else{ conn->write(SEPARATOR); } } }
void start_new_file(FILE *f) { struct lpc_predef_s *tmpf; free_defines(); add_define("_FUNCTION", -1, ""); add_define("LPC4", -1, ""); /* Tell coders this is LPC ver 4.0 */ add_define("CD_DRIVER", -1, ""); #ifdef DEBUG add_define("DEBUG_DRIVER", -1, ""); #endif add_define("T_INTEGER" , -1, ltoa(T_NUMBER)); add_define("T_FLOAT" , -1, ltoa(T_FLOAT)); add_define("T_STRING" , -1, ltoa(T_STRING)); add_define("T_OBJECT" , -1, ltoa(T_OBJECT)); add_define("T_FUNCTION", -1, ltoa(T_FUNCTION)); add_define("T_ARRAY" , -1, ltoa(T_POINTER)); add_define("T_MAPPING" , -1, ltoa(T_MAPPING)); for (tmpf = lpc_predefs; tmpf; tmpf = tmpf->next) { char namebuf[NSIZE]; char mtext[MLEN]; *mtext='\0'; (void)sscanf(tmpf->flag, "%[^=]=%[ -~=]", namebuf, mtext); if (strlen(namebuf) >= NSIZE) fatal("NSIZE exceeded\n"); if (strlen(mtext) >= MLEN) fatal("MLEN exceeded\n"); add_define(namebuf,-1,mtext); } keep1.token = keep2.token = keep3.token = -47; yyin = f; slast = '\n'; lastchar = '\n'; inctop = 0; /* If not here, where? */ num_incfiles = 0; current_incfile = 0; current_line = 1; lex_fatal = 0; incdepth = 0; nbuf = 0; outp = defbuf+DEFMAX; pragma_strict_types = 0; pragma_no_inherit = pragma_no_clone = pragma_no_shadow = pragma_resident = 0; nexpands = 0; }
static void draw_activity(gchar *title, gboolean act, gboolean det) { WINDOW_REC *window; GList *tmp; gchar str[MAX_INT_STRLEN]; gboolean first, is_det; set_color(stdscr, sbar_color_normal); addstr(title); first = TRUE; for (tmp = activity_list; tmp != NULL; tmp = tmp->next) { window = tmp->data; is_det = window->new_data >= NEWDATA_HILIGHT; if (is_det && !det) continue; if (!is_det && !act) continue; if (first) first = FALSE; else { set_color(stdscr, sbar_color_dim); addch(','); } ltoa(str, window->refnum); switch (window->new_data) { case NEWDATA_TEXT: set_color(stdscr, sbar_color_dim); break; case NEWDATA_MSG: set_color(stdscr, sbar_color_bold); break; case NEWDATA_HILIGHT: if (window->last_color > 0) set_color(stdscr, sbar_color_background | mirc_colors[window->last_color]); else set_color(stdscr, sbar_color_act_highlight); break; } addstr(str); } }
void LcdStateRunning::drawKwhStats() { Settings settings; EepromSettings::load(settings); lcd.setBacklight(LCD16x2::WHITE); lcd.move(0,0); lcd.write_P(STR_STATS_KWH); lcd.move(0,1); uint16_t *p = 0; switch (page) { case PAGE_KWH_WEEK: lcd.write_P(STR_STATS_WEEK); p = &settings.kwh_week; break; case PAGE_KWH_MONTH: lcd.write_P(STR_STATS_MONTH); p = &settings.kwh_month; break; case PAGE_KWH_YEAR: lcd.write_P(STR_STATS_YEAR); p = &settings.kwh_year; break; case PAGE_KWH_TOTAL: lcd.write_P(STR_STATS_TOTAL); p = &settings.kwh_total; break; default: break; } char buffer[10] = {0}; ltoa(p ? *p : 0, buffer, 10); lcd.write(": "); lcd.write(buffer); spaces(lcd, 5); }
BOOL CDialog_Check::OnInitDialog() { CDialog::OnInitDialog(); if(m_checkModal) { SetWindowText(_T("入库")); } else { SetWindowText(_T("出库")); } InitComobox(); if(!m_date.GetId().empty()) { m_date.m_material = m_allMaterial.at(m_mName_ctrl.GetCurSel()); int index = 0; for (index = 0; index < m_allMaterial.size();index ++) if (m_allMaterial[index].GetId() == m_date.GetId()) break; m_mName_ctrl.SetCurSel(index); char cTmp[20] ={0}; itoa(m_date.m_num,cTmp,10); m_mNum_ctrl.SetWindowText(m_dateChange.stringToCstring(string(cTmp))); memset(cTmp,0,20); ltoa(m_date.m_total,cTmp,10); m_total_ctrl.SetWindowText(m_dateChange.stringToCstring(string(cTmp))); for(index = 0;index<m_allClass.size();index ++) if(m_allClass[index].GetId() == m_date.m_class.GetId()) break; m_cName_ctrl.SetCurSel(index); m_wName_ctrl.SetWindowText(m_date.m_operateWare); for (index = 0;index <m_allUser.size();index ++) if (m_allUser[index].GetId() == m_date.m_userInfo.GetId()) break; m_pName_ctrl.SetCurSel(index); m_telPhone_ctrl.SetWindowText(m_date.m_tellPhone); m_detail_ctrl.SetWindowText(m_date.m_detail); } m_wName_ctrl.SetWindowText(CControl_bace::s_wareHouse.m_aname); return TRUE; }
void GPIO_ISR(void) { //digitalWrite(1,0,1); if (US_ECHO_Data_ADDR & US_ECHO_MASK) { Timer16UsEcho_WritePeriod(46400); Timer16UsEcho_Start(); // Used to measure time until echo signal is returned start++; } else { usRawTimerValue = Timer16UsEcho_wReadTimer(); Timer16UsEcho_Stop(); ltoa(lcdBuffer[0], usRawTimerValue, 10); stop++; } gpioTick = true; isrclear = PRT1DR; }
// Aus einer 2byte-Binärzahl einen base-36 Seriennummernstring machen char *wordtoserno(word Binaer) { char SerNStr[4]; static char Seriennummer[4]; int i,l; // limitation if (Binaer > 46655L) Binaer = 46655L; ltoa(Binaer,SerNStr,36); sprintf(Seriennummer,"%3s",SerNStr); strupr(Seriennummer); // generate leading zeroes l = strlen(Seriennummer); for (i=0; i<l; i++) { if (Seriennummer[i] == ' ') Seriennummer[i] = '0'; }; return Seriennummer; }
string CTranscription::duodec2dec(string val) { long i, n, digit; string res; n=0; for(i=val.size()-1;i>=0;i--) { if((val[i]>='0')&&(val[i]<='9')) digit=val[i]-'0'; else digit=val[i]-'a'+10; n+=digit*(int)pow((float)12, (int)(val.size()-i-1)); } res=ltoa(n); return res; }
void AlarmEnable(int idx, int enable) { Schedule* alarm; if(idx < 0 || idx >= m_maxAlarm) return; ltoa(idx+1, (g_alarmkey+ALARMKEY_OFFSET), 10); if(enable < 0) { int status = api.GetInt(g_alarmkey, "Alarm", 0); if(enable == -1) { enable = !status; goto update_and_continue; } enable = status; alarm = NULL; } else { update_and_continue: api.SetInt(g_alarmkey, "Alarm", enable); alarm = TimetableSearchID(idx); } if(!enable) { if(alarm) { TimetableQueue(alarm, 0); free(alarm); } return; } if(!alarm) { alarm = (Schedule*)malloc(sizeof(Schedule)); if(!alarm) return; alarm->time = AlarmNextTimestamp(); alarm->id = idx; /// @note : on next backward incompatible change, store a single value including every "flag" alarm->data = 0; if(api.GetInt(g_alarmkey,"Alarm",0)) alarm->data |= ALRM_ENABLED; if(api.GetInt(g_alarmkey,"Once",0)) alarm->data |= ALRM_ONESHOT; if(api.GetInt(g_alarmkey,"12h",0)) alarm->data |= ALRM_12H; if(api.GetInt(g_alarmkey,"ChimeHr",0)) alarm->data |= ALRM_CHIMEHR; if(api.GetInt(g_alarmkey,"Repeat",0)) alarm->data |= ALRM_REPEAT; if(api.GetInt(g_alarmkey,"Blink",0)) alarm->data |= ALRM_BLINK; if(api.GetInt(g_alarmkey,"jrMsgUsed",0)) alarm->data |= ALRM_DIALOG; TimetableQueue(alarm, 1); } }
static bool parseFortranId( WString &str, unsigned j, char *help ) { char groupid[2]; char num[50]; char *table; unsigned id; unsigned i; bool ret; ret = TRUE; if( isalpha( str[j] ) && isalpha( str[j+1] ) && str[j+2] == '-' ) { groupid[0] = str[j]; groupid[1] = str[j+1]; j += 3; } else { ret = FALSE; } if( !isdigit( str[j] ) ) ret = FALSE; if( ret ) { i=0; while( isdigit( str[j] ) ) { num[i] = str[j]; j++; i++; } num[i] = '\0'; id = GROUP_INCREMENT; table = fortranGrpCodes; for( ;; ) { if( table[0] == '\0' && table[1] == '\0' ) { ret = FALSE; break; } if( groupid[0] == table[0] && groupid[1] == table[1] ) { id += atoi( num ); ltoa( id, help, 10 ); break; } id += GROUP_INCREMENT; table += 2; } } return( ret ); }
/* redraw activity */ static void statusbar_activity(SBAR_ITEM_REC *item, int ypos) { WINDOW_REC *window; GList *tmp; gchar str[MAX_INT_STRLEN]; int size_needed; gboolean act, det; size_needed = 0; act = det = FALSE; for (tmp = activity_list; tmp != NULL; tmp = tmp->next) { window = tmp->data; size_needed += 1+ltoa(str, window->refnum); if (!use_colors && window->new_data == NEWDATA_MSG_FORYOU) det = TRUE; else act = TRUE; } if (act) size_needed += 6; /* [Act: ], -1 */ if (det) size_needed += 6; /* [Det: ], -1 */ if (act && det) size_needed--; if (item->size != size_needed) { /* we need more (or less..) space! */ statusbar_item_resize(item, size_needed); return; } if (item->size == 0) return; move(ypos, item->xpos); set_color((1 << 4)+3); addch('['); if (act) draw_activity("Act: ", TRUE, !det); if (act && det) addch(' '); if (det) draw_activity("Det: ", FALSE, TRUE); set_color((1 << 4)+3); addch(']'); screen_refresh(); }
static Logfile * logfile_list (Logfile *log, char **args) { Logfile *l; char *targets = NULL; say("Logfiles:"); for (l = logfiles; l; l = l->next) { targets = logfile_get_targets(l); say("Log %2d [%s] logging %s is %s, file %s server %s targets %s", l->refnum, l->name, logtype[l->type], onoff[l->active], l->filename ? l->filename : "<NONE>", l->servref == NOSERV ? "ALL" : ltoa(l->servref), targets ? targets : "<NONE>"); new_free(&targets); } return log; }