/[cvs]/joko/Uni/BSArch/03/win32/utils_misc.c
ViewVC logotype

Contents of /joko/Uni/BSArch/03/win32/utils_misc.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Thu Jun 15 22:58:58 2006 UTC (18 years, 3 months ago) by joko
Branch: MAIN
File MIME type: text/plain
refactoring

1 /* $Id: min_shell.c,v 1.5 2006/06/15 22:15:10 joko Exp $ */
2
3 #include <stdio.h>
4 #include <windows.h>
5
6 // if last char is newline, "strip" it
7 void chomp(char * string) {
8 int string_length = strlen(string);
9 if (string[string_length-1] == '\n') {
10 string[string_length-1] = '\0';
11 }
12 }
13
14 // checks for errors and writes its message to stderr
15 BOOL check_alert_error(const char * error_source) {
16 DWORD dwError = GetLastError();
17
18 HLOCAL message = NULL;
19 BOOL fOk;
20
21 if (dwError == 0)
22 return FALSE;
23
24 fOk = FormatMessage(
25 FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER,
26 NULL,
27 dwError,
28 MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT),
29 (PTSTR)&message,
30 0,
31 NULL
32 );
33
34 if (message != NULL) {
35 fprintf(stderr, "Error with '%s': %s (Code %i)\n", error_source, message, dwError);
36 LocalFree(message);
37 }
38
39 return TRUE;
40
41 }

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed