The WinSock library is now loaded at run-time, which means we can
[u/mdw/putty] / winstuff.h
index 411fe17..693fd42 100644 (file)
@@ -5,6 +5,10 @@
 #ifndef PUTTY_WINSTUFF_H
 #define PUTTY_WINSTUFF_H
 
+#ifndef AUTO_WINSOCK
+#include <winsock2.h>
+#endif
+#include <windows.h>
 #include <stdio.h>                    /* for FILENAME_MAX */
 
 #include "tree234.h"
@@ -23,11 +27,15 @@ struct FontSpec {
     int charset;
 };
 
+#define BOXFLAGS DLGWINDOWEXTRA
+#define BOXRESULT DLGWINDOWEXTRA + 4
+#define DF_END 0x0001
+
 /*
  * Global variables. Most modules declare these `extern', but
  * window.c will do `#define PUTTY_DO_GLOBALS' before including this
  * module, and so will get them properly defined.
- */
+*/
 #ifndef GLOBAL
 #ifdef PUTTY_DO_GLOBALS
 #define GLOBAL
@@ -126,6 +134,23 @@ GLOBAL void *logctx;
                               "All Files (*.*)\0*\0\0\0")
 
 /*
+ * winnet.c dynamically loads WinSock 2 or WinSock 1 depending on
+ * what it can get, which means any WinSock routines used outside
+ * that module must be exported from it as function pointers. So
+ * here they are.
+ */
+extern int (WINAPI *p_WSAAsyncSelect)
+    (SOCKET s, HWND hWnd, u_int wMsg, long lEvent);
+extern int (WINAPI *p_WSAEventSelect)
+    (SOCKET s, WSAEVENT hEventObject, long lNetworkEvents);
+extern int (WINAPI *p_select)
+    (int nfds, fd_set FAR * readfds, fd_set FAR * writefds,
+     fd_set FAR *exceptfds, const struct timeval FAR * timeout);
+extern int (WINAPI *p_WSAGetLastError)(void);
+extern int (WINAPI *p_WSAEnumNetworkEvents)
+    (SOCKET s, WSAEVENT hEventObject, LPWSANETWORKEVENTS lpNetworkEvents);
+
+/*
  * Exports from winctrls.c.
  */
 
@@ -163,13 +188,15 @@ struct dlgparam {
     HWND hwnd;                        /* the hwnd of the dialog box */
     struct winctrls *controltrees[8];  /* can have several of these */
     int nctrltrees;
+    char *wintitle;                   /* title of actual window */
     char *errtitle;                   /* title of error sub-messageboxes */
     void *data;                               /* data to pass in refresh events */
     union control *focused, *lastfocused; /* which ctrl has focus now/before */
+    char shortcuts[128];              /* track which shortcuts in use */
     int coloursel_wanted;             /* has an event handler asked for
                                        * a colour selector? */
-    char shortcuts[128];              /* track which shortcuts in use */
     struct { unsigned char r, g, b, ok; } coloursel_result;   /* 0-255 */
+    tree234 *privdata;                /* stores per-control private data */
     int ended, endresult;             /* has the dialog been ended? */
 };
 
@@ -283,6 +310,10 @@ int winctrl_handle_command(struct dlgparam *dp, UINT msg,
 void winctrl_rem_shortcuts(struct dlgparam *dp, struct winctrl *c);
 int winctrl_context_help(struct dlgparam *dp, HWND hwnd, int id);
 
+void dp_init(struct dlgparam *dp);
+void dp_add_tree(struct dlgparam *dp, struct winctrls *tree);
+void dp_cleanup(struct dlgparam *dp);
+
 /*
  * Exports from wincfg.c.
  */
@@ -302,6 +333,20 @@ void modal_about_box(HWND hwnd);
 void show_help(HWND hwnd);
 
 /*
+ * Exports from winmisc.c.
+ */
+
+int SaneDialogBox(HINSTANCE hinst,
+                 LPCTSTR tmpl,
+                 HWND hwndparent,
+                 DLGPROC lpDialogFunc);
+
+void SaneEndDialog(HWND hwnd, int ret);
+
+extern OSVERSIONINFO osVersion;
+BOOL init_winver(void);
+
+/*
  * Exports from sizetip.c.
  */
 void UpdateSizeTip(HWND src, int cx, int cy);
@@ -313,4 +358,16 @@ void EnableSizeTip(int bEnable);
 struct unicode_data;
 void init_ucs(Config *, struct unicode_data *);
 
+/*
+ * pageantc.c needs to schedule callbacks for asynchronous agent
+ * requests. This has to be done differently in GUI and console, so
+ * there's an exported function used for the purpose.
+ * 
+ * Also, we supply FLAG_SYNCAGENT to force agent requests to be
+ * synchronous in pscp and psftp.
+ */
+void agent_schedule_callback(void (*callback)(void *, void *, int),
+                            void *callback_ctx, void *data, int len);
+#define FLAG_SYNCAGENT 0x1000
+
 #endif