ReactOS 0.4.16-dev-889-g9563c07
cputs.cpp
Go to the documentation of this file.
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>
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
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 }
34 {
36 }
38 return result;
39}
#define EINVAL
Definition: acclib.h:90
#define __cdecl
Definition: accygwin.h:79
void __cdecl __acrt_unlock(_In_ __acrt_lock_id lock)
Definition: locks.cpp:57
@ __acrt_conio_lock
int __cdecl _cputs(char const *const string)
Definition: cputs.cpp:13
__acrt_lock(__acrt_heap_lock)
GLuint64EXT * result
Definition: glext.h:11304
GLfloat GLfloat p
Definition: glext.h:8902
#define EOF
Definition: stdio.h:24
#define _VALIDATE_CLEAR_OSSERR_RETURN(expr, errorcode, retexpr)
#define __try
Definition: pseh2_64.h:188
#define __leave
Definition: pseh2_64.h:192
#define __endtry
Definition: pseh2_64.h:191
#define __finally
Definition: pseh2_64.h:190
_CRTIMP int __cdecl _putch_nolock(_In_ int _Ch)