view lib-src/emacsclient.c @ 1284:4742a5797146

Password: Last login: Tue Sep 29 20:00:25 from paris.CS.Berkele 4.3 BSD UNIX #1: Fri Dec 1 20:30:54 EST 1989 This machine belongs to the GNU project. Feel free to use it. Send questions, requests, or other remarks to request@gnu.ai.mit.edu The GNU Project does not have the physical resources to "host" random games and IRC daemons on its machines. They tie up computing resources needed to develop software and further GNU. They have become a real hassle for us, so please don't run them. /home/fsg is full. Do the right thing. Guests: please don't use the hp300 machines for games, IRC, or news. You are welcome to use them for other purposes as long as a staff member doesn't ask you to log out and use another host. The hp300s include wookumz, churchy, geech, and mole. Machines which may be used for just about any purpose include hal, wombat, kropotkin, goldman, and hill. You have mail. This is a -bash login shell. No DISPLAY variable here... jla@churchy$ pwd /home/fsf/jla jla@churchy$ cd src /gd/gnu/emacs/19.0/src jla@churchy$ gdb xemacs GDB is free software and you are welcome to distribute copies of it under certain conditions; type "show copying" to see the conditions. There is absolutely no warranty for GDB; type "show warranty" for details. GDB 4.6, Copyright 1992 Free Software Foundation, Inc... TERMCAP and TERM environment variables unset. Environment variable "DISPLAY" not defined. Breakpoint 1 at 0x7d6ec Breakpoint 2 at 0x77310 (gdb) set env DISPLAY 128.32.150.43:0.0 (gdb) r Starting program: /home/gd/gnu/emacs/19.0/src/xemacs -q Cannot insert breakpoint 1: The same program may be running in another process. Cannot access memory at address 0x7d6ec. (gdb) [1]+ Stopped gdb xemacs jla@churchy$ ps x PID TT STAT TIME COMMAND 29053 p7 S 0:05 -bash (bash) 29074 p7 T 0:04 gdb xemacs 29075 p7 T 0:00 /home/gd/gnu/emacs/19.0/src/xemacs -q 29076 p7 R 0:00 ps x jla@churchy$ ps ax PID TT STAT TIME COMMAND 0 ? D 0:36 swapper 1 ? I 0:01 init 2 ? D 0:03 pagedaemon 49 ? S 15:02 syslogd 50 ? I 0:58 portmap 60 ? I 0:12 -accepting connections (sendmail) 64 ? S < 0:53 /usr/local/etc/ntpd 67 ? I 0:01 /usr/bin/X11/xdm 97 ? I 0:19 cron 101 ? S 2:22 /usr/etc/rwhod 103 ? I 2:45 /etc/inetd 106 ? IW 0:00 /usr/lib/lpd 145 ? IW 0:00 (nfsd) 146 ? IW 0:00 (nfsd) 147 ? IW 0:00 (nfsd) 148 ? IW 0:00 (nfsd) 152 ? IW 1:38 (biod) 153 ? IW 1:40 (biod) 154 ? IW 1:41 (biod) 155 ? IW 1:40 (biod) 2925 ? IW 0:00 rpc.mountd 5255 ? I 11:14 ibble 24806 ? S 19:37 /usr/bin/X11/X :0 28913 ? I 0:00 -:0 (xdm) 28924 ? I 0:01 sh /home/fsf/melissa/.xinitrc 28932 ? I 0:00 xterm -C -ut +sb -n Console -geometry 80x24+1+0 28933 ? I 0:00 xbiff -geometry -140+180 28934 ? S 0:02 xclock -analog -geometry -0+180 28935 ? S 0:02 xclock -digital -geometry 85x17-0+280 28936 ? I 0:54 emacs -wn Mail -in Mail -geometry 80x55+35+18 -f rmail -fon 28937 ? I 0:01 twm 28940 ? I 0:00 /usr/local/lib/emacs/etc/wakeup 60 28951 ? I 0:11 emacs -d :0.0 -w 28952 ? I 0:00 /usr/local/lib/emacs/etc/wakeup 60 29024 ? I 0:09 emacs -d :0.0 -w 29025 ? I 0:00 /usr/local/lib/emacs/etc/wakeup 60 29045 ? I 0:00 -AA29035 mizzou1.missouri.edu: user open (sendmail) 28938 p0 I 0:00 bash 28942 p1 I 0:00 /usr/local/gnubin/bash -i 28943 p2 I 0:00 -sh (csh) 28953 p3 I 0:00 /usr/local/gnubin/bash -i 28954 p4 I 0:00 -sh (csh) 29026 p5 I 0:00 /usr/local/gnubin/bash -i 560 p6 I 0:08 .nbin/mr 29027 p6 I 0:00 -sh (csh) 29052 p7 S 0:00 rlogind 29053 p7 S 0:05 -bash (bash) 29074 p7 T 0:04 gdb xemacs 29075 p7 T 0:00 /home/gd/gnu/emacs/19.0/src/xemacs -q 29077 p7 R 0:00 ps ax 5256 q0 IW 0:00 -bin/csh (csh) 5272 q0 S 6:38 tf2 5261 q1 IW 0:00 -bin/csh (csh) 5266 q2 IW 0:00 -bin/csh (csh) 15329 q2 I 7:27 emacs -f gnus 15330 q2 I 0:01 /usr/local/lib/emacs/etc/wakeup 60 95 ? S 2:22 update 157 ? IW 0:00 - 300h console (getty) jla@churchy$ fg gdb xemacs (gdb) r The program being debugged has been started already. Start it from the beginning? (y or n) y Starting program: /home/gd/gnu/emacs/19.0/src/xemacs -q Cannot insert breakpoint 1: The same program may be running in another process. Cannot access memory at address 0x7d6ec. (gdb) dis (gdb) r The program being debugged has been started already. Start it from the beginning? (y or n) y Starting program: /home/gd/gnu/emacs/19.0/src/xemacs -q Program received signal 2, Interrupt 0x83ffe in select () (gdb) b Fsignal Breakpoint 3 at 0x503da: file eval.c, line 1105. (gdb) c Continuing. Cannot insert breakpoint 3: The same program may be running in another process. Cannot access memory at address 0x503da. (gdb) dis (gdb) c Continuing. Program received signal 2, Interrupt 0x83ffe in select () (gdb) k` Kill the inferior process? (y or n) y (gdb) q jla@churchy$ who jla ttyp7 Sep 30 14:10 (priam.CS.Berkele) melissa :0 Sep 30 13:41 jla@churchy$ ll *emacs* -rwxrwxrwx 1 jimb daemon 2464158 Sep 27 23:33 emacs-19.0.437* -rwxrwxrwx 1 jimb daemon 2464135 Sep 28 02:19 emacs-19.0.438* -rwxrwxrwx 1 rms daemon 2464283 Sep 28 09:08 emacs-19.0.439* -rwxrwxrwx 1 jimb daemon 2464480 Sep 29 00:59 emacs-19.0.440* -rwxrwxrwx 1 jimb daemon 2465827 Sep 29 09:24 emacs-19.0.444* -rwxrwxrwx 1 jimb daemon 2466058 Sep 29 10:16 emacs-19.0.445* -rwxrwxrwx 1 jimb daemon 2466058 Sep 29 10:35 emacs-19.0.446* -rwxrwxrwx 1 jimb daemon 2466070 Sep 29 13:18 emacs-19.0.447* -rwxrwxrwx 1 jimb daemon 2462257 Sep 30 11:00 emacs-19.0.448* -rwxrwxrwx 2 jimb daemon 2462209 Sep 30 11:16 emacs-19.0.449* -rwxrwxrwx 1 jimb daemon 2462194 Sep 30 11:57 emacs-19.0.450* -rwxrwxrwx 2 jimb daemon 2466524 Sep 30 12:19 emacs-19.0.451* -r--r--r-- 1 jimb daemon 20265 Sep 22 23:40 emacs.c -rw-rw-rw- 1 rms daemon 18316 Sep 23 08:15 emacs.o -rwxrwxrwx 1 jimb daemon 2466070 Sep 29 14:36 jimb-xemacs* -rwxrwxrwx 1 jimb daemon 2097884 Sep 30 12:17 temacs* -rwxrwxrwx 1 jimb daemon 1822178 Sep 13 09:31 temacs-2* -rw-rw-rw- 1 jimb daemon 784 Sep 18 1988 temacs.opt -rw-rw-rw- 1 jimb daemon 177 Feb 26 1987 testemacs.com -rwxrwxrwx 2 jimb daemon 2466524 Sep 30 12:19 xemacs* -rwxrwxrwx 1 jla daemon 2463040 Sep 23 17:15 yemacs* jla@churchy$ rm yemacs jla@churchy$ cp xemacs yemacs & [1] 29088 jla@churchy$ more ChangeLog Wed Sep 30 06:59:07 1992 Jim Blandy (jimb@wookumz.gnu.ai.mit.edu) * buffer.c (Fother_buffer): Add back the VISIBLE_OK argument. It got removed with no comment or ChangeLog entry, and append-to-buffer uses it. * window.c (struct save_window_data): Add a member called focus_frame, to save and restore the screen's focus frame. (Fset_window_configuration): Redirect the frame's focus as indicated in the window configuration. (Fcurrent_window_configuration): Record the frame's current focus. * minibuf.c (read_minibuf): Don't bother to save the current frame's focus, and have read_minibuf_unwind restore it; saving and restoring the window configurations will take care of that. (read_minibuf_unwind): Don't worry about restoring the frame's focus. * window.c (Fset_window_configuration): Don't select the frame just because we restored its configuration. * window.c (Fset_window_configuration): Don't forget to set the frame's selected window when we can't call Fselect_window. * xterm.c (x_meta_mod_mask): New variable, indicating which X modifier bits denote meta keys. (x_find_modifier_meanings): New function, to set x_meta_mod_mask. (x_convert_modifiers): Use that. (x_term_init): Call x_find_modifier_meanings. * data.c (Fmake_local_variable): If SYM forwards to a C variable, swap in the value for the current buffer immediately. * lisp.h: Doc elaboration for Lisp_Buffer_Local_Value. Tue Sep 29 21:05:30 1992 Joseph Arceneaux (jla@churchy.gnu.ai.mit.edu) * textprop.c (Ferase_text_properties): Merge intervals when possible. Tue Sep 29 00:04:05 1992 Jim Blandy (jimb@wookumz.gnu.ai.mit.edu) * xselect.c (Qcut_buffer0): Symbol removed; we're using a new interface to the cut buffer now. (NUM_CUT_BUFFERS, cut_buffer_atom, cut_buffer_value, cut_buffer_cached, cut_buffer_just_set): New variables. (Fx_own_selection, Fx_selection_value): Dike out the code to handle CUT_BUFFER0 requests. (Fx_get_cut_buffer, Fx_set_cut_buffer, x_watch_cut_buffer_cache, x_invalidate_cut_buffer_cache): New functions. [1]+ Exit 0 cp xemacs yemacs jla@churchy$ gdb yemacs GDB is free software and you are welcome to distribute copies of it under certain conditions; type "show copying" to see the conditions. There is absolutely no warranty for GDB; type "show warranty" for details. GDB 4.6, Copyright 1992 Free Software Foundation, Inc... TERMCAP and TERM environment variables unset. Environment variable "DISPLAY" not defined. Breakpoint 1 at 0x7d6ec Breakpoint 2 at 0x77310 (gdb) b Fsignal Breakpoint 3 at 0x503da: file eval.c, line 1105. (gdb) set env DISPLAY 128.32.150.43:0.0 (gdb) r Starting program: /home/gd/gnu/emacs/19.0/src/yemacs -q Breakpoint 3, Fsignal (sig=17759556, data=17759236) at eval.c:1105 1105 register struct handler *allhandlers = handlerlist; (gdb) c Continuing. Breakpoint 3, Fsignal (sig=17759576, data=84996828) at eval.c:1105 1105 register struct handler *allhandlers = handlerlist; (gdb) bt #0 Fsignal (sig=17759576, data=84996828) at eval.c:1105 #1 0x4664a in wrong_type_argument (predicate=17803608, value=987136) at data.c:73 #2 0x4572 in Fredirect_frame_focus (frame=987136, focus_frame=235868160) at frame.c:893 #3 0xe114 in Fset_window_configuration (configuration=353327296) at window.c:2498 #4 0x524aa in unbind_to (count=7, value=51516952) at eval.c:2111 #5 0xe61c in Fsave_window_excursion (args=84526412) at window.c:2683 #6 0x60cd4 in Fbyte_code (bytestr=50971960, vector=67749184, maxdepth=1) at bytecode.c:555 #7 0x521a8 in funcall_lambda (fun=101303552, nargs=2, arg_vector=0xffeff7ae) at eval.c:2032 #8 0x51c42 in Ffuncall (nargs=3, args=0xffeff7aa) at eval.c:1898 #9 0x607c8 in Fbyte_code (bytestr=50977256, vector=67754576, maxdepth=5) at bytecode.c:422 #10 0x521a8 in funcall_lambda (fun=101308856, nargs=1, arg_vector=0xffeff8ee) at eval.c:2032 #11 0x51c42 in Ffuncall (nargs=2, args=0xffeff8ea) at eval.c:1898 #12 0x4e980 in Fcall_interactively (function=17914640, record=17759236) at callint.c:508 #13 0x24090 in Fcommand_execute (cmd=17914640, record=17759236) at keyboard.c:3025 #14 0x21028 in command_loop_1 () at keyboard.c:973 #15 0x50370 in internal_condition_case (bfun=0x2084c <command_loop_1>, handlers=17759536, hfun=0x20304 <cmd_error>) at eval.c:1083 #16 0x2066a in command_loop_2 () at keyboard.c:701 #17 0x4fece in internal_catch (tag=17759516, func=0x2064e <command_loop_2>, arg=17759236) at eval.c:875 #18 0x2062e in command_loop () at keyboard.c:681 #19 0x201ca in recursive_edit_1 () at keyboard.c:523 #20 0x20298 in Frecursive_edit () at keyboard.c:558 #21 0x1fa36 in main (argc=2, argv=0xffeffce4, envp=0xffeffcf0) at emacs.c:581 (gdb) fr 2 #2 0x4572 in Fredirect_frame_focus (frame=987136, focus_frame=235868160) at frame.c:893 893 CHECK_LIVE_FRAME (frame, 0); (gdb) l 888 This is useful for temporarily redirecting keystrokes to the minibuffer\n\ 889 window when a frame doesn't have its own minibuffer.") 890 (frame, focus_frame) 891 Lisp_Object frame, focus_frame; 892 { 893 CHECK_LIVE_FRAME (frame, 0); 894 895 if (NILP (focus_frame)) 896 focus_frame = frame; 897 else (gdb) 898 CHECK_LIVE_FRAME (focus_frame, 1); 899 900 XFRAME (frame)->focus_frame = focus_frame; 901 902 if (frame_rehighlight_hook) 903 (*frame_rehighlight_hook) (); 904 jla@churchy$ l elisp/ jla-src/ v19-src/ jla@churchy$ cd v19-src/ jla@churchy$ grep INTERVAL lisp.h #ifdef USE_INTERVALS typedef struct interval *INTERVAL; #define DECLARE_INTERVALS INTERVAL intervals; #define INITIALIZE_INTERVAL(ptr,val) ptr->intervals = val #define INTERVAL #define DECLARE_INTERVALS #define INITIALIZE_INTERVAL(ptr,val) #endif /* USE_INTERVALS */ DECLARE_INTERVALS jla@churchy$ grep INTERVAL config.h /* Define USE_INTERVALS to handle fat text. */ #define USE_INTERVALS jla@churchy$ d /gd2/jla/v19-src jla@churchy$ pwd /home/gd2/jla/v19-src jla@churchy$ grep DECLARE_INTERVALS *.[ch] buffer.h: DECLARE_INTERVALS lisp.h:#define DECLARE_INTERVALS INTERVAL intervals; lisp.h:#define DECLARE_INTERVALS lisp.h: DECLARE_INTERVALS jla@churchy$ grep INITIALIZE_INTERVAL *.c alloc.c: INITIALIZE_INTERVAL (XSTRING (val), NULL_INTERVAL); alloc.c: INITIALIZE_INTERVAL (XSTRING (new), NULL_INTERVAL); buffer.c: INITIALIZE_INTERVAL (b, NULL_INTERVAL); buffer.c: INITIALIZE_INTERVAL (b, NULL_INTERVAL); jla@churchy$ pwd /home/gd2/jla/v19-src jla@churchy$ cd etc /gd/gnu/emacs/19.0/etc jla@churchy$ l *.c /usr/local/gnubin/ls: *.c: No such file or directory jla@churchy$ more Makefile DESTDIR= LIBDIR=/usr/local/lib BINDIR=/usr/local/bin MANDIR=/usr/man/man1 MANEXT=1 all: distclean: -rm -f *~ \#* DOC* core clean: -rm -f core jla@churchy$ cd .. jla@churchy$ l ChangeLog README.~3~ info/ ChangeLog~ README.~6~ lib-src/ GETTING.GNU.SOFTWARE README.~7~ lisp/ GETTING.GNU.SOFTWARE.~1~ arch-lib/ local-lisp/ GETTING.GNU.SOFTWARE.~2~ build-install* lock/ INSTALL build-install.in* make-dist* INSTALL.~1~ build-install.in,v* make-dist.~10~* INSTALL.~2~ config.emacs.~1~* make-dist.~11~* jla@churchy$ cd src /gd/gnu/emacs/19.0/src jla@churchy$ make -f xmakefile editfns.o make: `editfns.o' is up to date. jla@churchy$ ll editfns.[co] -rw-r--r-- 1 jla daemon 36258 Sep 30 20:39 editfns.c -rw-rw-rw- 1 jla daemon 38383 Sep 30 20:43 editfns.o jla@churchy$ date Wed Sep 30 20:45:25 EDT 1992 jla@churchy$ rm editfns.o jla@churchy$ make -f xmakefile editfns.o cc -g -Demacs -Is -Im -c editfns.c -o editfns.o jla@churchy$ lt {insdel,emacs,buffer}.[co] -rw-rw-rw- 1 jla daemon 16422 Sep 30 20:42 insdel.o -rw-rw-rw- 1 rms daemon 18316 Sep 30 20:40 emacs.o -rw-r--r-- 1 jla daemon 14931 Sep 30 19:54 insdel.c -rw-r--r-- 1 jla daemon 20387 Sep 30 19:33 emacs.c -rw-rw-rw- 1 jla daemon 44674 Sep 30 19:29 buffer.o -r--r--r-- 1 jimb daemon 56614 Sep 30 14:13 buffer.c jla@churchy$ ll buffer.h -rw-r--r-- 1 jla daemon 14323 Sep 30 18:36 buffer.h jla@churchy$ ll temacs -rw-rw-rw- 1 jimb daemon 313564 Sep 30 20:46 temacs jla@churchy$ man rcs jla@churchy$ man rlog jla@churchy$ rlog RCS/buffer.c,v RCS file: RCS/buffer.c,v Working file: buffer.c head: 1.15 branch: locks: strict access list: symbolic names: comment leader: " * " keyword substitution: kv total revisions: 15; selected revisions: 15 description: /* Buffer manipulation primitives for GNU Emacs. ---------------------------- revision 1.15 date: 1992/09/30 18:16:11; author: jimb; state: Exp; lines: +9 -5 * buffer.c (Fother_buffer): Add back the VISIBLE_OK argument. It got removed with no comment or ChangeLog entry, and append-to-buffer uses it. ---------------------------- revision 1.14 date: 1992/09/29 04:54:28; author: jimb; state: Exp; lines: +1 -1 * data.c (Frem): Use the `fmod' function under SunOS, Ultrix, and HP/UX, not just under USG systems. ---------------------------- revision 1.13 date: 1992/09/29 04:08:04; author: jimb; state: Exp; lines: +20 -14 * buffer.c (Fbury_buffer): This used to undisplay the buffer being buried only if the BUFFER argument was nil. Instead, undisplay the buffer whenever it's displayed in the selected window, no matter how it was specified by BUFFER. This is how it behaves in 18.58, and I can't find any ChangeLog entry in 18.58 or 19.0 saying why they differ. Fix the doc string accordingly. ---------------------------- revision 1.12 date: 1992/09/22 05:16:47; author: jimb; state: Exp; lines: +1 -0 * buffer.c (Fget_buffer_create): Doc fix. jla@churchy$ d /gd/gnu/emacs/19.0/src jla@churchy$ ci editfns.c insdel.c emacs.c buffer.h intervals.h intervals.c tex tprop.c RCS/editfns.c,v <-- editfns.c new revision: 1.14; previous revision: 1.13 enter log message, terminated with single '.' or end of file: >> >> * editfns.c (make_buffer_string): Call copy_intervals_to_string(). (Finsert_buffer_substring): Call graft_intervals_into_buffer(). #include "intervals.h". >> >> >> . done RCS/insdel.c,v <-- insdel.c new revision: 1.5; previous revision: 1.4 reuse log message of previous file? [yn](y): n enter log message, terminated with single '.' or end of file: >> * insdel.c: #include "intervals.h" (prepare_to_modify_buffer): Call verify_interval_modification(). (insert_from_string): Call offset_intervals() and graft_intervals_into_buffer(). (del_range): Call offset_intervals(). (insert): Call offset_interv>> >> >> >> >> als(). >> . done
author Joseph Arceneaux <jla@gnu.org>
date Thu, 01 Oct 1992 00:56:11 +0000
parents 2b11e85880d3
children e10f7473d2e3
line wrap: on
line source

/* Client process that communicates with GNU Emacs acting as server.
   Copyright (C) 1986, 1987 Free Software Foundation, Inc.

This file is part of GNU Emacs.

GNU Emacs is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.

GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Emacs; see the file COPYING.  If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */


#define NO_SHORTNAMES
#include "../src/config.h"
#undef read
#undef write
#undef open
#ifdef close
#undef close
#endif


#if !defined(HAVE_SOCKETS) && !defined(HAVE_SYSVIPC)
#include <stdio.h>

main (argc, argv)
     int argc;
     char **argv;
{
  fprintf (stderr, "%s: Sorry, the Emacs server is supported only\n",
	   argv[0]);
  fprintf (stderr, "on systems with Berkeley sockets or System V IPC.\n");
  exit (1);
}

#else /* HAVE_SOCKETS or HAVE_SYSVIPC */

#if ! defined (HAVE_SYSVIPC)
/* BSD code is very different from SYSV IPC code */

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/stat.h>
#include <stdio.h>
#include <errno.h>

extern int sys_nerr;
extern char *sys_errlist[];
extern int errno;

main (argc, argv)
     int argc;
     char **argv;
{
  char system_name[32];
  int s, i;
  FILE *out;
  struct sockaddr_un server;
  char *homedir, *cwd, *str;
  char string[BUFSIZ];

  char *getenv (), *getwd ();
  int geteuid ();

  if (argc < 2)
    {
      fprintf (stderr, "Usage: %s [+linenumber] filename\n", argv[0]);
      exit (1);
    }

  /* 
   * Open up an AF_UNIX socket in this person's home directory
   */

  if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
    {
      fprintf (stderr, "%s: ", argv[0]);
      perror ("socket");
      exit (1);
    }
  server.sun_family = AF_UNIX;
#ifndef SERVER_HOME_DIR
  {
    struct stat statbfr;

    gethostname (system_name, sizeof (system_name));
    sprintf (server.sun_path, "/tmp/esrv%d-%s", geteuid (), system_name);

    if (stat (server.sun_path, &statbfr) == -1)
      {
	if (errno == ENOENT)
	  fprintf (stderr,
		   "Can't find socket; have you started the server?\n");
	else
	  perror ("stat");
	exit (1);
      }
    if (statbfr.st_uid != geteuid())
      {
	fprintf (stderr, "Illegal socket owner\n");
	exit (1);
      }
  }
#else
  if ((homedir = getenv ("HOME")) == NULL)
    {
      fprintf (stderr, "%s: No home directory\n", argv[0]);
      exit (1);
    }
  strcpy (server.sun_path, homedir);
  strcat (server.sun_path, "/.emacs_server");
#endif

  if (connect (s, &server, strlen (server.sun_path) + 2) < 0)
    {
      fprintf (stderr, "%s: ", argv[0]);
      perror ("connect");
      exit (1);
    }
  if ((out = fdopen (s, "r+")) == NULL)
    {
      fprintf (stderr, "%s: ", argv[0]);
      perror ("fdopen");
      exit (1);
    }

  cwd = getwd (string);
  if (cwd == 0)
    {
      /* getwd puts message in STRING if it fails.  */
      fprintf (stderr, "%s: %s (%s)\n", argv[0], string,
	       (errno < sys_nerr) ? sys_errlist[errno] : "unknown error");
      exit (1);
    }

  for (i = 1; i < argc; i++)
    {
      if (*argv[i] == '+')
	{
	  char *p = argv[i] + 1;
	  while (*p >= '0' && *p <= '9') p++;
	  if (*p != 0)
	    fprintf (out, "%s/", cwd);
	}
      else if (*argv[i] != '/')
	fprintf (out, "%s/", cwd);
      fprintf (out, "%s ", argv[i]);
    }
  fprintf (out, "\n");
  fflush (out);

  printf ("Waiting for Emacs...");
  fflush (stdout);

  rewind (out); /* re-read the output */
  str = fgets (string, BUFSIZ, out); 

  /* Now, wait for an answer and print any messages.  */
  
  while (str = fgets (string, BUFSIZ, out))
    printf ("%s", str);
  
  exit (0);
}

#else /* This is the SYSV IPC section */

#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <stdio.h>

main (argc, argv)
     int argc;
     char **argv;
{
  int s;
  key_t key;
  struct msgbuf * msgp =
      (struct msgbuf *) malloc (sizeof *msgp + BUFSIZ);
  struct msqid_ds * msg_st;
  char *homedir, buf[BUFSIZ];
  char gwdirb[BUFSIZ];
  char *cwd;
  char *temp;
  char *getwd (), *getcwd (), *getenv ();

  if (argc < 2)
    {
      fprintf (stderr, "Usage: %s [+linenumber] filename\n", argv[0]);
      exit (1);
    }

  /*
   * Create a message queue using ~/.emacs_server as the path for ftok
   */
  if ((homedir = getenv ("HOME")) == NULL)
    {
      fprintf (stderr, "%s: No home directory\n", argv[0]);
      exit (1);
    }
  strcpy (buf, homedir);
  strcat (buf, "/.emacs_server");
  creat (buf, 0600);
  key = ftok (buf, 1);	/* unlikely to be anyone else using it */
  s = msgget (key, 0600 | IPC_CREAT);
  if (s == -1)
    {
      fprintf (stderr, "%s: ", argv[0]);
      perror ("msgget");
      exit (1);
    }

  /* Determine working dir, so we can prefix it to all the arguments.  */
#ifdef BSD
  temp = getwd (gwdirb);
#else
  temp = getcwd (gwdirb, sizeof gwdirb);
#endif

  cwd = gwdirb;
  if (temp != 0)
    {
      /* On some systems, cwd can look like `@machine/...';
	 ignore everything before the first slash in such a case.  */
      while (*cwd && *cwd != '/')
	cwd++;
      strcat (cwd, "/");
    }
  else
    {
      fprintf (stderr, cwd);
      exit (1);
    }

  msgp->mtext[0] = 0;
  argc--; argv++;
  while (argc)
    {
      if (*argv[0] == '+')
	{
	  char *p = argv[0] + 1;
	  while (*p >= '0' && *p <= '9') p++;
	  if (*p != 0)
	    strcat (msgp->mtext, cwd);
	}
      else if (*argv[0] != '/')
	strcat (msgp->mtext, cwd);

      strcat (msgp->mtext, argv[0]);
      strcat (msgp->mtext, " ");
      argv++; argc--;
    }
  strcat (msgp->mtext, "\n");
  msgp->mtype = 1;
  if (msgsnd (s, msgp, strlen (msgp->mtext)+1, 0) < 0)
    {
      fprintf (stderr, "%s: ", argv[0]);
      perror ("msgsnd");
      exit (1);
    }
  /*
   * Now, wait for an answer
   */
  printf ("Waiting for Emacs...");
  fflush (stdout);

  msgrcv (s, msgp, BUFSIZ, getpid (), 0);	/* wait for anything back */
  strcpy (buf, msgp->mtext);

  printf ("\n%s\n", buf);
  exit (0);
}

#endif /* HAVE_SYSVIPC */

#endif /* HAVE_SOCKETS or HAVE_SYSVIPC */