Reactos
at master 39 lines 1.0 kB view raw
1// 2// cputs.cpp 3// 4// Copyright (c) Microsoft Corporation. All rights reserved. 5// 6// Defines _cputs(), which writes a string directly to the console. 7// 8#include <conio.h> 9#include <corecrt_internal_lowio.h> 10 11// Writes the given string directly to the console. No newline is appended. 12// Returns 0 on success; nonzero on failure. 13extern "C" int __cdecl _cputs(char const* const string) 14{ 15 _VALIDATE_CLEAR_OSSERR_RETURN(string != nullptr, EINVAL, -1); 16 17 __acrt_lock(__acrt_conio_lock); 18 int result = 0; 19 __try 20 { 21 // Write the string directly to the console. Each character is written 22 // individually, as performance of this function is not considered 23 // critical. 24 for (char const* p = string; *p; ++p) 25 { 26 if (_putch_nolock(*p) == EOF) 27 { 28 result = -1; 29 __leave; 30 } 31 } 32 } 33 __finally 34 { 35 __acrt_unlock(__acrt_conio_lock); 36 } 37 __endtry 38 return result; 39}