static RD_BOOL l_ui_authenticate(struct rdp_inst * inst) { if (!AllocConsole()) _cputs("\n"); /* reusing debug console */ _cputs("Please enter NLA login credential.\n"); _cputs("User name:"); if (inst->settings->username[0] == 0) getsn(inst->settings->username, sizeof(inst->settings->username), 0); else _cputs(inst->settings->username); _putch('\n'); _cputs("Domain:"); if (inst->settings->domain[0] == 0) getsn(inst->settings->domain, sizeof(inst->settings->domain), 0); else _cputs(inst->settings->domain); _putch('\n'); _cputs("Password:"******"***"); _putch('\n'); return 1; }
void clrscr(void) { _putch('\033'); _putch('['); _putch('2'); _putch('J'); }
void XUI_Wnd::show_members( int indent ) { SLB::ClassInfo* c = SLB::Manager::getInstance().getClass( typeid( *this ) ); if( c ) { SLB::LuaCall< const char*( const XUI_Wnd*, const char*, int ) > op( Lua::Instance(), "class_attrib" ); std::list< const char* > l; c->getMembers( l ); std::list< const char* >::iterator i = l.begin(); while( i != l.end() ) { try { _putch( '\n' ); for( int n = 0; n < indent; ++n ) printf( " " ); printf( "|-> %s", *i); const char* attrib = op( this, *i, indent ); if( attrib ) { printf( " = %s", attrib ); } } catch( std::runtime_error& err ) { OutputDebugStringA( err.what() ); } ++i; } } _putch( '\n' ); }
char *Sys_ConsoleInput(void) { // if (cls.state == ca_dedicated) { static char text[MAX_INPUTLINE]; int len = 0; #ifdef WIN32 int c; // read a line out while (_kbhit ()) { c = _getch (); _putch (c); if (c == '\r') { text[len] = 0; _putch ('\n'); len = 0; return text; } if (c == 8) { if (len) { _putch (' '); _putch (c); len--; text[len] = 0; } continue; } text[len] = c; len++; text[len] = 0; if (len == sizeof (text)) len = 0; } #else fd_set fdset; struct timeval timeout; FD_ZERO(&fdset); FD_SET(0, &fdset); // stdin timeout.tv_sec = 0; timeout.tv_usec = 0; if (select (1, &fdset, NULL, NULL, &timeout) != -1 && FD_ISSET(0, &fdset)) { len = read (0, text, sizeof(text)); if (len >= 1) { // rip off the \n and terminate text[len-1] = 0; return text; } } #endif } return NULL; }
void cursoroff(void) { _putch('\033'); _putch('['); _putch('2'); _putch('5'); _putch('l'); }
void cursoron(void) { _putch('\033'); _putch('['); _putch('2'); _putch('5'); _putch('h'); }
/* The function is used in Windows console app, especially S-commands. */ void iRODSNtGetUserPasswdInputInConsole(char *buf, char *prompt, int echo_input) { char *p = buf; char c; char star='*'; char whitechar = ' '; if((prompt != NULL) && (strlen(prompt) > 0)) { printf("%s", prompt); fflush(stdout); } while(1) { c = _getch(); if(c == 8) /* a backspace, we currently ignore it. i.e. treat it as doing nothing. User can alway re-do it. */ { if(p > buf) { --p; if(echo_input) { _putch(c); _putch(whitechar); _putch(c); } } } else if(c == 13) /* 13 is a return char */ { _putch(c); break; } else { /* _putch(star); */ p[0] = c; ++p; if(echo_input) { _putch(c); } } /* extra protection */ if((c == '\n') || (c == '\f') || (c == 13)) break; } p[0] = '\0'; printf("\n"); }
void PrintfProgressBar (uint64_t progress, uint64_t full) { double pg = progress * 1.0 / full; _putch ('['); for (int i = 0; i < pg * 50; i++) _putch ('-'); for (int i = 0; i < (1 - pg) * 50 - 1; i++) _putch (' '); _putch (']'); _putch ('\r'); }
void forward(int *x, int *y, int dir) { gotoxy(*x + 1, *y + 1); _putch(' '); *x = (dir == LEFT) ? --(*x) : (dir == RIGHT) ? ++(*x) : *x; *y = (dir == UP) ? --(*y) : (dir == DOWN) ? ++(*y) : *y; record(*x, *y); gotoxy(*x + 1, *y + 1); _putch(42); }
size_t CharacterProtocol::putline(const char *string) { size_t count = 0; while(string && *string && (EOF != _putch(*string))) ++count; string = eol; while(string && *string && (EOF != _putch(*string))) ++count; return count; }
char * _cgets(char *s) { char len; int ch; len=0; while (s[0]>len) { ch=_getch(); if (ch==KB_ENTER) break; //enter hit, end of input if (ch==KB_ESC) { s[1]=0; s[2]=0; return &s[2]; } if (ch==KB_BACK) { if (len>0) { len--; //delete char and go back (if some chars left) _putch(KB_BACK); _putch(' '); _putch(KB_BACK); } continue; } if (ch>0x80 || ch <' ') //skip functions keys continue; _putch((char)0xff&ch); //print back to screen s[len+2]=(char)0xff&ch; len++; } s[1]=len; s[len+2]=0; return &s[2]; }
int _tmain(int argc, _TCHAR* argv[]) { _cputs(buffer); _putch('\r'); _putch('\n'); _cputs(buffer1); //Displays buffer1 message a = _getche(); //Puts first input in variable a //Accounts for multiple numbered inputs while(a>='0' && a <= '9') { _asm sub a, 30h;// b = b * 10 + a; a = _getche(); } _putch('\r'); _putch('\n'); _cputs(buffer2); //Displays buffer2 message c = _getche(); //Puts second input in c //Accounts for multiple numbered inputs while(c>='0' && c <= '9') { _asm sub c, 30h;// d = d * 10 + c; c = _getche(); } _putch('\r'); _putch('\n'); //Calls the subtraction function sub(b,d); _putch('\r'); _putch('\n'); getche(); return 0; }
void textcolor(int color) { _putch('\033'); _putch('['); if (color & 0x8) _putch('1'); else _putch('2'); _putch('m'); _putch('\033'); _putch('['); _putch('3'); _putch(((color&0x7)%10)+'0'); _putch('m'); }
void textbackground(int color) { _putch('\033'); _putch('['); if (color & 0x8) _putch('5'); else _putch('6'); _putch('m'); _putch('\033'); _putch('['); _putch('4'); _putch((color&0x7)+'0'); _putch('m'); }
static PyObject * msvcrt_putch_impl(PyModuleDef *module, char char_value) /*[clinic end generated code: output=c05548b11554f36f input=ec078dd10cb054d6]*/ { _putch(char_value); Py_RETURN_NONE; }
void MenuConf::printItems(Item* item, int indent) { while(item) { for(int i=0; i<indent; i++) _putch(' '); if(item->data) { if(item->data->name[0]) { printf("%s: ", item->data->name); } printf("'%s'", item->data->caption); if(item->data->hotkeys) { printf(", ["); for(Hotkey* h=item->data->hotkeys; h; h=h->nextSibling) { printf(h->string); if(h->nextSibling) printf(", "); } printf("]"); } printf("\n"); } else { printf("---\n"); } printItems(item->firstChild, indent+2); item = item->nextSibling; } }
int UDBSocket_write(UDBSocket socket, unsigned char* data, int dataLength) { switch (socket->type) { case UDBSocketStandardInOut: { int i; for (i = 0; i < dataLength; i++) { _putch(data[i]); } fflush(stdout); return i; } case UDBSocketUDPClient: case UDBSocketUDPServer: { int bytesWritten; if (socket->type == UDBSocketUDPServer && socket->si_other.sin_port == 0) { UDBSocket_read(socket, NULL, 0); if (socket->si_other.sin_port == 0) { return 0; } } bytesWritten = (int)sendto(socket->fd, (char*)data, dataLength, 0, (const struct sockaddr*)&socket->si_other, sizeof(socket->si_other)); if (bytesWritten < 0) { snprintf(UDBSocketLastError, LAST_ERR_BUF_SIZE, "sendto() Error Code : %d", WSAGetLastError()); return -1; } return bytesWritten; } case UDBSocketSerial: { unsigned long bytesWritten; DWORD dwRetFlag; if (socket->hComms != 0) { dwRetFlag = WriteFile(socket->hComms, data, dataLength, &bytesWritten, NULL); if (!dwRetFlag) { snprintf(UDBSocketLastError, LAST_ERR_BUF_SIZE, "WriteFile Error = %d", GetLastError()); //ShowMessage(ErrorString); return -1; } } else { //ShowMessage("Comm port not open"); } return bytesWritten; } default: break; } return -1; }
void fillchar(const char ch, int n) { int i; for (i = 0; i < n; i++) { _putch(ch); } }
static void user_putc(char ch) { #if defined(WIN32) _putch(ch); #else write(STDIN_FILENO,&ch,1); #endif }
void _putch(char ch) { rm_ctx ctx; if (ch == '\n') { _putch('\r'); } btab->p_set_ctx(0x0E00 | ch, &ctx); btab->p_bios_call(0x10, &ctx); }
/********************************************************************* * _getche (MSVCRT.@) */ int CDECL _getche(void) { int retval; LOCK_CONSOLE; retval = _getch(); if (retval != MSVCRT_EOF) retval = _putch(retval); UNLOCK_CONSOLE; return retval; }
static int user_putsn(char *str, int n) { int rv; #if defined(WIN32) for(rv=0;rv<n;rv++) _putch(*str++); #else rv = write(STDIN_FILENO,str,n); #endif return rv; }
static PyObject *msvcrt_putch(PyObject *self, PyObject *args) { char ch; if (!PyArg_ParseTuple(args, "c:putch", &ch)) return NULL; _putch(ch); Py_INCREF(Py_None); return Py_None; }
int user_quit( const char *msg, unsigned long ulMaxTime ) { #if defined(TARGET_LIB_FOR_WINCHI) return 0; #endif #if ( !defined(TARGET_LIB_FOR_WINCHI) && defined(_WIN32) ) int quit, enter, ret; printf(msg); if ( ulMaxTime ) { inchiTime ulEndTime; InchiTimeGet( &ulEndTime ); InchiTimeAddMsec( &ulEndTime, ulMaxTime ); while ( !_kbhit() ) { if ( bInchiTimeIsOver( &ulEndTime ) ) { printf("\n"); return 0; } MySleep( 100 ); } } while( 1 ) { quit = ( 'q' == (ret = _getch()) || 'Q'==ret || /*Esc*/ 27==ret ); enter = ( '\r' == ret ); if ( ret == 0xE0 ) ret = _getch(); else _putch(ret); /* echo */ if ( quit || enter ) break; printf( "\r" ); printf( msg ); } _putch('\n'); return quit; #else return 0; #endif /* #if ( defined(_WIN32) && !defined(TARGET_LIB_FOR_WINCHI) ) */ }
void ReadPassword( char * Password ) { int c, n; n = 0; for (;;) { c = _getch(); // ^C if ( c == 0x3 ) { putchar( '\n' ); ExitProcess( 0 ); } // Backspace if ( c == 0x8 ) { if ( n ) { n--; _putch( 0x8 ); _putch( ' ' ); _putch( 0x8 ); } continue; } // Return if ( c == '\r' ) break; Password[n++] = c; _putch( '*' ); } Password[n] = 0; putchar( '\n' ); }
//벽 프린터 void draw_maze(int m[][MAZE_SIZE]) { int i, j; for (j = 0; j < MAZE_SIZE; j++) { for (i = 0; i < MAZE_SIZE; i++) { gotoxy(i + 1, j + 1); _putch(get_shape(m, i, j)); } } }
/* fgets from stdin do for some reason not work and there is no getpass ... */ static void getsn(char *s, int size, char bullet) { int i; for (i=0; i < size; i++) { if ((s[i] = _getch()) == '\r') break; _putch(bullet ? bullet : s[i]); } s[i] = 0; }
void drawfkeys(const char *fkeys[]) { const char *s; int i, j; gotoxy(1,25); for (i=0;i<10;i++) { textcolor(WHITE); textbackground(BLACK); if (i!= 0) _putch(' '); if (i== 9) { _putch('1'); _putch('0'); } else _putch((i%10)+'1'); textcolor(BLACK); textbackground(CYAN); s = fkeys[i] ? fkeys[i] : 0; for (j=0;j<6;j++) { if (s && *s) _putch(*s++); else _putch(' '); } } }
void main () { char c; int n; tree_pointer t; t = build_simple_tree(); printf("************* Command ************\n"); printf("C: Count tree, A: Add tree data \n"); printf("H: Height of tree, S: Show preorder \n"); printf("F: Free tree, Q: Quit \n"); printf("**********************************\n"); while (1) { printf("\nCommand> "); c = _getch(); _putch(c); c = toupper(c); switch (c) { case 'C' : n = bt_count(t); printf ("\n Total number of node = %d \n", n); break; case 'A' : n = bt_add(t); printf ("\n Sum of tree data = %d \n", n); break; case 'H' : n = bt_height(t); printf ("\n Height of tree = %d \n", n); break; case 'S' : printf ("\n"); bt_show_preorder(t); printf ("\n"); break; case 'F' : printf ("\n"); free_bt(t); printf ("\n"); break; case 'Q' : printf("\n"); exit(1); default : break; } } }
/* f*****g Micro$oft!!! gets - unsafe (buffer overflows) cgets - not work on Vista x64 fgets - not work on win2k sp2 because __iob_func not found in msvcrt.dll */ int s_gets(char *buff, int size) { int pn = 0; u8 ch; while ((ch = _getch()) != '\r') { if ( (ch == 0) || (ch == 0xE0) ) { _getch(); } else if (ch == 8) { if (pn > 0) { pn--; _putch(8); _putch(' '); _putch(8); } } else { if (pn < (size - 1)) { buff[pn++] = ch; _putch(ch); } } } _putch('\n'); buff[pn] = 0; return buff[0] != 0; }