Use git-describe to determine release version
[cygwin-setup.git] / msg.cc
blobd0cbfa2b23553a8cf9e0a33df651fd9a87bc747d
1 /*
2 * Copyright (c) 2000, Red Hat, Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
10 * http://www.gnu.org/
12 * Written by DJ Delorie <dj@cygnus.com>
16 /* The purpose of this file is to centralize all the message
17 functions. */
19 #if 0
20 static const char *cvsid =
21 "\n%%% $Id$\n";
22 #endif
24 #include "msg.h"
26 #include "LogFile.h"
27 #include "win32.h"
29 #include <stdio.h>
30 #include <stdarg.h>
31 #include "dialog.h"
32 #include "state.h"
34 void
35 msg (const char *fmt, ...)
37 char buf[2000];
38 va_list args;
39 va_start (args, fmt);
40 vsnprintf (buf, 2000, fmt, args);
41 OutputDebugString (buf);
44 int
45 mbox (HWND owner, const char *buf, const char *name, int type)
47 Log (LOG_PLAIN) << "mbox " << name << ": " << buf << endLog;
48 if (unattended_mode)
50 // Return some default values.
51 Log (LOG_PLAIN) << "unattended_mode is set at mbox: returning default value" << endLog;
52 switch (type & MB_TYPEMASK)
54 case MB_OK:
55 case MB_OKCANCEL:
56 return IDOK;
57 break;
58 case MB_YESNO:
59 case MB_YESNOCANCEL:
60 return IDYES;
61 break;
62 case MB_ABORTRETRYIGNORE:
63 return IDIGNORE;
64 break;
65 case MB_RETRYCANCEL:
66 return IDCANCEL;
67 break;
68 default:
69 Log (LOG_PLAIN) << "unattended_mode failed for " << (type & MB_TYPEMASK) << endLog;
70 return 0;
73 return MessageBox (owner, buf, "Cygwin Setup", type);
76 static int
77 mbox (HWND owner, const char *name, int type, int id, va_list args)
79 char buf[1000], fmt[1000];
81 if (LoadString (hinstance, id, fmt, sizeof (fmt)) <= 0)
82 ExitProcess (0);
84 vsnprintf (buf, 1000, fmt, args);
85 return mbox(owner, buf, name, type);
88 void
89 note (HWND owner, int id, ...)
91 va_list args;
92 va_start (args, id);
93 mbox (owner, "note", 0, id, args);
96 void
97 fatal (HWND owner, int id, ...)
99 va_list args;
100 va_start (args, id);
101 mbox (owner, "fatal", 0, id, args);
102 Logger ().exit (1);
106 yesno (HWND owner, int id, ...)
108 va_list args;
109 va_start (args, id);
110 return mbox (owner, "yesno", MB_YESNO, id, args);