-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: rxvt-unicode-sixel
action: commit
revision:
path_from:
revision_from: 1eef8973cdd46497c14c66e89b7454078d880996:
path_to:
revision_to:

git.thebackupbox.net

rxvt-unicode-sixel

git://git.thebackupbox.net/rxvt-unicode-sixel

commit 1eef8973cdd46497c14c66e89b7454078d880996
Author: Marc Lehmann <schmorp@schmorp.de>
Date:   Mon Nov 24 19:52:16 2003 +0000

    *** empty log message ***

diff --git a/src/rxvtc.C b/src/rxvtc.C

index 1a3604800e9d1bb140b80a21c6bf919e0990b453..

index ..262969ac65e013b4967ac6a2f9de23df5ff199c6 100644

--- a/src/rxvtc.C
+++ b/src/rxvtc.C
@@ -38,13 +38,13 @@ main(int argc, const char *const *argv)
   char buf[PATH_MAX];

   c.send ("NEW");
-  c.send ("DISPLAY"); c.send (getenv ("DISPLAY"));
+  c.send ("DISPLAY"), c.send (getenv ("DISPLAY"));
   // instead of getcwd we could opendir(".") and pass the fd for fchdir *g*
-  c.send ("CWD"); c.send (getcwd (buf, sizeof (buf)));
+  c.send ("CWD"), c.send (getcwd (buf, sizeof (buf)));

-  c.send ("ARGV"); c.send (argc);
   for (int i = 0; i < argc; i++)
-    c.send (argv[i]);
+    c.send ("ARG"), c.send (argv[i]);
+
   c.send ("END");
 }

diff --git a/src/rxvtd.C b/src/rxvtd.C

index 6496289292076f07c9f62a29c0ba87f55fb45b7e..

index ..d56acc95178da949ed44dd48c406cf37ed795eda 100644

--- a/src/rxvtd.C
+++ b/src/rxvtd.C
@@ -77,18 +77,44 @@ void server::err ()

 void server::read_cb (io_watcher &w, short revents)
 {
-  token cmd;
+  auto_str tok;

-  if (recv (cmd))
+  if (recv (tok))
     {
-      if (!strcmp (cmd, "NEW"))
+      if (!strcmp (tok, "NEW"))
         {
+          auto_str display, cwd;
+          simplevec<auto_str> argv;
+
+          for (;;)
+            {
+              if (!recv (tok))
+                return err ();
+
+              if (!strcmp (tok, "END"))
+                break;
+              else if (!strcmp (tok, "DISPLAY") && recv (display))
+                ;
+              else if (!strcmp (tok, "CWD") && recv (cwd))
+                ;
+              else if (!strcmp (tok, "ARG") && recv (tok))
+                argv.push_back (tok);
+              else
+                return err ();
+            }
+
+          // TODO: no setenv, please
+          setenv ("DISPLAY", display.get (), 1);
+
+          rxvt_init (argv.size (), reinterpret_cast<char **>(argv.begin ()));
+          dR;
+          rxvt_main_loop (aR);
         }
       else
-        err ();
+        return err ();
     }
   else
-    err ();
+    return err ();
 }

 int
diff --git a/src/rxvtdaemon.C b/src/rxvtdaemon.C

index 3f310bd9cc2693ea93cfd188eea2e2358bb17c0b..

index ..c3691721b5cecff4cbe4b64131bdf4760c73ed6f 100644

--- a/src/rxvtdaemon.C
+++ b/src/rxvtdaemon.C
@@ -25,7 +25,7 @@ void rxvt_connection::send (const char *data)
   send (data, strlen (data));
 }

-bool rxvt_connection::recv (char *&data, int *len)
+bool rxvt_connection::recv (auto_str &data, int *len)
 {
   uint8_t s[2];
   int l;
@@ -53,22 +53,6 @@ bool rxvt_connection::recv (char *&data, int *len)
   return true;
 }

-bool rxvt_connection::recv (token &data)
-{
-  char *d;
-  int l;
-
-  if (!recv (d, &l))
-    return false;
-
-  if (l < sizeof (token) - 1)
-    strcpy (data, d);
-
-  delete [] d;
-
-  return l < sizeof (token) - 1;
-}
-
 void rxvt_connection::send (int data)
 {
   uint8_t s[4];
diff --git a/src/rxvtdaemon.h b/src/rxvtdaemon.h

index f6832adeb1167e9ab62fe46be485b2b267ae0fdc..

index ..785b5d77d4f9224972dc76038b38ca42e859b82a 100644

--- a/src/rxvtdaemon.h
+++ b/src/rxvtdaemon.h
@@ -1,19 +1,18 @@
 #ifndef RXVT_DAEMON_H
 #define RXVT_DAEMON_H

+#include "rxvtvec.h"
+
 struct rxvt_connection {
   int fd;

   static const char *unix_sockname ();

-  typedef char[4] token;
-
   void send (const char *data, int len);
   void send (const char *data);
   void send (int data);

-  bool recv (char *&data, int *len = 0);
-  bool recv (token &data);
+  bool recv (auto_str &data, int *len = 0);
   bool recv (int &data);
 };

diff --git a/src/rxvtvec.h b/src/rxvtvec.h

index 151a857857a522db31bdffb2f1126e4d3983fedc..

index ..01d17925cbb5a54f77930a07aeceda0a4df3ba84 100644

--- a/src/rxvtvec.h
+++ b/src/rxvtvec.h
@@ -32,4 +32,47 @@ I find(I first, I last, const T& value)
   return first;
 }

+template<typename T>
+struct auto_ptr {
+  T *p;
+
+  auto_ptr() : p(0) { }
+  auto_ptr(T *a) : p(a) { }
+
+  template<typename A>
+  auto_ptr(auto_ptr<A> &a)
+  {
+    p = a.p;
+    a.p = 0;
+  }
+
+  // void because it makes sense in our context
+  void operator =(T *a)
+  {
+    delete p;
+    p = a;
+  }
+
+  template<typename A>
+  void operator =(auto_ptr<A> &a)
+  {
+    *this = a.p;
+    a.p = 0;
+  }
+
+  operator T *() const { return p; }
+
+  T *operator ->() const { return p; }
+  T &operator *() const { return *p; }
+
+  T *get ()
+  {
+    T *r = p;
+    p = 0;
+    return r;
+  }
+};
+
+typedef auto_ptr<char> auto_str;
+
 #endif

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 10:02:39 2024