]> asedeno.scripts.mit.edu Git - PuTTY_svn.git/commitdiff
Add a nonfatal() function everywhere, to be used for reporting things
authorSimon Tatham <anakin@pobox.com>
Fri, 19 Jul 2013 17:44:28 +0000 (17:44 +0000)
committerSimon Tatham <anakin@pobox.com>
Fri, 19 Jul 2013 17:44:28 +0000 (17:44 +0000)
that the user really ought to know but that are not actually fatal to
continued operation of PuTTY or a single network connection.

git-svn-id: http://svn.tartarus.org/sgt/putty@9932 cda61777-01e9-0310-a592-d414129be87e

cmdgen.c
macosx/osxmain.m
pscp.c
psftp.c
putty.h
unix/gtkdlg.c
unix/unix.h
unix/uxplink.c
windows/window.c
windows/winplink.c

index 33662c3be9f055bfd438d341b746961a71139794..69c0177c0878fddbffcca1ce6665760957aae316 100644 (file)
--- a/cmdgen.c
+++ b/cmdgen.c
@@ -102,6 +102,16 @@ void modalfatalbox(char *p, ...)
     cleanup_exit(1);
 }
 
+void nonfatal(char *p, ...)
+{
+    va_list ap;
+    fprintf(stderr, "ERROR: ");
+    va_start(ap, p);
+    vfprintf(stderr, p, ap);
+    va_end(ap);
+    fputc('\n', stderr);
+}
+
 /*
  * Stubs to let everything else link sensibly.
  */
index d8202e24960cdda4949c2be01a63313f3bfc3e2f..2eba150c39a5160f5964b4c0634359d31c7ff200 100644 (file)
@@ -85,6 +85,24 @@ static void commonfatalbox(char *p, va_list ap)
     exit(1);
 }
 
+void nonfatal(void *frontend, char *p, ...)
+{
+    char *errorbuf;
+    NSAlert *alert;
+    va_list ap;
+
+    va_start(ap, p);
+    errorbuf = dupvprintf(p, ap);
+    va_end(ap);
+
+    alert = [[[NSAlert alloc] init] autorelease];
+    [alert addButtonWithTitle:@"Error"];
+    [alert setInformativeText:[NSString stringWithCString:errorbuf]];
+    [alert runModal];
+
+    sfree(errorbuf);
+}
+
 void fatalbox(char *p, ...)
 {
     va_list ap;
diff --git a/pscp.c b/pscp.c
index 70e3e7a111d9410eb5617be788531be80d927d24..2eecad6dbbfb0e8689a136b5d73efad0af0a5750 100644 (file)
--- a/pscp.c
+++ b/pscp.c
@@ -129,6 +129,19 @@ void modalfatalbox(char *fmt, ...)
 
     cleanup_exit(1);
 }
+void nonfatal(char *fmt, ...)
+{
+    char *str, *str2;
+    va_list ap;
+    va_start(ap, fmt);
+    str = dupvprintf(fmt, ap);
+    str2 = dupcat("Error: ", str, "\n", NULL);
+    sfree(str);
+    va_end(ap);
+    tell_str(stderr, str2);
+    sfree(str2);
+    errs++;
+}
 void connection_fatal(void *frontend, char *fmt, ...)
 {
     char *str, *str2;
diff --git a/psftp.c b/psftp.c
index 322b9c687ee0b42a8546e742d009586a0b38130c..6dd733d9385ab990355d915db3f6cf41e4386af6 100644 (file)
--- a/psftp.c
+++ b/psftp.c
@@ -2477,6 +2477,18 @@ void modalfatalbox(char *fmt, ...)
 
     cleanup_exit(1);
 }
+void nonfatal(char *fmt, ...)
+{
+    char *str, *str2;
+    va_list ap;
+    va_start(ap, fmt);
+    str = dupvprintf(fmt, ap);
+    str2 = dupcat("Error: ", str, "\n", NULL);
+    sfree(str);
+    va_end(ap);
+    fputs(str2, stderr);
+    sfree(str2);
+}
 void connection_fatal(void *frontend, char *fmt, ...)
 {
     char *str, *str2;
diff --git a/putty.h b/putty.h
index 6534da7403f3f83bb059f99b0488ff4249212f2b..e5c641d30faa03fce236d3c000e70afa1b66206c 100644 (file)
--- a/putty.h
+++ b/putty.h
@@ -589,6 +589,7 @@ void get_clip(void *frontend, wchar_t **, int *);
 void optimised_move(void *frontend, int, int, int);
 void set_raw_mouse_mode(void *frontend, int);
 void connection_fatal(void *frontend, char *, ...);
+void nonfatal(char *, ...);
 void fatalbox(char *, ...);
 void modalfatalbox(char *, ...);
 #ifdef macintosh
index 50aa4fad5c1856592291d0cd47854222a670ed72..6020497cb74a5bc98a0d90d4c5e144f62a95b5a5 100644 (file)
@@ -3389,6 +3389,13 @@ void fatal_message_box(void *window, char *msg)
                "OK", 'o', 1, 1, NULL);
 }
 
+void nonfatal_message_box(void *window, char *msg)
+{
+    messagebox(window, "PuTTY Error", msg,
+               string_width("REASONABLY LONG LINE OF TEXT FOR BASIC SANITY"),
+               "OK", 'o', 1, 1, NULL);
+}
+
 void fatalbox(char *p, ...)
 {
     va_list ap;
@@ -3401,6 +3408,17 @@ void fatalbox(char *p, ...)
     cleanup_exit(1);
 }
 
+void nonfatal(char *p, ...)
+{
+    va_list ap;
+    char *msg;
+    va_start(ap, p);
+    msg = dupvprintf(p, ap);
+    va_end(ap);
+    fatal_message_box(NULL, msg);
+    sfree(msg);
+}
+
 static GtkWidget *aboutbox = NULL;
 
 static void about_close_clicked(GtkButton *button, gpointer data)
index 91d0642309afbecbbe94cdaddb354b78bf62eb38..3af9eebb30ab64448fc712dbf7dfc506cf642886 100644 (file)
@@ -88,6 +88,7 @@ void *get_window(void *frontend);      /* void * to avoid depending on gtk.h */
 int do_config_box(const char *title, Conf *conf,
                  int midsession, int protcfginfo);
 void fatal_message_box(void *window, char *msg);
+void nonfatal_message_box(void *window, char *msg);
 void about_box(void *window);
 void *eventlogstuff_new(void);
 void showeventlog(void *estuff, void *parentwin);
index 560ec386d0f011bcde07c7c9210605a727780877..9e10c488c2e1c635d82740d4eaef75ed127f4bc8 100644 (file)
@@ -63,6 +63,22 @@ void modalfatalbox(char *p, ...)
     }
     cleanup_exit(1);
 }
+void nonfatal(char *p, ...)
+{
+    struct termios cf;
+    va_list ap;
+    premsg(&cf);
+    fprintf(stderr, "ERROR: ");
+    va_start(ap, p);
+    vfprintf(stderr, p, ap);
+    va_end(ap);
+    fputc('\n', stderr);
+    postmsg(&cf);
+    if (logctx) {
+        log_free(logctx);
+        logctx = NULL;
+    }
+}
 void connection_fatal(void *frontend, char *p, ...)
 {
     struct termios cf;
index b7f5f8672427c9932b47ea8e57d426df0f87e3ba..38270e6877e798203827302eb653a643b54c25ae 100644 (file)
@@ -5342,6 +5342,22 @@ void modalfatalbox(char *fmt, ...)
     cleanup_exit(1);
 }
 
+/*
+ * Print a message box and don't close the connection.
+ */
+void nonfatal(char *fmt, ...)
+{
+    va_list ap;
+    char *stuff, morestuff[100];
+
+    va_start(ap, fmt);
+    stuff = dupvprintf(fmt, ap);
+    va_end(ap);
+    sprintf(morestuff, "%.70s Error", appname);
+    MessageBox(hwnd, stuff, morestuff, MB_ICONERROR | MB_OK);
+    sfree(stuff);
+}
+
 DECL_WINDOWS_FUNCTION(static, BOOL, FlashWindowEx, (PFLASHWINFO));
 
 static void init_flashwindow(void)
index dfbb80d84de3eb352de6c9a10b932ab16b0db66e..37453bb734ae87abeed26f7f7359db6759d1d41f 100644 (file)
@@ -49,6 +49,19 @@ void modalfatalbox(char *p, ...)
     }
     cleanup_exit(1);
 }
+void nonfatal(char *p, ...)
+{
+    va_list ap;
+    fprintf(stderr, "ERROR: ");
+    va_start(ap, p);
+    vfprintf(stderr, p, ap);
+    va_end(ap);
+    fputc('\n', stderr);
+    if (logctx) {
+        log_free(logctx);
+        logctx = NULL;
+    }
+}
 void connection_fatal(void *frontend, char *p, ...)
 {
     va_list ap;