annotate lib-src/gnuclient.c @ 167:85ec50267440 r20-3b10

Import from CVS: tag r20-3b10
author cvs
date Mon, 13 Aug 2007 09:45:46 +0200
parents 25f70ba0133c
children 929b76928fce
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* -*-C-*-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Client code to allow local and remote editing of files by XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Copyright (C) 1989 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 Copyright (C) 1995 Sun Microsystems, Inc.
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
5 Copyright (C) 1997 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 Boston, MA 02111-1307, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 Author: Andy Norman (ange@hplb.hpl.hp.com), based on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 'etc/emacsclient.c' from the GNU Emacs 18.52 distribution.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 Please mail bugs and suggestions to the author at the above address.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 * This file incorporates new features added by Bob Weiner <weiner@mot.com>,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 * Darrell Kindred <dkindred@cmu.edu> and Arup Mukherjee <arup@cmu.edu>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 * GNUATTACH support added by Ben Wing <wing@xemacs.org>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 * Please see the note at the end of the README file for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 * (If gnuserv came bundled with your emacs, the README file is probably
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 * ../etc/gnuserv.README relative to the directory containing this file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 /* Hand-munged RCS header */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 static char rcsid [] = "!Header: gnuclient.c,v 2.2 95/12/12 01:39:21 wing nene !";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 #include "gnuserv.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 #include "getopt.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 #include <stdio.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 #include <stdlib.h>
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
50 #ifdef HAVE_STRING_H
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 #include <string.h>
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
52 #endif /* HAVE_STRING_H */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 #include <sys/types.h>
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
54 #ifdef HAVE_UNISTD_H
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 #include <unistd.h>
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
56 #endif /* HAVE_UNISTD_H */
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
57 #include <signal.h>
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
58
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
59 int read_line(int, char *);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 #if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 !defined(INTERNET_DOMAIN_SOCKETS)
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
63 int
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
64 main (int argc, char *argv[])
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 fprintf (stderr, "Sorry, the Emacs server is only "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 "supported on systems that have\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 fprintf (stderr, "Unix Domain sockets, Internet Domain "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 "sockets or System V IPC.\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 exit (1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 } /* main */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 #else /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 static char cwd[MAXPATHLEN+2]; /* current working directory when calculated */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 static char *cp = NULL; /* ptr into valid bit of cwd above */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
77 static pid_t emacs_pid; /* Process id for emacs process */
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
78
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
79 void initialize_signals (void);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
80
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 153
diff changeset
81 static void
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
82 tell_emacs_to_resume (int sig)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
83 {
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
84 char buffer[GSERV_BUFSZ+1];
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
85 int s; /* socket / msqid to server */
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
86 int connect_type; /* CONN_UNIX, CONN_INTERNET, or
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
87 ONN_IPC */
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
88
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
89 /* Why is SYSV so retarded? */
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
90 /* We want emacs to realize that we are resuming */
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
91 signal(SIGCONT, tell_emacs_to_resume);
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
92
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
93 connect_type = make_connection (NULL, (u_short) 0, &s);
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
94
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
95 sprintf(buffer,"(gnuserv-eval '(resume-pid-console %d))", (int)getpid());
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
96 send_string(s, buffer);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
97
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
98 #ifdef SYSV_IPC
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
99 if (connect_type == (int) CONN_IPC)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
100 disconnect_from_ipc_server (s, msgp, FALSE);
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
101 #else /* !SYSV_IPC */
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
102 if (connect_type != (int) CONN_IPC)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
103 disconnect_from_server (s, FALSE);
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
104 #endif /* !SYSV_IPC */
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
105 }
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
106
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 153
diff changeset
107 static void
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
108 pass_signal_to_emacs (int sig)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
109 {
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
110 if (kill (emacs_pid, sig) == -1)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
111 {
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
112 fprintf (stderr, "gnuattach: Could not pass signal to emacs process\n");
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
113 exit (1);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
114 }
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
115 initialize_signals ();
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
116 }
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
117
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
118 void
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
119 initialize_signals ()
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
120 {
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
121 /* Set up signal handler to pass relevant signals to emacs process.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
122 We used to send SIGSEGV, SIGBUS, SIGPIPE, SIGILL and others to
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
123 Emacs, but I think it's better not to. I can see no reason why
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
124 Emacs should SIGSEGV whenever gnuclient SIGSEGV-s, etc. */
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
125 signal (SIGHUP, pass_signal_to_emacs);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
126 signal (SIGQUIT, pass_signal_to_emacs);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
127 signal (SIGINT, pass_signal_to_emacs);
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
128 #ifdef SIGWINCH
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
129 signal (SIGWINCH, pass_signal_to_emacs);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
130 #endif
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
131
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
132 /* We want emacs to realize that we are resuming */
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
133 signal (SIGCONT, tell_emacs_to_resume);
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
134 }
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
135
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 get_current_working_directory -- return the cwd.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 static char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 get_current_working_directory (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 if (cp == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 { /* haven't calculated it yet */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 #ifdef BSD
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 if (getwd (cwd) == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 #else /* !BSD */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 if (getcwd (cwd,MAXPATHLEN) == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 #endif /* !BSD */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 perror (progname);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 fprintf (stderr, "%s: unable to get current working directory\n",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 progname);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 exit (1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 } /* if */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 /* on some systems, cwd can look like '@machine/' ... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 /* ignore everything before the first '/' */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 for (cp = cwd; *cp && *cp != '/'; ++cp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 } /* if */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 return cp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 } /* get_current_working_directory */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 filename_expand -- try to convert the given filename into a fully-qualified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 pathname.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 filename_expand (char *fullpath, char *filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 /* fullpath - returned full pathname */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 /* filename - filename to expand */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 int len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 fullpath[0] = '\0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 if (filename[0] && filename[0] != '/')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 { /* relative filename */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 strcat (fullpath, get_current_working_directory ());
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 len = strlen (fullpath);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 if (len > 0 && fullpath[len-1] == '/') /* trailing slash already? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ; /* yep */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 strcat (fullpath, "/"); /* nope, append trailing slash */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 } /* if */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 strcat (fullpath,filename);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 } /* filename_expand */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
197 /* Encase the string in quotes, escape all the backslashes and quotes
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
198 in string. */
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 153
diff changeset
199 static char *
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
200 clean_string (CONST char *s)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
201 {
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
202 int i = 0;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
203 char *p, *res;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
204
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
205 for (p = s; *p; p++, i++)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
206 {
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
207 if (*p == '\\' || *p == '\"')
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
208 ++i;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
209 else if (*p == '\004')
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
210 i += 3;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
211 }
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
212 p = res = (char *)malloc (i + 2 + 1);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
213 *p++ = '\"';
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
214 for (; *s; p++, s++)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
215 {
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
216 switch (*s)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
217 {
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
218 case '\\':
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
219 *p++ = '\\';
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
220 *p = '\\';
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
221 break;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
222 case '\"':
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
223 *p++ = '\\';
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
224 *p = '\"';
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
225 break;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
226 case '\004':
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
227 *p++ = '\\';
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
228 *p++ = 'C';
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
229 *p++ = '-';
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
230 *p = 'd';
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
231 break;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
232 default:
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
233 *p = *s;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
234 }
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
235 }
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
236 *p++ = '\"';
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
237 *p = '\0';
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
238 return res;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
239 }
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
240
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
241 #define GET_ARGUMENT(var, desc) do { \
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
242 if (*(p + 1)) (var) = p + 1; \
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
243 else \
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
244 { \
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
245 if (!argv[++i]) \
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
246 { \
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
247 fprintf (stderr, "%s: `%s' must be followed by an argument\n", \
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
248 progname, desc); \
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
249 exit (1); \
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
250 } \
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
251 (var) = argv[i]; \
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
252 } \
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
253 over = 1; \
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
254 } while (0)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
255
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
256 /* A strdup immitation. */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
257 static char *
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
258 my_strdup (CONST char *s)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
259 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
260 char *new = malloc (strlen (s) + 1);
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
261 if (new)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
262 strcpy (new, s);
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
263 return new;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
264 }
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
265
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
266 int
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
267 main (int argc, char *argv[])
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 {
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
269 int starting_line = 1; /* line to start editing at */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
270 char command[MAXPATHLEN+50]; /* emacs command buffer */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
271 char fullpath[MAXPATHLEN+1]; /* full pathname to file */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
272 char *eval_form = NULL; /* form to evaluate with `-eval' */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
273 char *eval_function = NULL; /* function to evaluate with `-f' */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
274 char *load_library = NULL; /* library to load */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
275 int quick = 0; /* quick edit, don't wait for user to
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
276 finish */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
277 int batch = 0; /* batch mode */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
278 int view = 0; /* view only. */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
279 int nofiles = 0;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
280 int errflg = 0; /* option error */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
281 int s; /* socket / msqid to server */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
282 int connect_type; /* CONN_UNIX, CONN_INTERNET, or
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
283 * CONN_IPC */
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
284 int suppress_windows_system = 0;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
285 char *display = NULL;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 #ifdef INTERNET_DOMAIN_SOCKETS
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
287 char *hostarg = NULL; /* remote hostname */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
288 char *remotearg;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
289 char thishost[HOSTNAMSZ]; /* this hostname */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
290 char remotepath[MAXPATHLEN+1]; /* remote pathname */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
291 char *path;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
292 int rflg = 0; /* pathname given on cmdline */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
293 char *portarg;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
294 u_short port = 0; /* port to server */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 #endif /* INTERNET_DOMAIN_SOCKETS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 #ifdef SYSV_IPC
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
297 struct msgbuf *msgp; /* message */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 #endif /* SYSV_IPC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 char *tty;
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
300 char buffer[GSERV_BUFSZ + 1]; /* buffer to read pid */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
301 char result[GSERV_BUFSZ + 1];
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
302 int i;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 #ifdef INTERNET_DOMAIN_SOCKETS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 memset (remotepath, 0, sizeof (remotepath));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 #endif /* INTERNET_DOMAIN_SOCKETS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
308 progname = strrchr (argv[0], '/');
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
309 if (progname)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
310 ++progname;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
311 else
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
312 progname = argv[0];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
314 display = getenv ("DISPLAY");
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
315 if (!display)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
316 suppress_windows_system = 1;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
317 else
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
318 display = my_strdup (display);
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
319
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
320 for (i = 1; argv[i] && !errflg; i++)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
321 {
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
322 if (*argv[i] != '-')
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 break;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
324 else if (*argv[i] == '-'
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
325 && (*(argv[i] + 1) == '\0'
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
326 || (*(argv[i] + 1) == '-' && *(argv[i] + 2) == '\0')))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
327 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
328 /* `-' or `--' */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
329 ++i;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
330 break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
331 }
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
332
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
333 if (!strcmp (argv[i], "-batch") || !strcmp (argv[i], "--batch"))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
334 batch = 1;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
335 else if (!strcmp (argv[i], "-eval") || !strcmp (argv[i], "--eval"))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
336 {
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
337 if (!argv[++i])
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
338 {
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
339 fprintf (stderr, "%s: `-eval' must be followed by an argument\n",
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
340 progname);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
341 exit (1);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
342 }
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
343 eval_form = argv[i];
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
344 }
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
345 else if (!strcmp (argv[i], "-display") || !strcmp (argv[i], "--display"))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
346 {
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
347 suppress_windows_system = 0;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
348 if (!argv[++i])
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
349 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
350 fprintf (stderr,
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
351 "%s: `-display' must be followed by an argument\n",
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
352 progname);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
353 exit (1);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
354 }
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
355 if (display)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
356 free (display);
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
357 /* no need to strdup. */
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
358 display = argv[i];
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
359 }
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
360 else if (!strcmp (argv[i], "-nw"))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
361 suppress_windows_system = 1;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
362 else
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
363 {
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
364 /* Iterate over one-letter options. */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
365 char *p;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
366 int over = 0;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
367 for (p = argv[i] + 1; *p && !over; p++)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
368 {
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
369 switch (*p)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
370 {
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
371 case 'q':
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
372 quick = 1;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
373 break;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
374 case 'v':
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
375 view = 1;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
376 break;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
377 case 'f':
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
378 GET_ARGUMENT (eval_function, "-f");
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
379 break;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
380 case 'l':
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
381 GET_ARGUMENT (load_library, "-l");
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
382 break;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 #ifdef INTERNET_DOMAIN_SOCKETS
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
384 case 'h':
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
385 GET_ARGUMENT (hostarg, "-h");
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
386 break;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
387 case 'p':
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
388 GET_ARGUMENT (portarg, "-p");
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
389 port = atoi (portarg);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
390 break;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
391 case 'r':
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
392 GET_ARGUMENT (remotearg, "-r");
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
393 strcpy (remotepath, remotearg);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
394 rflg = 1;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
395 break;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 #endif /* INTERNET_DOMAIN_SOCKETS */
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
397 default:
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
398 errflg = 1;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
399 }
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
400 } /* for */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
401 } /* else */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
402 } /* for */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 if (errflg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 fprintf (stderr,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 #ifdef INTERNET_DOMAIN_SOCKETS
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
408 "usage: %s [-nw] [-q] [-v] [-l library] [-f function] [-eval expr]\n"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
409 " [-h host] [-p port] [-r file-name] [[+line] file] ...\n",
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
410 #else /* !INTERNET_DOMAIN_SOCKETS */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
411 "usage: %s [-nw] [-q] [-v] [-l library] [-f function] [-eval expr] "
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 "[[+line] path] ...\n",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 #endif /* !INTERNET_DOMAIN_SOCKETS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 progname);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 exit (1);
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
416 }
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
417 if (batch && argv[i])
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 {
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
419 fprintf (stderr, "%s: Cannot specify `-batch' with file names\n",
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
420 progname);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
421 exit (1);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
422 }
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
423 if (suppress_windows_system && hostarg)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
424 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
425 fprintf (stderr, "%s: Remote editing is available only on X\n",
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
426 progname);
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
427 exit (1);
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
428 }
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
429
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
430 *result = '\0';
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
431 if (eval_function || eval_form || load_library)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
432 {
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
433 #if defined(INTERNET_DOMAIN_SOCKETS)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
434 connect_type = make_connection (hostarg, port, &s);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
435 #else
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
436 connect_type = make_connection (NULL, (u_short) 0, &s);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
437 #endif
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
438 sprintf (command, "(gnuserv-eval%s '(progn ", quick ? "-quickly" : "");
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
439 send_string (s, command);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
440 if (load_library)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
441 {
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
442 sprintf (command, " (load-library %s)", clean_string (load_library));
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
443 send_string (s, command);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
444 }
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
445 if (eval_form)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
446 {
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
447 sprintf (command, " %s", eval_form);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
448 send_string (s, command);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
449 }
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
450 if (eval_function)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
451 {
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
452 sprintf (command, " (%s)", eval_function);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
453 send_string (s, command);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
454 }
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
455 send_string (s, "))");
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
456 send_string (s, EOT_STR);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
457 if (read_line (s, result) == 0)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
458 {
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
459 fprintf (stderr, "%s: Could not read\n", progname);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
460 exit (1);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
461 }
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
462 } /* eval_function || eval_form || load_library */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
463 else if (batch)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
464 {
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
465 fprintf (stderr, "%s: `-batch' requires an evaluation\n",
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
466 progname);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
467 exit (1);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
468 }
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
469
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
470 if (!batch)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
471 {
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
472 if (suppress_windows_system)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
473 {
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
474 tty = ttyname (0);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
475 if (!tty)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
476 {
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
477 fprintf (stderr, "%s: Not connected to a tty", progname);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
478 exit (1);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
479 }
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
480 #if defined(INTERNET_DOMAIN_SOCKETS)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
481 connect_type = make_connection (hostarg, port, &s);
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
482 #else
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
483 connect_type = make_connection (NULL, (u_short) 0, &s);
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
484 #endif
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
485 send_string (s, "(gnuserv-eval '(emacs-pid))");
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
486 send_string (s, EOT_STR);
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
487
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
488 if (read_line (s, buffer) == 0)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
489 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
490 fprintf (stderr, "%s: Could not establish Emacs procces id\n",
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
491 progname);
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
492 exit (1);
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
493 }
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
494 /* Don't do disconnect_from_server becasue we have already read
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
495 data, and disconnect doesn't do anything else. */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
496 #ifndef INTERNET_DOMAIN_SOCKETS
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
497 if (connect_type == (int) CONN_IPC)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
498 disconnect_from_ipc_server (s, msgp, FALSE);
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
499 #endif /* !SYSV_IPC */
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
500
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
501 emacs_pid = (pid_t)atol(buffer);
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
502 initialize_signals();
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
503 } /* suppress_windows_system */
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 78
diff changeset
504
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
505 #if defined(INTERNET_DOMAIN_SOCKETS)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
506 connect_type = make_connection (hostarg, port, &s);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 #else
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
508 connect_type = make_connection (NULL, (u_short) 0, &s);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 #ifdef INTERNET_DOMAIN_SOCKETS
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
512 if (connect_type == (int) CONN_INTERNET)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
513 {
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
514 char *ptr;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
515 gethostname (thishost, HOSTNAMSZ);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
516 if (!rflg)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
517 { /* attempt to generate a path
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 * to this machine */
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
519 if ((ptr = getenv ("GNU_NODE")) != NULL)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
520 /* user specified a path */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
521 strcpy (remotepath, ptr);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
522 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 #if 0 /* This is really bogus... re-enable it if you must have it! */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 #if defined (hp9000s300) || defined (hp9000s800)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
525 else if (strcmp (thishost,hostarg))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
526 { /* try /net/thishost */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
527 strcpy (remotepath, "/net/"); /* (this fails using internet
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
528 addresses) */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
529 strcat (remotepath, thishost);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
530 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 #endif
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
533 }
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
534 else
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
535 { /* same machines, no need for path */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
536 remotepath[0] = '\0'; /* default is the empty path */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
537 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 #endif /* INTERNET_DOMAIN_SOCKETS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 #ifdef SYSV_IPC
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
541 if ((msgp = (struct msgbuf *)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
542 malloc (sizeof *msgp + GSERV_BUFSZ)) == NULL)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
543 {
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
544 fprintf (stderr, "%s: not enough memory for message buffer\n", progname);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
545 exit (1);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
546 } /* if */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
548 msgp->mtext[0] = '\0'; /* ready for later strcats */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 #endif /* SYSV_IPC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
551 if (suppress_windows_system)
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
552 {
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
553 char *term = getenv ("TERM");
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
554 if (!term)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
555 {
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
556 fprintf (stderr, "%s: unknown terminal type\n", progname);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
557 exit (1);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
558 }
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
559 sprintf (command, "(gnuserv-edit-files '(tty %s %s %d) '(",
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
560 clean_string (tty), clean_string (term), (int)getpid ());
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
561 }
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
562 else /* !suppress_windows_system */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
563 {
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
564 sprintf (command, "(gnuserv-edit-files '(x %s) '(",
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
565 clean_string (display));
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
566 } /* !suppress_windows_system */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
567 send_string (s, command);
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
568
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
569 if (!argv[i])
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
570 nofiles = 1;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
572 for (; argv[i]; i++)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 {
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
574 if (i < argc - 1 && *argv[i] == '+')
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
575 starting_line = atoi (argv[i++]);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
576 else
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
577 starting_line = 1;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
578 /* If the last argument is +something, treat it as a file. */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
579 if (i == argc)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
580 {
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
581 starting_line = 1;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
582 --i;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
583 }
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
584 filename_expand (fullpath, argv[i]);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 #ifdef INTERNET_DOMAIN_SOCKETS
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
586 path = malloc (strlen (remotepath) + strlen (fullpath) + 1);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
587 sprintf (path, "%s%s", remotepath, fullpath);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
588 #else
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
589 path = my_strdup (fullpath);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 #endif
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
591 sprintf (command, "(%d . %s)", starting_line, clean_string (path));
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
592 send_string (s, command);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
593 free (path);
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
594 } /* for */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
595
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
596 sprintf (command, ")%s%s",
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
597 (quick || (nofiles && !suppress_windows_system)) ? " 'quick" : "",
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
598 view ? " 'view" : "");
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 108
diff changeset
599 send_string (s, command);
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
600 send_string (s, ")");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 #ifdef SYSV_IPC
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
603 if (connect_type == (int) CONN_IPC)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
604 disconnect_from_ipc_server (s, msgp, FALSE);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 #else /* !SYSV_IPC */
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
606 if (connect_type != (int) CONN_IPC)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
607 disconnect_from_server (s, FALSE);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 #endif /* !SYSV_IPC */
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
609 } /* not batch */
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
610
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
611 if (batch && !quick)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
612 printf ("%s\n", result);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
614 return 0;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 } /* main */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 #endif /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */