annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
493
8b101799ff37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 478
diff changeset
1 /* Client process that communicates with GNU Emacs acting as server.
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2 Copyright (C) 1986, 1987 Free Software Foundation, Inc.
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 This file is part of GNU Emacs.
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 the Free Software Foundation; either version 1, or (at your option)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 any later version.
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 GNU General Public License for more details.
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 #define NO_SHORTNAMES
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 #include "../src/config.h"
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 #undef read
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 #undef write
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 #undef open
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 #ifdef close
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 #undef close
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 #endif
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 #if !defined(HAVE_SOCKETS) && !defined(HAVE_SYSVIPC)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 #include <stdio.h>
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 main (argc, argv)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 int argc;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 char **argv;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 {
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 fprintf (stderr, "%s: Sorry, the Emacs server is supported only\n",
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 argv[0]);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 fprintf (stderr, "on systems with Berkeley sockets or System V IPC.\n");
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 exit (1);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 }
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 #else /* HAVE_SOCKETS or HAVE_SYSVIPC */
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 #if ! defined (HAVE_SYSVIPC)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 /* BSD code is very different from SYSV IPC code */
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 #include <sys/types.h>
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 #include <sys/socket.h>
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 #include <sys/un.h>
493
8b101799ff37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 478
diff changeset
52 #include <sys/stat.h>
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 #include <stdio.h>
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 #include <errno.h>
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 extern int sys_nerr;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 extern char *sys_errlist[];
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 extern int errno;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 main (argc, argv)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 int argc;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 char **argv;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 {
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 char system_name[32];
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 int s, i;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 FILE *out;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 struct sockaddr_un server;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 char *homedir, *cwd, *str;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 char string[BUFSIZ];
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 char *getenv (), *getwd ();
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 int geteuid ();
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 if (argc < 2)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 {
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 fprintf (stderr, "Usage: %s [+linenumber] filename\n", argv[0]);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 exit (1);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 }
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 /*
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 * Open up an AF_UNIX socket in this person's home directory
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 */
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 {
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 fprintf (stderr, "%s: ", argv[0]);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 perror ("socket");
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 exit (1);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 }
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 server.sun_family = AF_UNIX;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 #ifndef SERVER_HOME_DIR
493
8b101799ff37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 478
diff changeset
92 {
8b101799ff37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 478
diff changeset
93 struct stat statbfr;
8b101799ff37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 478
diff changeset
94
8b101799ff37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 478
diff changeset
95 gethostname (system_name, sizeof (system_name));
8b101799ff37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 478
diff changeset
96 sprintf (server.sun_path, "/tmp/esrv%d-%s", geteuid (), system_name);
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97
493
8b101799ff37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 478
diff changeset
98 if (stat (server.sun_path, &statbfr) == -1)
8b101799ff37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 478
diff changeset
99 {
816
fc1f790220a4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 493
diff changeset
100 if (errno == ENOENT)
fc1f790220a4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 493
diff changeset
101 fprintf (stderr,
fc1f790220a4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 493
diff changeset
102 "Can't find socket; have you started the server?\n");
fc1f790220a4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 493
diff changeset
103 else
fc1f790220a4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 493
diff changeset
104 perror ("stat");
493
8b101799ff37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 478
diff changeset
105 exit (1);
8b101799ff37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 478
diff changeset
106 }
8b101799ff37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 478
diff changeset
107 if (statbfr.st_uid != geteuid())
8b101799ff37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 478
diff changeset
108 {
8b101799ff37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 478
diff changeset
109 fprintf (stderr, "Illegal socket owner\n");
8b101799ff37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 478
diff changeset
110 exit (1);
8b101799ff37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 478
diff changeset
111 }
8b101799ff37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 478
diff changeset
112 }
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 #else
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 if ((homedir = getenv ("HOME")) == NULL)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 {
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 fprintf (stderr, "%s: No home directory\n", argv[0]);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 exit (1);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 }
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 strcpy (server.sun_path, homedir);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 strcat (server.sun_path, "/.emacs_server");
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 #endif
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 if (connect (s, &server, strlen (server.sun_path) + 2) < 0)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 {
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 fprintf (stderr, "%s: ", argv[0]);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 perror ("connect");
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 exit (1);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 }
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 if ((out = fdopen (s, "r+")) == NULL)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 {
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 fprintf (stderr, "%s: ", argv[0]);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 perror ("fdopen");
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 exit (1);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 }
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 cwd = getwd (string);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 if (cwd == 0)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 {
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 /* getwd puts message in STRING if it fails. */
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 fprintf (stderr, "%s: %s (%s)\n", argv[0], string,
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 (errno < sys_nerr) ? sys_errlist[errno] : "unknown error");
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 exit (1);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 }
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 for (i = 1; i < argc; i++)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 {
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 if (*argv[i] == '+')
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 {
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 char *p = argv[i] + 1;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 while (*p >= '0' && *p <= '9') p++;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 if (*p != 0)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 fprintf (out, "%s/", cwd);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 }
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 else if (*argv[i] != '/')
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 fprintf (out, "%s/", cwd);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 fprintf (out, "%s ", argv[i]);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 }
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 fprintf (out, "\n");
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 fflush (out);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 printf ("Waiting for Emacs...");
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 fflush (stdout);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 rewind (out); /* re-read the output */
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 str = fgets (string, BUFSIZ, out);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 /* Now, wait for an answer and print any messages. */
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 while (str = fgets (string, BUFSIZ, out))
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 printf ("%s", str);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 exit (0);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 }
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 #else /* This is the SYSV IPC section */
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 #include <sys/types.h>
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 #include <sys/ipc.h>
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 #include <sys/msg.h>
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 #include <stdio.h>
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 main (argc, argv)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 int argc;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 char **argv;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 {
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 int s;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 key_t key;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 struct msgbuf * msgp =
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (struct msgbuf *) malloc (sizeof *msgp + BUFSIZ);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 struct msqid_ds * msg_st;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 char *homedir, buf[BUFSIZ];
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 char gwdirb[BUFSIZ];
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 char *cwd;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 char *temp;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 char *getwd (), *getcwd (), *getenv ();
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 if (argc < 2)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 {
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 fprintf (stderr, "Usage: %s [+linenumber] filename\n", argv[0]);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 exit (1);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 }
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 /*
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 * Create a message queue using ~/.emacs_server as the path for ftok
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 */
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 if ((homedir = getenv ("HOME")) == NULL)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 {
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 fprintf (stderr, "%s: No home directory\n", argv[0]);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 exit (1);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 }
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 strcpy (buf, homedir);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 strcat (buf, "/.emacs_server");
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 creat (buf, 0600);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 key = ftok (buf, 1); /* unlikely to be anyone else using it */
1031
2b11e85880d3 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 816
diff changeset
215 s = msgget (key, 0600 | IPC_CREAT);
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 if (s == -1)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 {
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 fprintf (stderr, "%s: ", argv[0]);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 perror ("msgget");
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 exit (1);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 }
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 /* Determine working dir, so we can prefix it to all the arguments. */
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 #ifdef BSD
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 temp = getwd (gwdirb);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 #else
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 temp = getcwd (gwdirb, sizeof gwdirb);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 #endif
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 cwd = gwdirb;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 if (temp != 0)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 {
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 /* On some systems, cwd can look like `@machine/...';
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 ignore everything before the first slash in such a case. */
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 while (*cwd && *cwd != '/')
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 cwd++;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 strcat (cwd, "/");
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 }
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 else
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 {
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 fprintf (stderr, cwd);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 exit (1);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 }
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 msgp->mtext[0] = 0;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 argc--; argv++;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 while (argc)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 {
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 if (*argv[0] == '+')
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 {
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 char *p = argv[0] + 1;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 while (*p >= '0' && *p <= '9') p++;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 if (*p != 0)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 strcat (msgp->mtext, cwd);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 }
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 else if (*argv[0] != '/')
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 strcat (msgp->mtext, cwd);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 strcat (msgp->mtext, argv[0]);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 strcat (msgp->mtext, " ");
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 argv++; argc--;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 }
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 strcat (msgp->mtext, "\n");
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 msgp->mtype = 1;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 if (msgsnd (s, msgp, strlen (msgp->mtext)+1, 0) < 0)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 {
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 fprintf (stderr, "%s: ", argv[0]);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 perror ("msgsnd");
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 exit (1);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 }
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 /*
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 * Now, wait for an answer
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 */
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 printf ("Waiting for Emacs...");
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 fflush (stdout);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 msgrcv (s, msgp, BUFSIZ, getpid (), 0); /* wait for anything back */
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 strcpy (buf, msgp->mtext);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 printf ("\n%s\n", buf);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 exit (0);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 }
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 #endif /* HAVE_SYSVIPC */
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 #endif /* HAVE_SOCKETS or HAVE_SYSVIPC */