Mailing List Archive

NessusClient/nessus report_save.c,1.2,1.3
Update of /usr/local/cvs/NessusClient/nessus
In directory raccoon.nessus.org:/tmp/cvs-serv53586

Modified Files:
report_save.c
Log Message:
Open PDF files on Windows.


Index: report_save.c
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/report_save.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- report_save.c 17 Jan 2006 18:05:56 -0000 1.2
+++ report_save.c 15 Mar 2006 15:50:03 -0000 1.3
@@ -34,6 +34,13 @@
#include <gtk/gtk.h>
#include "xstuff.h"

+#ifdef CYGWIN
+#include <windows.h>
+#include <winbase.h>
+#include <shellapi.h>
+#include <sys/cygwin.h>
+#endif /* CYGWIN */
+
#include "preferences.h"
#include "context.h"
#include "error_dialog.h"
@@ -276,6 +283,8 @@
* XXX: This function eventually should be moved into a more
* suitable module.
*/
+#ifndef CYGWIN
+
void
show_pdf(filename)
char * filename;
@@ -305,6 +314,42 @@
g_free(cmd);
}
}
+
+#else /* CYGWIN */
+
+/* The cygwin version uses always the system default.
+ * A bit complicated, but it works. Nicer solution
+ * appreciated.
+ */
+void
+show_pdf(filename)
+ char * filename;
+{
+ char win32path[MAX_PATH];
+ HINSTANCE rc;
+ cygwin_conv_to_win32_path(filename, win32path);
+ rc = ShellExecute((HWND)0, NULL, win32path, NULL, NULL, SW_SHOWNORMAL);
+ if (rc <= (HINSTANCE)32)
+ {
+ char *s_buf;
+ DWORD error = GetLastError();
+ int len = FormatMessage( /* API error */
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, /* no message source */
+ error,
+ MAKELANGID(LANG_NEUTRAL,
+ SUBLANG_DEFAULT),
+ (LPTSTR) &s_buf,
+ 0, /* size not used */
+ NULL); /* no args */
+ show_error(_("Can't open PDF file: %s:\n%s"), filename, s_buf);
+ LocalFree(s_buf);
+ }
+}
+
+#endif /* CYGWIN */

void
report_open_pdf(menuitem, ctrls)

_______________________________________________
Nessus-cvs mailing list
Nessus-cvs@list.nessus.org
http://mail.nessus.org/mailman/listinfo/nessus-cvs