unix.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #ifndef PUTTY_UNIX_H
  2. #define PUTTY_UNIX_H
  3. #include <stdio.h> /* for FILENAME_MAX */
  4. #include "charset.h"
  5. struct Filename {
  6. char path[FILENAME_MAX];
  7. };
  8. #define f_open(filename, mode) ( fopen((filename).path, (mode)) )
  9. struct FontSpec {
  10. char name[256];
  11. };
  12. typedef void *Context; /* FIXME: probably needs changing */
  13. typedef int OSSocket;
  14. #define OSSOCKET_DEFINED /* stop network.h using its default */
  15. extern Backend pty_backend;
  16. /*
  17. * Under GTK, we send MA_CLICK _and_ MA_2CLK, or MA_CLICK _and_
  18. * MA_3CLK, when a button is pressed for the second or third time.
  19. */
  20. #define MULTICLICK_ONLY_EVENT 0
  21. /*
  22. * Under GTK, there is no context help available.
  23. */
  24. #define HELPCTX(x) P(NULL)
  25. #define FILTER_KEY_FILES NULL /* FIXME */
  26. /*
  27. * Under X, selection data must not be NUL-terminated.
  28. */
  29. #define SELECTION_NUL_TERMINATED 0
  30. /*
  31. * Under X, copying to the clipboard terminates lines with just LF.
  32. */
  33. #define SEL_NL { 10 }
  34. /* Simple wraparound timer function */
  35. unsigned long getticks(void); /* based on gettimeofday(2) */
  36. #define GETTICKCOUNT getticks
  37. #define TICKSPERSEC 1000000 /* gettimeofday returns microseconds */
  38. #define CURSORBLINK 450000 /* no standard way to set this */
  39. #define WCHAR wchar_t
  40. #define BYTE unsigned char
  41. /* Things pty.c needs from pterm.c */
  42. char *get_x_display(void *frontend);
  43. int font_dimension(void *frontend, int which);/* 0 for width, 1 for height */
  44. long get_windowid(void *frontend);
  45. /* Things gtkdlg.c needs from pterm.c */
  46. void *get_window(void *frontend); /* void * to avoid depending on gtk.h */
  47. /* Things pterm.c needs from gtkdlg.c */
  48. int do_config_box(const char *title, Config *cfg, int midsession);
  49. void fatal_message_box(void *window, char *msg);
  50. void about_box(void *window);
  51. void *eventlogstuff_new(void);
  52. void showeventlog(void *estuff, void *parentwin);
  53. void logevent_dlg(void *estuff, const char *string);
  54. int reallyclose(void *frontend);
  55. /* Things pterm.c needs from {ptermm,uxputty}.c */
  56. char *make_default_wintitle(char *hostname);
  57. int process_nonoption_arg(char *arg, Config *cfg);
  58. /* pterm.c needs this special function in xkeysym.c */
  59. int keysym_to_unicode(int keysym);
  60. /* Things uxstore.c needs from pterm.c */
  61. char *x_get_default(const char *key);
  62. /* Things uxstore.c provides to pterm.c */
  63. void provide_xrm_string(char *string);
  64. /* The interface used by uxsel.c */
  65. void uxsel_init(void);
  66. typedef int (*uxsel_callback_fn)(int fd, int event);
  67. void uxsel_set(int fd, int rwx, uxsel_callback_fn callback);
  68. void uxsel_del(int fd);
  69. int select_result(int fd, int event);
  70. int first_fd(int *state, int *rwx);
  71. int next_fd(int *state, int *rwx);
  72. /* The following are expected to be provided _to_ uxsel.c by the frontend */
  73. int uxsel_input_add(int fd, int rwx); /* returns an id */
  74. void uxsel_input_remove(int id);
  75. /* uxcfg.c */
  76. struct controlbox;
  77. void unix_setup_config_box(struct controlbox *b, int midsession, void *window);
  78. /*
  79. * In the Unix Unicode layer, DEFAULT_CODEPAGE is a special value
  80. * which causes mb_to_wc and wc_to_mb to call _libc_ rather than
  81. * libcharset. That way, we can interface the various charsets
  82. * supported by libcharset with the one supported by mbstowcs and
  83. * wcstombs (which will be the character set in which stuff read
  84. * from the command line or config files is assumed to be encoded).
  85. */
  86. #define DEFAULT_CODEPAGE 0xFFFF
  87. #define CP_UTF8 CS_UTF8 /* from libcharset */
  88. #define strnicmp strncasecmp
  89. #define stricmp strcasecmp
  90. /* BSD-semantics version of signal() */
  91. void (*putty_signal(int sig, void (*func)(int)))(int);
  92. /*
  93. * Exports from unicode.c.
  94. */
  95. struct unicode_data;
  96. int init_ucs(struct unicode_data *ucsdata, char *line_codepage,
  97. int utf8_override, int font_charset, int vtmode);
  98. /*
  99. * Spare function exported directly from uxnet.c.
  100. */
  101. int sk_getxdmdata(void *sock, unsigned long *ip, int *port);
  102. /*
  103. * General helpful Unix stuff: more helpful version of the FD_SET
  104. * macro, which also handles maxfd.
  105. */
  106. #define FD_SET_MAX(fd, max, set) do { \
  107. FD_SET(fd, &set); \
  108. if (max < fd + 1) max = fd + 1; \
  109. } while (0)
  110. #endif