about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJosh Rickmar <jrick@devio.us>2012-06-01 17:40:07 -0400
committerJosh Rickmar <jrick@devio.us>2012-06-01 17:40:07 -0400
commitbd853cb3f256c4faeb9295c87435c1a1eadafd29 (patch)
tree3d0a76b392b32c6fe011e61631475fcce3bdedce
parent1e2c5ad606b967ebff3f1f81c7e49b48520c8f6a (diff)
downloadxombrero-bd853cb3f256c4faeb9295c87435c1a1eadafd29.tar.gz
Fix some random stuff the rebasing lost. At least the build still
works, will have to check later to make sure all the other features
got in.
-rw-r--r--unix.c3
-rw-r--r--xombrero.c29
-rw-r--r--xombrero.h1
3 files changed, 33 insertions, 0 deletions
diff --git a/unix.c b/unix.c
index 93f9948..a5a765e 100644
--- a/unix.c
+++ b/unix.c
@@ -16,6 +16,9 @@
 
 #include <xombrero.h>
 
+/* put this here for now, move away if unix needs something special */
+void	(*os_init)(void);
+
 int
 fork_exec(struct tab *t, char *argv0, const gchar *argv1, char *error, int loud)
 {
diff --git a/xombrero.c b/xombrero.c
index 4a34938..19c3a88 100644
--- a/xombrero.c
+++ b/xombrero.c
@@ -1345,6 +1345,35 @@ save_tabs_and_quit(struct tab *t, struct karg *args)
 	return (1);
 }
 
+void
+expand_tilde(char *path, size_t len, const char *s)
+{
+	struct passwd		*pwd;
+	int			i;
+	char			user[LOGIN_NAME_MAX];
+	const char		*sc = s;
+
+	if (path == NULL || s == NULL)
+		errx(1, "expand_tilde");
+
+	if (s[0] != '~') {
+		strlcpy(path, sc, len);
+		return;
+	}
+
+	++s;
+	for (i = 0; s[i] != '/' && s[i] != '\0'; ++i)
+		user[i] = s[i];
+	user[i] = '\0';
+	s = &s[i];
+
+	pwd = strlen(user) == 0 ? getpwuid(getuid()) : getpwnam(user);
+	if (pwd == NULL)
+		strlcpy(path, sc, len);
+	else
+		snprintf(path, len, "%s%s", pwd->pw_dir, s);
+}
+
 int
 run_page_script(struct tab *t, struct karg *args)
 {
diff --git a/xombrero.h b/xombrero.h
index 4fcf58b..75e7ec5 100644
--- a/xombrero.h
+++ b/xombrero.h
@@ -335,6 +335,7 @@ const gchar		*get_title(struct tab *, bool);
 void			load_uri(struct tab *t, gchar *uri);
 gboolean		match_uri(const gchar *uri, const gchar *key);
 int			valid_url_type(char *);
+void			expand_tilde(char *, size_t, const char *);
 
 void			load_webkit_string(struct tab *, const char *, gchar *);
 void			button_set_stockid(GtkWidget *, char *);