Skip to content
Browse files

gh-6: Compile with automake on Ubuntu

  • Loading branch information...
1 parent de7cedc commit 92cd7a130e287ae0a53f86e93e346b82b36af321 @FauxFaux committed Oct 26, 2011
Showing with 81 additions and 322 deletions.
  1. +12 −2 adb.c
  2. +4 −2 mkfiles.pl
  3. +3 −0 putty.h
  4. +2 −0 settings.c
  5. +1 −1 terminal.c
  6. +1 −1 unix/gtkdlg.c
  7. +2 −2 unix/gtkwin.c
  8. +37 −0 unix/urlhack_unix.c
  9. +4 −1 unix/uxstore.c
  10. +3 −116 urlhack.cpp
  11. +5 −5 windows/re_lib/regexp.cpp
  12. +2 −2 windows/re_lib/regexp.h
  13. +4 −3 windows/urlhack.h
  14. +1 −187 windows/urlhack_win.cpp
View
14 adb.c
@@ -192,8 +192,18 @@ static const char *adb_init(void *frontend_handle, void **backend_handle,
}
/* send initial data to adb server */
-
- sprintf_s(sendhost,512,"%04xhost:%s",strlen(host)+5,host);
+#if _MSC_VER
+ sprintf_s
+#else
+ snprintf
+#endif
+ (sendhost, 512,
+#if _MSC_VER
+ "%04xhost:%s"
+#else
+ "%04zxhost:%s"
+#endif
+ , strlen(host)+5, host);
sk_write(adb->s,sendhost,strlen(host)+9);
sk_flush(adb->s);
View
6 mkfiles.pl
@@ -972,8 +972,6 @@ sub manpages {
"ULDFLAGS = \$(LDFLAGS)\n".
"ifeq (,\$(findstring NO_GSSAPI,\$(COMPAT)))\n".
"ifeq (,\$(findstring STATIC_GSSAPI,\$(COMPAT)))\n".
- "XLDFLAGS+= -ldl\n".
- "ULDFLAGS+= -ldl\n".
"else\n".
"CFLAGS+= -DNO_LIBDL \$(shell \$(KRB5CONFIG) --cflags gssapi)\n".
"XLDFLAGS+= \$(shell \$(KRB5CONFIG) --libs gssapi)\n".
@@ -1047,6 +1045,8 @@ sub manpages {
(join " ", map {"-I$dirpfx$_"} @srcdirs)).
" -D _FILE_OFFSET_BITS=64\n".
"ULDFLAGS = \$(LDFLAGS)\n".
+ "XLDFLAGS+= -ldl\n".
+ "ULDFLAGS+= -ldl\n".
"INSTALL=install\n".
"INSTALL_PROGRAM=\$(INSTALL)\n".
"INSTALL_DATA=\$(INSTALL)\n".
@@ -1109,6 +1109,8 @@ sub manpages {
(join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
"XLDFLAGS = \@LDFLAGS\@ \@LIBS\@ \@GTK_LIBS\@\n".
"ULDFLAGS = \@LDFLAGS\@ \@LIBS\@\n".
+ "XLDFLAGS+= -ldl -lstdc++\n".
+ "ULDFLAGS+= -ldl -lstdc++\n".
"INSTALL=\@INSTALL\@\n".
"INSTALL_PROGRAM=\$(INSTALL)\n".
"INSTALL_DATA=\$(INSTALL)\n".
View
3 putty.h
@@ -716,6 +716,9 @@ struct config_tag {
int url_underline;
int url_defbrowser;
int url_defregex;
+#ifndef MAX_PATH
+# define MAX_PATH 260
+#endif
char url_browser[MAX_PATH];
char url_regex[1024];
View
2 settings.c
@@ -52,6 +52,8 @@ const char *const ttymodes[] = {
"CS8", "PARENB", "PARODD", NULL
};
+const char* urlhack_default_regex = "((((https?|ftp):\\/\\/)|www\\.)(([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+)|localhost|([a-zA-Z0-9\\-]+\\.)*[a-zA-Z0-9\\-]+\\.(com|net|org|info|biz|gov|name|edu|[a-zA-Z][a-zA-Z]))(:[0-9]+)?((\\/|\\?)[^ \"]*[^ ,;\\.:\">)])?)|(spotify:[^ ]+:[^ ]+)";
+
/*
* Convenience functions to access the backends[] array
* (which is only present in tools that manage settings).
View
2 terminal.c
@@ -5903,7 +5903,7 @@ void term_mouse(Terminal *term, Mouse_Button braw, Mouse_Button bcooked,
}
else {
termline *urldata = scrlineptr(region.y0);
- int linklen, pos = region.x0, row = region.y0;
+ int linklen, row = region.y0;
linklen = (term->cols - region.x0) +
((region.y1 - region.y0 - 1) * term->cols) + region.x1 + 1;
View
2 unix/gtkdlg.c
@@ -2859,7 +2859,7 @@ int do_config_box(const char *title, Config *cfg, int midsession,
window = gtk_dialog_new();
ctrlbox = ctrl_new_box();
- setup_config_box(ctrlbox, midsession, cfg->protocol, protcfginfo);
+ setup_config_box(ctrlbox, midsession, cfg->protocol, protcfginfo, -1);
unix_setup_config_box(ctrlbox, midsession, cfg->protocol);
gtk_setup_config_box(ctrlbox, midsession, window);
View
4 unix/gtkwin.c
@@ -3197,7 +3197,7 @@ static void update_savedsess_menu(GtkMenuItem *menuitem, gpointer data)
gtk_container_foreach(GTK_CONTAINER(inst->sessionsmenu),
(GtkCallback)gtk_widget_destroy, NULL);
- get_sesslist(&sesslist, TRUE);
+ get_sesslist(&sesslist, TRUE, -1);
/* skip sesslist.sessions[0] == Default Settings */
for (i = 1; i < sesslist.nsessions; i++) {
GtkWidget *menuitem =
@@ -3220,7 +3220,7 @@ static void update_savedsess_menu(GtkMenuItem *menuitem, gpointer data)
gtk_container_add(GTK_CONTAINER(inst->sessionsmenu), menuitem);
gtk_widget_show(menuitem);
}
- get_sesslist(&sesslist, FALSE); /* free up */
+ get_sesslist(&sesslist, FALSE, -1); /* free up */
}
void set_window_icon(GtkWidget *window, const char *const *const *icon,
View
37 unix/urlhack_unix.c
@@ -0,0 +1,37 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "urlhack.h"
+
+void urlhack_launch_url(const char* app, const char *url)
+{
+ const size_t max = 4000;
+ char buf[max];
+ const char *browser = NULL;
+
+ if (app)
+ browser = app;
+ if (NULL == browser || 0 == strlen(browser))
+ browser = "xdg-open";
+
+ snprintf(buf, max, "%s %s", browser, url);
+
+ if (!system(buf))
+ printf("couldn't run browser: %s", buf);
+}
+
+int urlhack_is_ctrl_pressed()
+{
+ // TODO
+ return 1;
+}
+
+
+void rtfm(const char *error)
+{
+ // TODO
+}
+
+
+
View
5 unix/uxstore.c
@@ -439,7 +439,10 @@ void del_settings(const char *sessionname)
sfree(filename);
}
-void *enum_settings_start(void)
+void set_storagetype(int storagetype_IGNORED) {
+}
+
+void *enum_settings_start(int storagetype_IGNORED)
{
DIR *dp;
char *filename;
View
119 urlhack.cpp
@@ -1,19 +1,11 @@
-/*
- * HACK: PuttyTray / Nutty
- * Hyperlink stuff: CORE FILE! Don't forget to COPY IT TO THE NEXT VERSION
- */
-#include <windows.h>
#include <vector>
+#include <string>
#include <sstream>
#include "urlhack.h"
-extern int urlhack_mouse_old_x = -1, urlhack_mouse_old_y = -1, urlhack_current_region = -1;
+int urlhack_mouse_old_x = -1, urlhack_mouse_old_y = -1, urlhack_current_region = -1;
static std::vector<text_region> link_regions;
-static std::string browser_app;
-
-extern const char* urlhack_default_regex = "((((https?|ftp):\\/\\/)|www\\.)(([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+)|localhost|([a-zA-Z0-9\\-]+\\.)*[a-zA-Z0-9\\-]+\\.(com|net|org|info|biz|gov|name|edu|[a-zA-Z][a-zA-Z]))(:[0-9]+)?((\\/|\\?)[^ \"]*[^ ,;\\.:\">)])?)|(spotify:[^ ]+:[^ ]+)";
-
void urlhack_clear_link_regions()
{
@@ -103,96 +95,6 @@ void urlhack_add_link_region(int x0, int y0, int x1, int y1)
}
-
-void urlhack_launch_url(const char* app, const char *url)
-{
- if (app) {
- ShellExecute(NULL, NULL, app, url, NULL, SW_SHOW);
- return;
- }
-
- if (browser_app.size() == 0) {
- // first let the OS try...
- if (reinterpret_cast<long>(ShellExecute(NULL, NULL, url, NULL, NULL, SW_SHOWNORMAL)) > 32) {
- return;
- }
-
- // Find out the default app
- HKEY key;
- DWORD dwValue;
- char *str;
- std::string lookup;
-
- if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice", 0, KEY_READ, &key) == ERROR_SUCCESS) {
- if (RegQueryValueEx(key, "Progid", NULL, NULL, NULL, &dwValue) == ERROR_SUCCESS)
- {
- str = new char[dwValue + 1];
-
- RegQueryValueEx(key, "Progid", NULL, NULL, (BYTE*)str, &dwValue);
- RegCloseKey(key);
-
- std::stringstream buffer;
- buffer << str << "\\shell\\open\\command";
- lookup = buffer.str();
-
- delete [] str;
- }
- }
-
- if (RegOpenKeyEx(HKEY_CLASSES_ROOT, lookup.length() > 0 ? lookup.c_str() : "HTTP\\shell\\open\\command", 0, KEY_READ, &key) == ERROR_SUCCESS) {
- if (!RegQueryValueEx(key, NULL, NULL, NULL, NULL, &dwValue) == ERROR_SUCCESS) return;
-
- str = new char[dwValue + 1];
-
- RegQueryValueEx(key, NULL, NULL, NULL, (BYTE*)str, &dwValue);
- RegCloseKey(key);
-
- browser_app = str;
- delete[] str;
-
- // Drop all stuff from the path and leave only the executable and the path
-
- if (browser_app.at(0) == '"') {
- browser_app.erase(0, 1);
-
- if (browser_app.find('"') > 0)
- browser_app.resize(browser_app.find('"'));
- }
- else {
- if (browser_app.find(' ') > 0)
- browser_app.resize(browser_app.find(' '));
- }
- }
- else {
- MessageBox(NULL, "Could not find your default browser.", "PuTTY Tray Error", MB_OK | MB_ICONINFORMATION);
- }
- }
-
- std::string u = url;
-
- if (u.find("http://") == std::string::npos && u.find("https://") == std::string::npos &&
- u.find("ftp://") == std::string::npos && u.find("ftps://") == std::string::npos) {
- if (u.find("ftp.") != std::string::npos)
- u.insert(0, "ftp://");
- else
- u.insert(0, "http://");
- }
-
- ShellExecute(NULL, NULL, browser_app.c_str(), u.c_str(), NULL, SW_SHOW);
-}
-
-
-
-
-
-
-int urlhack_is_ctrl_pressed()
-{
- return HIWORD(GetAsyncKeyState(VK_CONTROL));
-}
-
-
-
// Regular expression stuff
static int urlhack_disabled = 0;
@@ -217,21 +119,6 @@ void urlhack_putchar(char ch)
-static void rtfm(char *error)
-{
- std::string error_msg = "The following error occured when compiling the regular expression\n" \
- "for the hyperlink support. Hyperlink detection is disabled during\n" \
- "this session (restart PuTTY Tray to try again).\n\n";
-
- std::string actual_error_msg = error_msg;
-
- actual_error_msg.append(error);
-
- MessageBox(0, actual_error_msg.c_str(), "PuTTY Tray Error", MB_OK);
-}
-
-
-
void urlhack_set_regular_expression(const char* expression)
{
is_regexp_compiled = 0;
@@ -288,4 +175,4 @@ void urlhack_go_find_me_some_hyperlinks(int screen_width)
text_pos = end_pos + 1;
}
-}
+}
View
10 windows/re_lib/regexp.cpp
@@ -174,15 +174,15 @@ STATIC void regoptail( char* p, char* val);
STATIC int strcspn();
#endif
-static void (*regerror_func)( char* s) = 0;
+static void (*regerror_func)( const char* s) = 0;
-void regerror( char* s)
+void regerror( const char* s)
{
if( regerror_func)
(*regerror_func)( s);
}
-void set_regerror_func( void (*func)( char*))
+void set_regerror_func( void (*func)( const char*))
{
regerror_func = func;
}
@@ -208,7 +208,7 @@ regcomp( char* exp)
register regexp *r;
register char *scan;
register char *longest;
- register int len;
+ register size_t len;
int flags;
if (exp == NULL)
@@ -294,7 +294,7 @@ reg( int paren, int* flagp) /* paren - Parenthesized? */
register char *ret;
register char *br;
register char *ender;
- register int parno;
+ register int parno = 0;
int flags;
*flagp = HASWIDTH; /* Tentatively. */
View
4 windows/re_lib/regexp.h
@@ -11,12 +11,12 @@ typedef struct regexp {
char regstart; /* Internal use only. */
char reganch; /* Internal use only. */
char *regmust; /* Internal use only. */
- int regmlen; /* Internal use only. */
+ size_t regmlen; /* Internal use only. */
char program[1]; /* Unwarranted chumminess with compiler. */
} regexp;
regexp *regcomp( char* re);
int regexec( regexp* r, char* str);
void regsub( regexp* r, char* str, char* substr);
void regerror( char* s); /* for internal use only */
-void set_regerror_func( void (*func)( char*));
+void set_regerror_func( void (*func)( const char*));
View
7 windows/urlhack.h
@@ -14,8 +14,8 @@ typedef struct { int x0, y0, x1, y1; } text_region;
extern "C" {
#endif
-const char* urlhack_default_regex;
-int urlhack_mouse_old_x, urlhack_mouse_old_y, urlhack_current_region;
+extern const char* urlhack_default_regex;
+extern int urlhack_mouse_old_x, urlhack_mouse_old_y, urlhack_current_region;
void urlhack_reset();
void urlhack_go_find_me_some_hyperlinks(int screen_width);
@@ -30,11 +30,12 @@ void urlhack_add_link_region(int x0, int y0, int x1, int y1);
void urlhack_launch_url(const char* app, const char *url);
int urlhack_is_ctrl_pressed();
void urlhack_set_regular_expression(const char* expression);
+void rtfm(const char *error);
#ifdef __cplusplus
}
#endif
-#endif // _URLHACK_H
+#endif // _URLHACK_H
View
188 windows/urlhack_win.cpp
@@ -1,109 +1,10 @@
-/*
- * HACK: PuttyTray / Nutty
- * Hyperlink stuff: CORE FILE! Don't forget to COPY IT TO THE NEXT VERSION
- */
#include <windows.h>
#include <vector>
#include <sstream>
#include "urlhack.h"
-extern int urlhack_mouse_old_x = -1, urlhack_mouse_old_y = -1, urlhack_current_region = -1;
-
-static std::vector<text_region> link_regions;
static std::string browser_app;
-extern const char* urlhack_default_regex = "((((https?|ftp):\\/\\/)|www\\.)(([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+)|localhost|([a-zA-Z0-9\\-]+\\.)*[a-zA-Z0-9\\-]+\\.(com|net|org|info|biz|gov|name|edu|[a-zA-Z][a-zA-Z]))(:[0-9]+)?((\\/|\\?)[^ \"]*[^ ,;\\.:\">)])?)|(spotify:[^ ]+:[^ ]+)";
-
-
-void urlhack_clear_link_regions()
-{
- link_regions.clear();
-}
-
-
-
-int urlhack_is_in_link_region(int x, int y)
-{
- std::vector<text_region>::iterator i = link_regions.begin();
- int loopCounter = 1;
-
- while (i != link_regions.end()) {
- text_region r = *i;
-
- if ((r.y0 == r.y1 && y == r.y0 && y == r.y1 && x >= r.x0 && x < r.x1) ||
- (r.y0 != r.y1 && ((y == r.y0 && x >= r.x0) || (y == r.y1 && x < r.x1) || (y > r.y0 && y < r.y1))))
- return loopCounter; //Changed: was return true
-
- loopCounter++;
- i++;
- }
-
- return false;
-}
-
-
-
-int urlhack_is_in_this_link_region(text_region r, int x, int y)
-{
- if ((r.y0 == r.y1 && y == r.y0 && y == r.y1 && x >= r.x0 && x < r.x1) || (r.y0 != r.y1 && ((y == r.y0 && x >= r.x0) || (y == r.y1 && x < r.x1) || (y > r.y0 && y < r.y1)))) {
- return true;
- }
-
- return false;
-}
-
-
-
-text_region urlhack_get_link_bounds(int x, int y)
-{
- std::vector<text_region>::iterator i = link_regions.begin();
-
- while (i != link_regions.end()) {
- text_region r = *i;
-
- if ((r.y0 == r.y1 && y == r.y0 && y == r.y1 && x >= r.x0 && x < r.x1) ||
- (r.y0 != r.y1 && ((y == r.y0 && x >= r.x0) || (y == r.y1 && x < r.x1) || (y > r.y0 && y < r.y1))))
- return *i;
-
- i++;
- }
-
- text_region region;
- region.x0 = region.y0 = region.x1 = region.y1 = -1;
- return region;
-}
-
-
-
-text_region urlhack_get_link_region(int index)
-{
- text_region region;
-
- if (index < 0 || index >= (int)link_regions.size()) {
- region.x0 = region.y0 = region.x1 = region.y1 = -1;
- return region;
- }
- else {
- return link_regions.at(index);
- }
-}
-
-
-
-void urlhack_add_link_region(int x0, int y0, int x1, int y1)
-{
- text_region region;
-
- region.x0 = x0;
- region.y0 = y0;
- region.x1 = x1;
- region.y1 = y1;
-
- link_regions.insert(link_regions.end(), region);
-}
-
-
-
void urlhack_launch_url(const char* app, const char *url)
{
if (app) {
@@ -181,43 +82,13 @@ void urlhack_launch_url(const char* app, const char *url)
ShellExecute(NULL, NULL, browser_app.c_str(), u.c_str(), NULL, SW_SHOW);
}
-
-
-
-
-
int urlhack_is_ctrl_pressed()
{
return HIWORD(GetAsyncKeyState(VK_CONTROL));
}
-
-// Regular expression stuff
-
-static int urlhack_disabled = 0;
-static int is_regexp_compiled = 0;
-static regexp* urlhack_rx;
-static std::string text_mass;
-
-
-
-void urlhack_reset()
-{
- text_mass.clear();
-}
-
-
-
-void urlhack_putchar(char ch)
-{
- char r00fles[2] = { ch, 0 };
- text_mass.append(r00fles);
-}
-
-
-
-static void rtfm(char *error)
+void rtfm(const char *error)
{
std::string error_msg = "The following error occured when compiling the regular expression\n" \
"for the hyperlink support. Hyperlink detection is disabled during\n" \
@@ -232,60 +103,3 @@ static void rtfm(char *error)
-void urlhack_set_regular_expression(const char* expression)
-{
- is_regexp_compiled = 0;
- urlhack_disabled = 0;
-
- set_regerror_func(rtfm);
- urlhack_rx = regcomp(const_cast<char*>(expression));
-
- if (urlhack_rx == 0) {
- urlhack_disabled = 1;
- }
-
- is_regexp_compiled = 1;
-}
-
-
-
-void urlhack_go_find_me_some_hyperlinks(int screen_width)
-{
- if (urlhack_disabled != 0) return;
-
- if (is_regexp_compiled == 0) {
- urlhack_set_regular_expression(urlhack_default_regex);
- }
-
- urlhack_clear_link_regions();
-
-
- char* text = const_cast<char*>(text_mass.c_str());
- char* text_pos = text;
-
- while (regexec(urlhack_rx, text_pos) == 1) {
- char* start_pos = *urlhack_rx->startp[0] == ' ' ? urlhack_rx->startp[0] + 1: urlhack_rx->startp[0];
- char* end_pos = urlhack_rx->endp[0];
- int max_brackets = 0;
- for (char *c = start_pos; c < end_pos; ++c) {
- switch (*c) {
- case '(': ++max_brackets; break;
- case ')': --max_brackets; break;
- }
- }
- while (max_brackets --> 0 && *end_pos == ')')
- ++end_pos;
-
- int x0 = (start_pos - text) % screen_width;
- int y0 = (start_pos - text) / screen_width;
- int x1 = (end_pos - text) % screen_width;
- int y1 = (end_pos - text) / screen_width;
-
- if (x0 >= screen_width) x0 = screen_width - 1;
- if (x1 >= screen_width) x1 = screen_width - 1;
-
- urlhack_add_link_region(x0, y0, x1, y1);
-
- text_pos = end_pos + 1;
- }
-}

0 comments on commit 92cd7a1

Please sign in to comment.
Something went wrong with that request. Please try again.