/******************************************************************************* * Zobrazeni casu na displeji *******************************************************************************/ int display_idle() { long microseconds, milliseconds, seconds, minutes, hours; char buf[20]; if (isrunning) t = get_time(); microseconds = (long)(((float)(t - t0))*TIMER_TICK); milliseconds = (long)(microseconds / 1000) % 1000; seconds = (((long)(microseconds / 1000) - milliseconds) / 1000) % 60; minutes = (((((long)(microseconds / 1000) - milliseconds) / 1000) - seconds) / 60) % 60; hours = ((((((long)(microseconds / 1000) - milliseconds) / 1000) - seconds) / 60) - minutes) / 60; if (hours < 10) { buf[0] = '0'; long2str(hours, &buf[1], 10); } else { long2str(hours, &buf[0], 10); } buf[2] = ':'; if (minutes < 10) { buf[3] = '0'; long2str(minutes, &buf[4], 10); } else { long2str(minutes, &buf[3], 10); } buf[5] = ':'; if (seconds < 10) { buf[6] = '0'; long2str(seconds, &buf[7], 10); } else { long2str(seconds, &buf[6], 10); } buf[8] = '.'; if (milliseconds < 10) { buf[9] = '0'; buf[10] = '0'; long2str(milliseconds, &buf[11], 10); } else if (milliseconds < 100) { buf[9] = '0'; long2str(milliseconds, &buf[10], 10); } else { long2str(milliseconds, &buf[9], 10); } buf[12] = '\0'; LCD_clear(); LCD_append_string(buf); return 0; }
wung_string * convert2str(wval *op) { switch (W_TYPE_P(op)) { case IS_LONG: return long2str(op->value.lval); case IS_STRING: return op->value.str; } return wung_string_init("error wnode!", sizeof("error wnode!")); }
int ini_putl_OpenedFile( const TCHAR *Section, const TCHAR *Key, long Value, INI_FILETYPE* pFileRead, INI_FILETYPE* pFileWrite ) { TCHAR LocalBuffer[32]; long2str(Value, LocalBuffer); return ini_puts_OpenedFile(Section, Key, LocalBuffer, pFileRead, pFileWrite); }
/* * try_set_attr * * if attribute exists and it's value is empty, set * new value and update tag-attribute-string */ static VOID try_setattr(HSCPRC * hp, HSCVAR * attr, ULONG value) { if (attr) { STRPTR old_value = get_vartext(attr); STRPTR new_value = long2str(value); if (!old_value) { /* set new value */ set_vartext(attr, new_value); /* append attribute name and "=" */ app_estr(hp->tag_attr_str, " "); app_estr(hp->tag_attr_str, attr->name); app_estr(hp->tag_attr_str, "="); /* append quotes and value */ if ((hp->quotemode == QMODE_KEEP) || (hp->quotemode == QMODE_DOUBLE)) app_estrch(hp->tag_attr_str, '\"'); else if (hp->quotemode == QMODE_SINGLE) app_estrch(hp->tag_attr_str, '\''); app_estr(hp->tag_attr_str, long2str(value)); /* append value */ if ((hp->quotemode == QMODE_KEEP) || (hp->quotemode == QMODE_DOUBLE)) app_estrch(hp->tag_attr_str, '\"'); else if (hp->quotemode == QMODE_SINGLE) app_estrch(hp->tag_attr_str, '\''); } else { /* validate old value */ if (strcmp(old_value, new_value)) { hsc_message(hp, MSG_UNEX_ATTR_VALUE, "unexpected value for %A: expected %q, found %q", attr, new_value, old_value); } } } }
/* * try_set_attr * * if attribute exists and it's value is empty, set * new value and update tag-attribute-string */ static VOID try_setattr(HSCPRC * hp, HSCVAR * attr, ULONG value) { if (attr && !get_vartext(attr)) { set_vartext(attr, long2str(value)); /* append attribute name and "=" */ app_estr(hp->tag_attr_str, " "); app_estr(hp->tag_attr_str, attr->name); app_estr(hp->tag_attr_str, "="); /* append quotes and value */ if ((hp->quotemode == QMODE_KEEP) || (hp->quotemode == QMODE_DOUBLE)) app_estrch(hp->tag_attr_str, '\"'); else if (hp->quotemode == QMODE_SINGLE) app_estrch(hp->tag_attr_str, '\''); app_estr(hp->tag_attr_str, long2str(value)); /* append value */ if ((hp->quotemode == QMODE_KEEP) || (hp->quotemode == QMODE_DOUBLE)) app_estrch(hp->tag_attr_str, '\"'); else if (hp->quotemode == QMODE_SINGLE) app_estrch(hp->tag_attr_str, '\''); } }
/* * status_file_and_line * * copy status message for current file & line * processing into status_buf[] * * NOTE: messages >79 chars are truncated */ static VOID status_file_and_line(HSCPRC * hp) { STRPTR filename = hsc_get_file_name(hp); if (filename) { /* create status-string */ /* NOTE: this is not done via sprintf(), because * no check for a too long string would be done */ strncpy(status_buf, filename, MAX_STATUSLEN); strncat(status_buf, " (", MAX_STATUSLEN - strlen(status_buf)); strncat(status_buf, long2str(hsc_get_file_line(hp)), MAX_STATUSLEN - strlen(status_buf)); strncat(status_buf, ")", MAX_STATUSLEN - strlen(status_buf)); } else { strcpy(status_buf, ""); } status_msg(status_buf); }
/* ** handle_hsc_exec ** ** exec a sub file */ BOOL handle_hsc_exec( INFILE *inpf, HSCTAG *tag ) { STRPTR cmd = get_vartext( tag->attr, "COMMAND" ); if ( cmd ) { int result; EXPSTR *msg = init_estr( 0 ); if ( msg && app_estr( msg, "execute: " ) && app_estr( msg, cmd ) ) { /* status message */ status_msg( estr2str( msg ) ); if ( verbose ) status_lf(); /* call command */ result = system( cmd ); /* check for non-zero-result */ if ( result ) { message( MSG_SYSTEM_RETURN, inpf ); errstr( "Calling external command returned " ); errstr( long2str( (LONG) result ) ); errlf(); } } else err_mem( inpf ); del_estr( msg ); } return (TRUE); }
/** ini_putl() * \param Section the name of the section to write the value in * \param Key the name of the entry to write * \param Value the value to write * \param Filename the name and full path of the .ini file to write to * * \return 1 if successful, otherwise 0 */ int ini_putl(const TCHAR *Section, const TCHAR *Key, long Value, const TCHAR *Filename) { TCHAR LocalBuffer[32]; long2str(Value, LocalBuffer); return ini_puts(Section, Key, LocalBuffer, Filename); }
/** ini_putl() * \param Section the name of the section to write the value in * \param Key the name of the entry to write, or NULL to erase all keys in the section * \param Value the value to write * \param Filename the name and full path of the .ini file to write to * * \return 1 if successful, otherwise 0 */ int ini_putl(const TCHAR *Section, const TCHAR *Key, long Value, const TCHAR *Filename) { TCHAR str[32]; long2str(Value, str); return ini_puts(Section, Key, str, Filename); }
/** ini_putl() * \param Section the name of the section to write the value in * \param Key the name of the entry to write * \param Value the value to write * \param Filename the name and full path of the .ini file to write to * * \return 1 if successful, otherwise 0 */ int ini_putl(const TCHAR *Section, const TCHAR *Key, long Value, const TCHAR *Filename) { TCHAR buff[32]; long2str(Value, buff); return ini_puts(Section, Key, buff, Filename); }
/** ini_putl() * \param Section the name of the section to write the value in * \param Key the name of the entry to write * \param Value the value to write * \param Filename the name and full path of the .ini file to write to * * \return 1 if successful, otherwise 0 */ int ini_putl(const char *Section, const char *Key, long Value, const char *Filename) { char LocalBuffer[32]; long2str(Value, LocalBuffer); return ini_puts(Section, Key, LocalBuffer, Filename); }
VOID hsc_message(HSCPRC * hp, HSCMSG_ID msg_id, const char *format,...) { HSCMSG_CLASS msg_class = hsc_get_msg_class(hp, msg_id); HSCMSG_ID msg_id_unmasked = msg_id & MASK_MESSAGE; INFILE *msg_inpf = NULL; STRPTR msg_fname = "unknown"; ULONG msg_x = 0; ULONG msg_y = 0; BOOL disp_msg = really_display_message(hp, msg_id); /* display message? */ if (disp_msg) { va_list ap; /* increase message-counter */ hp->msg_count++; /* set fatal-flag, if this is a fatal message */ if (msg_id > MSG_FATAL) { hp->fatal = TRUE; } /* clear message buffer */ clr_estr(hp->curr_msg); /* create message string */ va_start(ap, format); while (format[0]) { if (format[0] == '%') { STRPTR s = NULL; HSCTAG *tag = NULL; HSCTAG *lazy = NULL; HSCATTR *attr = NULL; HSCENT *ent = NULL; format++; switch (format[0]) { case 'd': /* * append decimal number */ app_estr(hp->curr_msg, long2str(va_arg(ap, LONG))); break; case 'q': /* * append quoted string */ s = va_arg(ap, STRPTR); app_estrch(hp->curr_msg, '`'); while (s[0]) { switch (s[0]) { case '\n': app_estr(hp->curr_msg, "\\n"); break; case '\"': app_estr(hp->curr_msg, "\\\""); break; default: if (s[0] < ' ') { app_estrch(hp->curr_msg, '\\'); app_estr(hp->curr_msg, long2str((LONG) s[0])); app_estrch(hp->curr_msg, ';'); } else app_estrch(hp->curr_msg, s[0]); } s++; /* process next char */ } app_estrch(hp->curr_msg, '\''); break; case 's': /* * append simple string */ app_estr(hp->curr_msg, va_arg(ap, STRPTR)); break; case 'T': /* append tag-pointer */ tag = va_arg(ap, HSCTAG *); msg_tag(hp->curr_msg, tag->name); break; case 't': /* append tag */ msg_tag(hp->curr_msg, va_arg(ap, STRPTR)); break; case 'C': /* append end tag-pointer */ tag = va_arg(ap, HSCTAG *); msg_endtag(hp->curr_msg, tag->name); break; case 'c': /* append end tag */ msg_endtag(hp->curr_msg, va_arg(ap, STRPTR)); break; case 'A': /* append attribute-pointer */ attr = va_arg(ap, HSCATTR *); msg_attr(hp->curr_msg, attr->name); break; case 'a': /* append attribute */ msg_attr(hp->curr_msg, va_arg(ap, STRPTR)); break; case 'E': /* append entity-pointer */ ent = va_arg(ap, HSCENT *); msg_entity(hp->curr_msg, ent->name); break; case 'e': /* append entity */ msg_entity(hp->curr_msg, va_arg(ap, STRPTR)); break; case 'i': /* append ID */ msg_idname(hp->curr_msg, va_arg(ap, STRPTR)); break; case 'j': /* append jerk/prostitute */ if (hp->prostitute) { app_estr(hp->curr_msg, "prostitutes"); } else { app_estr(hp->curr_msg, "jerks"); } break; case 'L': /* append var-list-pointer */ lazy = va_arg(ap, HSCTAG *); msg_lazy(hp->curr_msg, lazy->name); break; case 'l': /* append var-list */ msg_lazy(hp->curr_msg, va_arg(ap, STRPTR)); break; default: /* * append unknown */ app_estrch(hp->curr_msg, '%'); if (format[0] && (format[0] != '%')) { app_estrch(hp->curr_msg, '%'); format--; } break; } } else { app_estrch(hp->curr_msg, format[0]); } if (format[0]) { format++; } }
char* long2char(long longVar) { std::string strVar = long2str(longVar); char* charVar = const_cast<char*>(strVar.c_str()); return charVar; }