// display the enabled internal commands int _near Cmds_Cmd( TCHAR *pszCmdLine ) { register int i, nColumn, nMaxColumns; nMaxColumns = GetScrCols(); for ( i = 0, nColumn = 0; ( i < NUMCMDS ); i++ ) { // make sure command hasn't been disabled (SETDOS /I-cmd) if ((commands[i].fParse & CMD_DISABLED) == 0) { printf( FMT_STR, commands[i].szCommand ); // get width of display if (( ++nColumn % ( nMaxColumns / 12 )) != 0 ) printf( FMT_LEFT_STR, 12 - strlen( commands[i].szCommand ), NULLSTR ); else { crlf(); } } } if (( nColumn % ( nMaxColumns / 12 )) != 0 ) crlf(); return 0; }
void TD_PrintChar(char c) { unsigned short temp16; temp16 = (yPos&(TD_SCREEN_VHEIGHT-1))*TD_SCREEN_VWIDTH; if (xPos==TD_SCREEN_WIDTH) { crlf(); temp16 = (yPos&(TD_SCREEN_VHEIGHT-1))*TD_SCREEN_VWIDTH; } if (c>=32 && c<=127) { textMap[temp16 + xPos] = (unsigned short)c; xPos++; } else if (c==10) { crlf(); temp16 = (yPos&(TD_SCREEN_VHEIGHT-1))*TD_SCREEN_VWIDTH; } else if (c==8) { xPos--; textMap[temp16 + xPos] = 32; } else if (c>=0 && c<32) { textMap[temp16 + xPos] = 32; xPos++; } }
bool tyhp_parse_http_request(const string& http_request, tyhp_http_header_t *phttphdr) { if(http_request.empty()) { perror("tyhp_parse_http_request: http_request is empty"); return false; } if(phttphdr == NULL) { perror("tyhp_parse_http_request: phttphdr is NULL"); return false; } string crlf("\r\n"), crlfcrlf("\r\n\r\n"); size_t prev = 0, next = 0; if(string::npos != (next = http_request.find(crlf, prev))) { string first_line(http_request.substr(prev, next - prev)); prev = next; stringstream sstream(first_line); sstream >> (phttphdr->method); sstream >> (phttphdr->url); sstream >> (phttphdr->version); }
void termputch(byte c) { switch(c) { case 7: beep(); return; case 8: xorcursor(); if(curcol>0) curcol--; else curcol=0; xorcursor(); return; case 11: case 12: case '\n': newline(); return; case '\r': if(LNM) crlf(); else { xorcursor(); curcol=0; xorcursor(); } return; default: ttyprint(c); return; } }
/** * Catches a stack overflow error. * * \req \req_ehandle The \program \shall catch and log errors. * * \todo Log errors. */ void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed portCHAR *pcTaskName) { lstr("\n\nvApplicationStackOverflowHook:"); lhex((unsigned int)pxTask);lstr((char*)pcTaskName);crlf(); for( ;; ); }
static void spawn_login(struct passwd *pwd, const char *tty, const char *id) { char *p, buf[50]; /* utmp */ ut.ut_type = USER_PROCESS; ut.ut_pid = getpid(); strncpy(ut.ut_line, tty, UT_LINESIZE); strncpy(ut.ut_id, id, 2); time(&ut.ut_time); strncpy(ut.ut_user, pwd->pw_name, UT_NAMESIZE); pututline(&ut); /* Don't leak utmp into the child */ endutent(); /* We don't care if initgroups fails - it only grants extra rights */ //initgroups(pwd->pw_name, pwd->pw_gid); /* But we do care if these fail! */ if (setgid(pwd->pw_gid) == -1 || setuid(pwd->pw_uid) == -1) _exit(255); signal(SIGINT, SIG_DFL); /* setup user environment variables */ envset("LOGNAME", pwd->pw_name); envset("HOME", pwd->pw_dir); envset("SHELL", pwd->pw_shell); /* home directory */ if (chdir(pwd->pw_dir)) putstr("login: unable to change to home directory, using /\n"); /* show the motd file */ if (!showfile("/etc/motd")) crlf(); /* and spawn the shell */ strcpy(buf, "-"); if ((p = strrchr(pwd->pw_shell, '/')) != NULL) strcat(buf, ++p); else strcat(buf, pwd->pw_shell); argp[0] = buf; argp[1] = NULL; execve(pwd->pw_shell, (void *) argp, (void *) env); putstr("login: can't execute shell\n"); exit(1); }
/* * Boot a specified local disk. AX specifies the BIOS disk number; or * -1 in case we should execute INT 18h ("next device.") */ __export void local_boot(int16_t ax) { com32sys_t ireg, oreg; int i; memset(&ireg, 0, sizeof(ireg)); syslinux_force_text_mode(); writestr(LOCALBOOT_MSG); crlf(); cleanup_hardware(); if (ax == -1) { /* Hope this does the right thing */ __intcall(0x18, &zero_regs, NULL); /* If we returned, oh boy... */ kaboom(); } /* * Load boot sector from the specified BIOS device and jump to * it. */ memset(&ireg, 0, sizeof ireg); ireg.edx.b[0] = ax & 0xff; ireg.eax.w[0] = 0; /* Reset drive */ __intcall(0x13, &ireg, NULL); memset(&ireg, 0, sizeof(ireg)); ireg.eax.w[0] = 0x0201; /* Read one sector */ ireg.ecx.w[0] = 0x0001; /* C/H/S = 0/0/1 (first sector) */ ireg.ebx.w[0] = OFFS(trackbuf); ireg.es = SEG(trackbuf); for (i = 0; i < retry_count; i++) { __intcall(0x13, &ireg, &oreg); if (!(oreg.eflags.l & EFLAGS_CF)) break; } if (i == retry_count) kaboom(); cli(); /* Abandon hope, ye who enter here */ memcpy((void *)0x07C00, trackbuf, 512); ireg.esi.w[0] = OFFS(trackbuf); ireg.edi.w[0] = 0x07C00; ireg.edx.w[0] = ax; call16(local_boot16, &ireg, NULL); }
void Console::write(const std::string message) { const Style& s = style(); const Font& font = s.font; const auto rect = screen_rect(); for(const auto c : message) { if( c == '\n' ) { crlf(); } else { const auto glyph = font.glyph(c); const auto advance = glyph.advance(); if( (pos.x + advance.x) > rect.width() ) { crlf(); } const Point pos_glyph { rect.pos.x + pos.x, display.scroll_area_y(pos.y) }; display.draw_glyph(pos_glyph, glyph, s.foreground, s.background); pos.x += advance.x; } } }
void hp9845_printer_device::insert_char(uint8_t ch) { if (m_pos == 80) { crlf(); } COPY_BIT(m_current_big , m_attrs[ m_pos ] , ATTRS_BIG_BIT); COPY_BIT(m_current_u_l , m_attrs[ m_pos ] , ATTRS_U_L_BIT); if (ch == '_') { BIT_SET(m_attrs[ m_pos ] , ATTRS_U_L_BIT); } else { m_line[ m_pos ] = ch; // Check for redefined characters unsigned redef_idx; if (is_ch_redef(ch , redef_idx)) { m_attrs[ m_pos ] = (m_attrs[ m_pos ] & ~ATTRS_REDEF_NO_MASK) | (uint8_t)redef_idx | ATTRS_NEW_MASK; } else { BIT_CLR(m_attrs[ m_pos ] , ATTRS_NEW_BIT); } } m_pos++; }
/********************************************************************* * * Main Function * *********************************************************************/ void main(void) { InitDevice(); LATAbits.LATA0 = 1; clrscr(); crlf(); printf("Hello from Cornell Cup!\n\r"); while(1) { if (ECAN_Receive()) { // new data received printf("Receive ADDR = %X\n\r", (temp_SIDH << 3)| (temp_SIDL >> 5)); printf("Data received: %d byte(s), ", temp_DLC); printf("Temperature = %d Fahrenheit\n\r", temp_D0); } else { } }
void print_CAN_Msg( canmsg_t *pmsg ) { int i; crlf(); // flags for packet hexout( ( ( pmsg->flags >> 24 ) & 0xff ) ); hexout( ( ( pmsg->flags >> 16 ) & 0xff ) ); hexout( ( ( pmsg->flags >> 8 ) & 0xff ) ); hexout( ( pmsg->flags & 0xff ) ); uart0BlockingPutch( 0x20 ); // id for frame hexout( ( ( pmsg->id >> 24 ) & 0xff ) ); hexout( ( ( pmsg->id >> 16 ) & 0xff ) ); hexout( ( ( pmsg->id >> 8 ) & 0xff ) ); hexout( ( pmsg->id & 0xff ) ); uart0BlockingPutch( 0x20 ); // timestamp for frame hexout( ( ( pmsg->timestamp >> 24 ) & 0xff ) ); hexout( ( ( pmsg->timestamp >> 16 ) & 0xff ) ); hexout( ( ( pmsg->timestamp >> 8 ) & 0xff ) ); hexout( ( pmsg->timestamp & 0xff ) ); uart0BlockingPutch( 0x20 ); // length for data part of frame hexout( pmsg->length ); uart0BlockingPutch( 0x20 ); // CAN frame data for ( i = 0; i<pmsg->length; i++ ) { hexout( pmsg->data[ i ] ); } }
void Noritake_VFD_GU7000::println(char c) { print(c); crlf(); }
void Noritake_VFD_GU7000::println(const char *str) { print(str); crlf(); }
void RFCFormat::writeHeaders(DtMailEnv & error, DtMail::Message & msg, DtMailBoolean include_unix_from, const char * extra_headers, const char ** suppress_headers, Buffer & buf) { error.clear(); // First we copy each header from the message to the // buffer. The headers may need encoding to put them away, so // we will apply RFC1522 if necessary. // DtMailHeaderHandle hnd; DtMail::Envelope * env = msg.getEnvelope(error); if (error.isSet()) { return; } char * name = NULL; DtMailValueSeq value; hnd = env->getFirstHeader(error, &name, value); if (!hnd || error.isSet()) { return; } if (include_unix_from && (error.isSet() || strcmp(name, "From") != 0)) { // We require a Unix from line, and we don't have one. // we will make one up using the sender, and the current // date. // char *unix_from = new char[100]; strcpy(unix_from, "From "); DtMailValueSeq sender; env->getHeader(error, DtMailMessageSender, DTM_TRUE, sender); if (error.isSet()) { // We no longer know who this is really from. // strcat(unix_from, "nobody@nowhere"); } else { DtMailAddressSeq * addrSeq = sender[0]->toAddress(); strcat(unix_from, (*addrSeq)[0]->dtm_address); delete addrSeq; } error.clear(); time_t now = time(NULL); char time_format[30]; SafeCtime(&now, time_format, sizeof(time_format)); strcat(unix_from, " "); strcat(unix_from, time_format); buf.appendData(unix_from, strlen(unix_from)); delete [] unix_from; } else { // Put out any header, except Unix From line // if (strcmp(name, "From") == 0) { value.clear(); free(name); hnd = env->getNextHeader(error, hnd, &name, value); } } for (; // First time is determined above. hnd && !error.isSet(); value.clear(), hnd = env->getNextHeader(error, hnd, &name, value)) { const char **hdr; for (hdr = suppress_headers; *hdr; hdr++) { if (strcasecmp(name, *hdr) == 0) break; } //add _is_write_bcc for fixing aix defect 177096 if (*hdr || strcasecmp(name, "bcc") == 0 && !_is_write_bcc ) { free(name); continue; // We will generate these headers. } int name_len = strlen(name); for (int val = 0; val < value.length(); val++) { // // If the value is null or empty do not emit this field const char *valPtr; for (valPtr = *(value[val]); *valPtr && (isspace((unsigned char)*valPtr)); valPtr++) {} if (!*valPtr) continue; buf.appendData(name, name_len); buf.appendData(": ", 2); rfc1522cpy(buf, *(value[val])); } free(name); } error.clear(); buf.appendData(extra_headers, strlen(extra_headers)); // Add new line that terminates the headers. // crlf(buf); }
void RFCFormat::rfc1522cpy(Buffer & buf, const char * value) { buf.appendData(value, strlen(value)); crlf(buf); }
u32 getNumericValue( char *p ) { crlf(); // must be a number '0x or a nummeric digit if ( ( *p >= '0' ) && ( *p <= '9' ) ) { // it is a nummeric digit if ( ( *(p+1) == 0 ) || *(p+1) == ',' || *(p+1) == 0x20 ) { // Decimal number return atoi( p ); } else if ( (*(p+1) & ~0x20 ) == 'X' ) { uart0BlockingPutch( 'A' ); // Hex number p += 2; // point beyond '0x' // Make sure it is't just '0x' if ( *p ) { int digit[ 4 ]; int i = 0; // First digit if ( -1 == ( digit[ i ] = getHexValue( *p++ ) ) ) { uart0BlockingPutch( 'B' ); return 0xffff; } i++; // digit 2 if ( -1 == ( digit[ i ] = getHexValue( *p++ ) ) ) { // One digit 0x9 uart0BlockingPutch( 'C' ); return digit[ 0 ]; } i++; // digit 3 if ( -1 == ( digit[ i ] = getHexValue( *p++ ) ) ) { // Two digit 0x99 uart0BlockingPutch( 'D' ); return digit[ 0 ] * 16 + digit[ 1 ]; } i++; // digit 4 if ( -1 == ( digit[ i ] = getHexValue( *p++ ) ) ) { // Three digit 0x999 uart0BlockingPutch( 'E' ); return digit[ 0 ] * 256 + digit[ 1 ] * 16 + digit[ 2 ]; } // Four digit 0x9999 uart0BlockingPutch( 'F' ); return ( digit[ 0 ] * 4096 + digit[ 1 ] * 256 + digit[ 2 ] * 16 + digit[ 3 ] ); } else { // it is '0x' uart0BlockingPutch( 'x' ); return 0xffff; } } else { return atoi( p ); } } else { uart0BlockingPutch( 'y' ); return 0xffff; } uart0BlockingPutch( 'z' ); return 0xffff; }
// edit or display a file with vertical & horizontal scrolling & text searching int _near List_Cmd( LPTSTR pszCmdLine ) { int nFVal, nReturn = 0, argc; TCHAR szSource[MAXFILENAME+1], szFileName[MAXFILENAME+1], *pszArg; FILESEARCH dir; memset( &dir, '\0', sizeof(FILESEARCH) ); // check for and remove switches if ( GetRange( pszCmdLine, &(dir.aRanges), 0 ) != 0 ) return ERROR_EXIT; // check for /T"search string" GetMultiCharSwitch( pszCmdLine, _TEXT("T"), szSource, 255 ); if ( szSource[0] == _TEXT('"') ) sscanf( szSource+1, _TEXT("%79[^\"]"), szListFindWhat ); else if ( szSource[0] ) sprintf( szListFindWhat, FMT_PREC_STR, 79, szSource ); if ( GetSwitches( pszCmdLine, _TEXT("*HIRSWX"), &lListFlags, 0 ) != 0 ) return ( Usage( LIST_USAGE )); if ( szSource[0] ) lListFlags |= LIST_SEARCH; // check for pipe to LIST w/o explicit /S switch if ( first_arg( pszCmdLine ) == NULL ) { if ( _isatty( STDIN ) == 0 ) lListFlags |= LIST_STDIN; else if (( lListFlags & LIST_STDIN ) == 0 ) return ( Usage( LIST_USAGE )); } // initialize buffers & globals if ( ListInit() ) return ERROR_EXIT; nCurrent = nStart = 0; // ^C handling if ( setjmp( cv.env ) == -1 ) { list_abort: FindClose( dir.hdir ); Cls_Cmd( NULL ); nReturn = CTRLC; goto list_bye; } RestartFileSearch: for ( argc = 0; ; argc++ ) { // break if at end of arg list, & not listing STDIN if (( pszArg = ntharg( pszCmdLine, argc )) == NULL ) { if (( lListFlags & LIST_STDIN ) == 0 ) break; } else strcpy( szSource, pszArg ); for ( nFVal = FIND_FIRST; ; ) { szClip[0] = _TEXT('\0'); // if not reading from STDIN, get the next matching file if (( lListFlags & LIST_STDIN ) == 0 ) { // qualify filename if ( nFVal == FIND_FIRST ) { mkfname( szSource, 0 ); if ( is_dir( szSource )) mkdirname( szSource, WILD_FILE ); } if ( stricmp( szSource, CLIP ) == 0 ) { RedirToClip( szClip, 99 ); if ( CopyFromClipboard( szClip ) != 0 ) break; strcpy( szFileName, szClip ); } else if ( QueryIsPipeName( szSource )) { // only look for pipe once if ( nFVal == FIND_NEXT ) break; copy_filename( szFileName, szSource ); } else if ( find_file( nFVal, szSource, ( FIND_BYATTS | FIND_RANGE | FIND_EXCLUDE | 0x07), &dir, szFileName ) == NULL ) { nReturn = (( nFVal == FIND_FIRST ) ? ERROR_EXIT : 0 ); break; } else if ( nStart < nCurrent ) { nStart++; nFVal = FIND_NEXT; continue; } else if ( dir.ulSize > 0L ) LFile.lSize = dir.ulSize; } // clear the screen (scrolling the buffer first to save the current screen) Cls_Cmd( NULL ); if (( nReturn = _list( szFileName )) == CTRLC ) goto list_abort; if ( szClip[0] ) remove( szClip ); if ( nReturn != 0 ) break; SetCurPos( nScreenRows, 0 ); if (( szClip[0] ) || ( lListFlags & LIST_STDIN )) break; if ( LFile.hHandle > 0 ) _close( LFile.hHandle ); LFile.hHandle = -1; // increment index to current file if ( nCurrent < nStart ) { FindClose( dir.hdir ); nStart = 0; goto RestartFileSearch; } else { nFVal = FIND_NEXT; nCurrent++; nStart++; } } // we can only read STDIN once! lListFlags &= ~LIST_STDIN; } crlf(); list_bye: FreeMem( LFile.lpBufferStart ); if ( LFile.hHandle > 0 ) _close( LFile.hHandle ); LFile.hHandle = -1; return nReturn; }
void Noritake_VFD_GU7000::println(const char *buffer, size_t size) { print(buffer, size); crlf(); }
void handlerequest(int fd, const char *addr) { char buffer[BUFFER_SIZE]; char can_uri[BUFFER_SIZE]; char filepath[BUFFER_SIZE]; char headers[BUFFER_SIZE]; char pf[BUFFER_SIZE]; int len = 0, ret, begin = 0, p, pbegin = 0, plen = 0; int state = 0, filelen; int fduri; char *uribuffer; int tot; time_t now; struct header rq; rq.code = 500; rq.contentlen = 0; memset(rq.contenttype, 0, sizeof(rq.contenttype)); memset(rq.host, 0, sizeof(rq.host)); memset(rq.cookie, 0, sizeof(rq.cookie)); do { ret = read(fd, buffer + len, BUFFER_SIZE - len); if (ret > 0) { len += ret; while ((state == 0 || state == 1) && begin < len && (p = crlf(buffer + begin, len - begin)) >= 0) { p += begin; if (state == 0) { if (statusline(fd, buffer + begin, p - begin, &rq)) state = 1; else { state = 3; break; } } else if (state == 1) { if (p - begin == 0) { if (rq.contentlen == 0) state = 3; else state = 2; } else if (!header(fd, buffer + begin, p - begin, &rq)) state = 3; } begin = p + 2; if (state == 2 || state == 3) break; } if (state == 2) { memcpy(rq.payload + pbegin, buffer + begin, len - begin); pbegin += len - begin; plen += len - begin; begin += len - begin; if (rq.contentlen != 0 && pbegin >= rq.contentlen) state = 3; } } else { state = 3; break; } } while (state <= 2); if (rq.contentlen == 0) rq.contentlen = plen; if (rq.code != 200) { respond(fd, rq.code, rq.protocol, NULL, 0, NULL); } else { if (rq.uri[0] == '/') strcpy(can_uri, rq.uri); else { strcpy(can_uri, "/"); strcat(can_uri, rq.uri); } if (!permissible(can_uri)) { rq.code = 403; respond(fd, rq.code, rq.protocol, NULL, 0, NULL); } else { state = locateresource(can_uri, filepath, BUFFER_SIZE, &filelen); if (state == 0) { rq.code = 404; respond(fd, rq.code, rq.protocol, NULL, 0, NULL); } else if (state == 2) { strcpy(buffer, "Location: "); strcat(buffer, filepath); strcat(buffer, "\r\n"); rq.code = 301; respond(fd, rq.code, rq.protocol, NULL, 0, buffer); } else if (state == 3) { rq.code = 403; respond(fd, rq.code ,rq.protocol, NULL, 0, NULL); } else if (state == 1) { if (postfix(filepath, pf) && strcmp(pf, "php") == 0) { php(fd, filepath, addr, &rq); } else { strcpy(headers, "Content-Type: "); strcat(headers, contenttype(filepath)); strcat(headers, "\r\n"); if (rq.method == METHOD_HEAD) respond(fd, rq.code, rq.protocol, NULL, filelen, headers); else { fduri = open(filepath, O_RDONLY); if (fduri < 0) { rq.code = 404; respond(fd, rq.code, rq.protocol, NULL, 0, NULL); } else { uribuffer = malloc(filelen); if (uribuffer == 0) { rq.code = 500; respond(fd, rq.code, rq.protocol, NULL, 0, NULL); } else { tot = 0; while (tot < filelen) tot += read(fduri, uribuffer + tot, filelen - tot); respond(fd, rq.code, rq.protocol, uribuffer, filelen, headers); free(uribuffer); } close(fduri); } } } } } } now = time(NULL); len = strftime(buffer, BUFFER_SIZE, "%d/%b/%Y %H:%M:%S", gmtime(&now)); fprintf(stdout, "%s - - [%s] \"%s\" %d\n", addr, buffer, rq.statusline, rq.code); }
void php(int socket, const char *script, const char *addr, struct header *rq) { int outfd[2]; int infd[2]; int pid; char strcontentlen[BUFFER_SIZE], strmethod[BUFFER_SIZE]; char buffer[BUFFER_SIZE]; const char *qs; int p, r; pipe(outfd); pipe(infd); if (!(pid = fork())) { close(0); close(1); dup2(outfd[0], 0); dup2(infd[1], 1); snprintf(strcontentlen, BUFFER_SIZE, "%d", rq->contentlen); switch (rq->method) { case METHOD_GET: strncpy(strmethod, "GET", BUFFER_SIZE); break; case METHOD_POST: strncpy(strmethod, "POST", BUFFER_SIZE); break; case METHOD_HEAD: strncpy(strmethod, "HEAD", BUFFER_SIZE); break; default: strncpy(strmethod, "GET", BUFFER_SIZE); break; } qs = querystring(rq->uri); setenv("REDIRECT_STATUS", "1", 1); setenv("SERVER_SOFTWARE", SERVER_NAME, 1); setenv("CONTENT_LENGTH", strcontentlen, 1); setenv("REQUEST_METHOD", strmethod, 1); setenv("SCRIPT_FILENAME", script, 1); if (qs) setenv("QUERY_STRING", qs, 1); setenv("REQUEST_URI", rq->uri, 1); setenv("HTTP_HOST", rq->host, 1); setenv("REMOTE_ADDR", addr, 1); if (strlen(rq->contenttype) > 0) setenv("CONTENT_TYPE", rq->contenttype, 1); else setenv("CONTENT_TYPE", "application/x-www-form-urlencoded", 1); if (strlen(rq->cookie) > 0) setenv("HTTP_COOKIE", rq->cookie, 1); write(outfd[1], rq->payload, rq->contentlen); execl(PHP_CGI, PHP_CGI, NULL); } else { close(outfd[0]); close(outfd[1]); close(infd[1]); p = 0; do { r = read(infd[0], buffer + p, BUFFER_SIZE - p); if (r <= 0) break; p += r; } while (crlf(buffer, p) < 0); r = crlf(buffer, p); if (r >= 12 && strncmp(buffer, "Status: ", 8) == 0) { buffer[11] = 0; rq->code = atoi(buffer + 8); if (rq->code == 0) rq->code = 200; respond2(socket, rq->code, rq->protocol); writeall(socket, buffer + r + 2, p - r - 2); } else { respond2(socket, rq->code, rq->protocol); writeall(socket, buffer, p); } while ((r = read(infd[0], buffer, BUFFER_SIZE)) > 0) { writeall(socket, buffer, r); } waitpid(pid, 0, 0); } }
void main() { // clrscr uint8_t color; uint8_t bg; uint8_t x, y; uint8_t a; uint16_t b; char c; char *vram; unsigned char index; char buffer[20]; unsigned char offs; // links, oben, rechts, unten window(3, 3, 30, 30); clrscr(); for (color = 0; color < 16; color++) { textcolor(color); for (bg = 0; bg < 8; bg++) { textbackground(bg); cstbt(0x1b); } cputs(" Hello KC85!\r\n"); } x = wherex(); y = wherey(); gotoxy(0, 3); delline(); gotoxy(0, 5); delline(); cputs("test"); gotoxy(x, y); c = getche(); putch(c); crlf(); // kbhit textcolor(BROWN); clrscr(); for (index = 0; index < 20; index++) { if ((index & 0x01) == 0x01) highvideo(); else lowvideo(); cputs("press key\r\n"); } textcolor(WHITE); while (kbhit()) cputs("you have touched key.\r\n"); cputs("done\r\n"); next(); // delline cputs("This line will be deleted. press key."); getch(); delline(); cputs("Line deleted successfully."); getch(); crlf(); // inlin cputs("Zeug eingeben: "); offs = wherex(); vram = inlin(); vram += offs; crlf(); index = 0; while (*vram != '\0') { buffer[index] = *vram; index++; vram++; } ahex(index); while (index > 0) { index--; ahex(buffer[index]); space(); } next(); crlf(); // cgets cputs("Zeug eingeben: "); buffer[0] = 10; vram = cgets(buffer); crlf(); delline(); index = buffer[1]; ahex(index); space(); space(); while (index > 0) { index--; ahex(*vram); space(); vram++; } ahex(*vram); crlf(); // add test a = sqr(100); b = puse(10, 10, 10); b = b + a; hlhx(b); crlf(); }
void Noritake_VFD_GU7000::println(unsigned long number, uint8_t base) { print(number, base); crlf(); }
void Console::writeln(const std::string message) { write(message); crlf(); }
/* * @brief: 根据解析下来的going_http_header_t来处理客户的请求. * @param phttpdr: 指向要处理的going_http_header_t; out: 保存处理的结果,http响应包. * @return: http status code. * * 目前支持的请求首部: * 目前支持的响应首部: */ int going_do_http_header(going_http_header_t *phttphdr, string& out) { char status_line[256] = {0}; string crlf("\r\n"); string server("Server: Gogoing\r\n"); string Public("Public: GET, HEAD\r\n"); string content_base = "Content-base: " + going_domain + crlf; string date = "Date: " + going_time_get() + crlf; string content_length("Content-Length: "); string content_location("Content-Location: "); string last_modify("Last-Modify: "); if(phttphdr == NULL){ snprintf(status_line, sizeof(status_line), "HTTP/1.1 %d %s\r\n", GOING_HTTP_BAD_REQUEST, going_get_state_by_codes(GOING_HTTP_BAD_REQUEST)); out = status_line + crlf; return GOING_HTTP_BAD_REQUEST; } string method = phttphdr->method; string real_url = going_make_url(phttphdr->url); string version = phttphdr->version; if(method == "GET" || method == "HEAD"){ if(going_is_file_existed(real_url.c_str()) == -1){ snprintf(status_line, sizeof(status_line), "HTTP/1.1 %d %s\r\n", GOING_HTTP_NOT_FOUND, going_get_state_by_codes(GOING_HTTP_NOT_FOUND)); out += status_line; return GOING_HTTP_NOT_FOUND; }else{ int len = going_get_file_length(real_url.c_str()); snprintf(status_line, sizeof(status_line), "HTTP/1.1 %d %s\r\n", GOING_HTTP_OK, going_get_state_by_codes(GOING_HTTP_OK)); out += status_line; snprintf(status_line, sizeof(status_line), "%d\r\n", len); out += content_length + status_line; out += server + content_base + date; out += last_modify + going_get_file_modified_time(real_url.c_str()) + crlf + crlf; } } else if(method == "PUT"){ snprintf(status_line, sizeof(status_line), "HTTP/1.1 %d %s\r\n", GOING_HTTP_NOT_IMPLEMENTED, going_get_state_by_codes(GOING_HTTP_NOT_IMPLEMENTED)); out += status_line + server + Public + date + crlf; return GOING_HTTP_NOT_IMPLEMENTED; } else if(method == "DELETE"){ snprintf(status_line, sizeof(status_line), "HTTP/1.1 %d %s\r\n", GOING_HTTP_NOT_IMPLEMENTED, going_get_state_by_codes(GOING_HTTP_NOT_IMPLEMENTED)); out += status_line + server + Public + date + crlf; return GOING_HTTP_NOT_IMPLEMENTED; }else if(method == "POST"){ snprintf(status_line, sizeof(status_line), "HTTP/1.1 %d %s\r\n", GOING_HTTP_NOT_IMPLEMENTED, going_get_state_by_codes(GOING_HTTP_NOT_IMPLEMENTED)); out += status_line + server + Public + date + crlf; return GOING_HTTP_NOT_IMPLEMENTED; }else{ snprintf(status_line, sizeof(status_line), "HTTP/1.1 %d %s\r\n", GOING_HTTP_BAD_REQUEST, going_get_state_by_codes(GOING_HTTP_BAD_REQUEST)); out = status_line + crlf; return GOING_HTTP_BAD_REQUEST; } return GOING_HTTP_OK; }
////////////////////////////// // Bedienungsanleitung screen.h void anleitung_screen(void) { const uint8_t item_anzahl = 16; uint8_t eingabe; uint8_t auswahl = 0; wiinit(4, 4, 8, 19, selectionwin); wisave(selectionwin); clrscr(); rahm(); wiinit(14, 2, 25, 28, descrwin); wisave(descrwin); clrscr(); rahm(); wiinit(15, 3, 23, 26, testwin); winak(selectionwin); putstr( "\r\n Index\r\n wiinit\r\n wisave\r\n wiload\r\n asme\r\n meas\r\n shift\r\n invzei\r\n invwin\r\n rahm\r\n lrahm\r\n shadow\r\n lshad\r\n icon\r\n priat\r\n inpat\r\n titel"); do { winak(testwin); clrscr(); switch (auswahl) { case 0: putstr("Kurzerkl\173rung,"); crlf(); crlf(); // 12345678901234567890123 putstr("wie die Funktionen aus"); crlf(); putstr("screen.lib bzw."); crlf(); putstr("screen.h in eigenen"); crlf(); putstr("C-Programmen genutzt"); crlf(); putstr("werden k\174nnen."); crlf(); crlf(); crlf(); putstr("Hardwarevoraussetzung:"); crlf(); putstr("- KC85/4 oder KC85/5"); crlf(); putstr("- M011 64k-RAM-Modul"); crlf(); crlf(); crlf(); // 1234567890123456789012 putstr("Das Einbinden erfolgt"); crlf(); putstr("im Quelltext mit:"); crlf(); crlf(); putstr("#include <screen.h>"); crlf(); crlf(); putstr("Beim Linken mu\176 der"); crlf(); putstr("Parameter \"-l screen\""); crlf(); putstr("erg\173nzt werden."); break; case 1: // 1234567890123456789012 putstr("wiinit( "); crlf(); putstr(" links,"); crlf(); putstr(" oben,"); crlf(); putstr(" breite,"); crlf(); putstr(" hoehe,"); crlf(); putstr(" fenster_nr);"); crlf(); crlf(); // 1234567890123456789012 putstr("Initialisiert ein"); crlf(); putstr("Fenster"); crlf(); crlf(); putstr("Achtung, fenster_nr"); crlf(); putstr("mu\176 wegen der"); crlf(); putstr("Speicherverwaltung"); crlf(); putstr("aufsteigend vergeben"); crlf(); putstr("werden."); crlf(); putstr("Es werden maximal 10"); crlf(); putstr("verschiedene Fenster"); crlf(); putstr("unterst\175tzt."); crlf(); crlf(); putstr(" siehe auch:"); crlf(); putstr(" wisave,"); crlf(); putstr(" wiload,"); crlf(); putstr(" rahm,"); crlf(); putstr(" shadow"); crlf(); break; case 2: // 1234567890123456789012 putstr("wisave( fenster_nr);"); crlf(); crlf(); // 1234567890123456789012 putstr("Sichert den"); crlf(); putstr("Fensterinhalt"); crlf(); crlf(); putstr("Es werden Pixel-,"); crlf(); putstr("Farb- und ASCII-RAM"); crlf(); putstr("gesichert."); crlf(); crlf(); putstr(" siehe auch:"); crlf(); putstr(" wiload,"); crlf(); putstr(" asme"); crlf(); break; case 3: // 1234567890123456789012 putstr("wiload( fenster_nr);"); crlf(); crlf(); // 1234567890123456789012 putstr("Restauriert den"); crlf(); putstr("Fensterinhalt"); crlf(); crlf(); putstr("Es werden Pixel-,"); crlf(); putstr("Farb- und ASCII-RAM"); crlf(); putstr("wiederhergestellt."); crlf(); crlf(); putstr(" siehe auch:"); crlf(); putstr(" wisave,"); crlf(); putstr(" meas"); crlf(); break; case 4: // 1234567890123456789012 putstr("asme( fenster_nr);"); crlf(); crlf(); // 1234567890123456789012 putstr("Sichert den"); crlf(); putstr("Fensterinhalt"); crlf(); crlf(); putstr("Es wird nur der"); crlf(); putstr("ASCII-RAM gesichert."); crlf(); crlf(); putstr(" siehe auch:"); crlf(); putstr(" wisave,"); crlf(); putstr(" meas"); crlf(); break; case 5: // 1234567890123456789012 putstr("meas( fenster_nr);"); crlf(); crlf(); // 1234567890123456789012 putstr("Restauriert den"); crlf(); putstr("Fensterinhalt"); crlf(); crlf(); putstr("Es wird nur der"); crlf(); putstr("ASCII-RAM wiederher-"); crlf(); putstr("gestellt."); crlf(); crlf(); putstr(" siehe auch:"); crlf(); putstr(" wiload,"); crlf(); putstr(" asme"); crlf(); break; case 6: // 1234567890123456789012 putstr("shift( x, y);"); crlf(); crlf(); // 1234567890123456789012 putstr("Verschiebt den"); crlf(); putstr("Fensterinhalt"); crlf(); crlf(); putstr("Wenn das MSB gesetzt"); crlf(); putstr("ist (\1340x80), wird"); crlf(); putstr("nach links bzw. oben"); crlf(); putstr("verschoben. Der ur-"); crlf(); putstr("spr\175ngliche Fenster-"); crlf(); putstr("inhalt wird nicht ge-"); crlf(); putstr("l\174scht."); crlf(); crlf(); putstr(" siehe auch:"); crlf(); putstr(" wiinit,"); crlf(); putstr(" wisave"); crlf(); break; case 7: // 1234567890123456789012 putstr("invzei( zeile);"); crlf(); crlf(); // 1234567890123456789012 putstr("Invertiert eine Zeile"); crlf(); putstr("im aktuellen Fenster."); crlf(); crlf(); putstr(" siehe auch:"); crlf(); putstr(" invwin"); crlf(); break; case 8: // 1234567890123456789012 putstr("invwin();"); crlf(); crlf(); // 1234567890123456789012 putstr("Invertiert den Inhalt"); crlf(); putstr("des aktuellen"); crlf(); putstr("Fensters."); crlf(); crlf(); putstr(" siehe auch:"); crlf(); putstr(" invzei"); crlf(); break; case 9: // 1234567890123456789012 putstr("rahm();"); crlf(); crlf(); // 1234567890123456789012 putstr("Zeichnet einen Rahmen"); crlf(); putstr("um das aktuelle"); crlf(); putstr("Fenster."); crlf(); crlf(); // 1234567890123456789012 putstr("Der Rahmen wird nicht"); crlf(); putstr("durch wiload bzw."); crlf(); putstr("wisave ber\175cksichtigt."); crlf(); crlf(); putstr(" siehe auch:"); crlf(); putstr(" shadow,"); crlf(); putstr(" lrahm"); crlf(); break; case 10: // 1234567890123456789012 putstr("lrahm();"); crlf(); crlf(); // 1234567890123456789012 putstr("Der Rahmen um das"); crlf(); putstr("aktuelle Fenster wird"); crlf(); putstr("mit der eingestellten"); crlf(); putstr("Hintergundfarbe ge-"); crlf(); putstr("l\174scht."); crlf(); crlf(); putstr(" siehe auch:"); crlf(); putstr(" rahm,"); crlf(); putstr(" lshad"); crlf(); break; case 11: // 1234567890123456789012 putstr("shadow();"); crlf(); crlf(); // 12345678901234567890123 putstr("Zeichnet einen Schatten"); putstr("unter dem aktuellen"); crlf(); putstr("Fenster."); crlf(); crlf(); // 12345678901234567890123 putstr("Der Schatten wird"); crlf(); putstr("nicht durch wiload bzw."); putstr("wisave ber\175cksichtigt."); crlf(); crlf(); putstr(" siehe auch:"); crlf(); putstr(" rahm,"); crlf(); putstr(" lshad"); crlf(); break; case 12: // 12345678901234567890123 putstr("lshad();"); crlf(); crlf(); // 12345678901234567890123 putstr("Der Schatten unter dem"); crlf(); putstr("aktuellen Fenster wird"); crlf(); putstr("gel\174scht."); crlf(); crlf(); putstr("Es wird die einge-"); crlf(); putstr("stellte Hintergundfarbe"); putstr("genutzt."); crlf(); crlf(); putstr(" siehe auch:"); crlf(); putstr(" shadow,"); crlf(); putstr(" lrahm"); crlf(); break; case 13: // 1234567890123456789012 putstr("icon("); crlf(); putstr(" icon_nr,"); crlf(); putstr(" &icon_def,"); crlf(); putstr(" spalte,"); crlf(); putstr(" zeile);"); crlf(); crlf(); // 12345678901234567890123 putstr("Stellt einen Icon auf"); crlf(); putstr("dem Bildschirm dar."); crlf(); crlf(); putstr("Die Gr\174\176e des Icons ist"); putstr("nur durch den Bild-"); crlf(); putstr("schirm beschr\173nkt."); crlf(); // 12345678901234567890123 putstr("Die Definition des Icon"); putstr("kann z.B. so erfolgen:"); crlf(); crlf(); putstr("const unsigned char"); crlf(); putstr(" icondef\033C[] = {"); crlf(); putstr(" breite, hoehe,"); crlf(); putstr(" data_0..data_n}\033C"); crlf(); crlf(); // 12345678901234567890123 putstr("Die Daten beschreiben"); crlf(); putstr("immer ein 8x8-Feld. Die"); putstr("Reihenfolge ist von"); crlf(); putstr("links nach rechts und"); crlf(); putstr("von oben nach unten."); crlf(); // Beispiel: // const unsigned char beispiel_icon[] = { 2, 1, // 0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, // 0xff, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0xff }; // Mehrere Icons können in einer Deinition zusammengefasst werden. Die Auswahl erfolgt dann über die icon_nr. break; case 14: // 12345678901234567890123 putstr("priat("); crlf(); putstr(" spalte,"); crlf(); putstr(" zeile,"); crlf(); putstr(" text);"); crlf(); crlf(); // 12345678901234567890123 putstr("Gibt einen Text an der"); crlf(); putstr("entsprechenden Stelle"); crlf(); putstr("im Fenster aus."); crlf(); crlf(); putstr(" siehe auch:"); crlf(); putstr(" inpat"); crlf(); break; case 15: // 12345678901234567890123 putstr("inpat("); crlf(); putstr(" spalte,"); crlf(); putstr(" zeile);"); crlf(); crlf(); // 12345678901234567890123 putstr("Setzt den Cursor auf"); crlf(); putstr("die entsprechende Posi-"); putstr("tion und erwartet eine"); crlf(); putstr("Eingabe. R\175ckgabewert"); crlf(); putstr("ist ein Zeiger auf den"); crlf(); putstr("ASCII-RAM mit den Ein-"); crlf(); putstr("gabewerten."); crlf(); crlf(); putstr(" siehe auch:"); crlf(); putstr(" priat"); crlf(); break; case 16: // 12345678901234567890123 putstr("titel( text);"); crlf(); crlf(); // 12345678901234567890123 putstr("Dekoriert ein Fenster"); crlf(); putstr("mit einer Titelzeile,"); crlf(); putstr("einem Titeltext und"); crlf(); putstr("einem Rahmen. Die Fens-"); putstr("tergr\174\176e wird entspre-"); crlf(); putstr("chend verkleinert."); crlf(); crlf(); putstr(" siehe auch:"); crlf(); putstr(" wiinit"); crlf(); break; } winak(selectionwin); invzei(auswahl + 1); while (!kbhit()) { } eingabe = getch(); invzei(auswahl + 1); if (eingabe == CUU) auswahl = (auswahl > 0) ? auswahl - 1 : item_anzahl; //if (eingabe == CUD) //auswahl = (auswahl + 1) % (item_anzahl + 1); if (eingabe == PAGE) auswahl = 0; if (eingabe == SCROL) auswahl = item_anzahl - 1; }while (eingabe != BREAK && eingabe != CR && eingabe != CUL); winak(descrwin); lrahm(); wiload(descrwin); winak(selectionwin); lrahm(); wiload(selectionwin); }
// create or display environment variables or aliases static int _fastcall __Set( LPTSTR pszCmdLine, TCHAR _far * pchList ) { LPTSTR pszArg; long fSet = 0L; TCHAR _far *lpszVars; init_page_size(); // set the pointer to the environment, alias, or function list // strip leading switches if (( pszCmdLine != NULL ) && ( *pszCmdLine == gpIniptr->SwChr )) { if ( GetSwitches( pszCmdLine, "AMPR", &fSet, 1 ) != 0 ) return USAGE_ERR; } // check for master environment set if (( pchList == glpEnvironment ) && ( fSet & SET_MASTER )) pchList = glpMasterEnvironment; // read environment or alias file(s) if ( fSet & SET_READ ) return ( SetFromFile( pszCmdLine, pchList, fSet & ( SET_DEFAULT | SET_SYSTEM | SET_USER | SET_VOLATILE ))); if ( setjmp( cv.env ) == -1 ) return CTRLC; // pause after each page if ( fSet & SET_PAUSE ) { gnPageLength = GetScrRows(); } if (( pszCmdLine == NULL ) || ( *(pszCmdLine = skipspace( pszCmdLine )) == _TEXT('\0'))) { // print all the variables or aliases for ( lpszVars = pchList; ( *lpszVars != _TEXT('\0') ); lpszVars = next_env( lpszVars ) ) { more_page( lpszVars, 0 ); } // return an error if no entries exist return (( lpszVars == pchList ) ? ERROR_LIST_EMPTY : 0 ); } if ( fSet & SET_EXPRESSION ) { if (( pszArg = strchr( pszCmdLine, _TEXT('=') )) != NULL ) { if (( pszArg > pszCmdLine ) && ( strchr( _TEXT("+-*/%&^|><"), pszArg[-1] ) != NULL )) { TCHAR szBuf[256]; // it's an assignment operator ("set /a test+=2") sscanf( pszCmdLine, _TEXT(" %[^ +-*/%&^|><=]"), szBuf ); strcpy( pszArg, pszArg+1 ); strins( pszCmdLine, _TEXT("=") ); strins( pszCmdLine, szBuf ); pszArg = pszCmdLine + strlen( szBuf ) + 1; } else pszArg = skipspace( pszArg+1 ); } else pszArg = pszCmdLine; StripQuotes( pszArg ); evaluate( pszArg ); if ( cv.bn < 0 ) { qputs( pszArg ); crlf(); } // create/modify/delete a variable return (( pszArg == pszCmdLine ) ? 0 : add_list( pszCmdLine, pchList )); } // display the current variable or alias argument? // (setting environment vars requires a '='; it's optional with aliases) if ((( pszArg = strchr( pszCmdLine, _TEXT('=') )) == NULL ) && (( pchList == 0L ) || ( ntharg( pszCmdLine, 0x8001 ) == NULL ))) { if (( lpszVars = get_list( pszCmdLine, pchList )) == 0L ) { return ERROR_NOT_IN_LIST; } printf( FMT_FAR_STR_CRLF, lpszVars ); return 0; } // create/modify/delete a variable or alias return ( add_list( pszCmdLine, pchList )); }