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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Fri Jun 16 00:06:11 2006 UTC (18 years, 3 months ago) by joko
Branch: MAIN
Changes since 1.1: +2 -2 lines
File MIME type: text/plain
shell command dispatching

1 joko 1.2 /* $Id: utils_misc.c,v 1.1 2006/06/15 22:58:58 joko Exp $ */
2 joko 1.1
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 joko 1.2 fprintf(stderr, "ERROR with '%s': %s (Code %i)\n", error_source, message, dwError);
36 joko 1.1 LocalFree(message);
37     }
38    
39     return TRUE;
40    
41     }

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