From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.devel Subject: Re: Allow specifying services as symbols? Date: Tue, 19 Oct 2010 14:09:03 -0500 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <87sk02ngog.fsf@lifelogs.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1287515370 4790 80.91.229.12 (19 Oct 2010 19:09:30 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 19 Oct 2010 19:09:30 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 19 21:09:29 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1P8HYv-0003Xu-3O for ged-emacs-devel@m.gmane.org; Tue, 19 Oct 2010 21:09:29 +0200 Original-Received: from localhost ([127.0.0.1]:57692 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8HYu-0002dz-HO for ged-emacs-devel@m.gmane.org; Tue, 19 Oct 2010 15:09:28 -0400 Original-Received: from [140.186.70.92] (port=35089 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8HYm-0002dk-8T for emacs-devel@gnu.org; Tue, 19 Oct 2010 15:09:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P8HYi-0003xi-49 for emacs-devel@gnu.org; Tue, 19 Oct 2010 15:09:20 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:42842) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P8HYh-0003xc-QB for emacs-devel@gnu.org; Tue, 19 Oct 2010 15:09:16 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1P8HYd-0003R5-GD for emacs-devel@gnu.org; Tue, 19 Oct 2010 21:09:11 +0200 Original-Received: from 38.98.147.130 ([38.98.147.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 19 Oct 2010 21:09:11 +0200 Original-Received: from tzz by 38.98.147.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 19 Oct 2010 21:09:11 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 70 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 38.98.147.130 X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:Vg1NoiHts++8Nxn9MH0mOVhFKdk= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:131855 Archived-At: --=-=-= Content-Type: text/plain On Tue, 19 Oct 2010 20:07:46 +0200 Lars Magne Ingebrigtsen wrote: LMI> It was suggested that we should allow specifying port names (e.g., LMI> "imap") as symbols, too, in addition to strings and numbers. Any LMI> objections to something like the following? My patch, attached here, corrects the docstring and fixes the two places where the port should be a symbol (you only got one, I think, because of the "goto open_socket" right before "#endif /* HAVE_GETADDRINFO */"). I'll write a manual patch as well if this is acceptable. Ted --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=make-network-connection-with-symbol-service.patch === modified file 'src/process.c' --- src/process.c 2010-10-08 10:14:47 +0000 +++ src/process.c 2010-10-19 18:26:51 +0000 @@ -2978,10 +2978,11 @@ host, and only clients connecting to that address will be accepted. :service SERVICE -- SERVICE is name of the service desired, or an -integer specifying a port number to connect to. If SERVICE is t, -a random port number is selected for the server. (If Emacs was -compiled with getaddrinfo, a port number can also be specified as a -string, e.g. "80", as well as an integer. This is not portable.) +integer specifying a port number to connect to. If SERVICE is t, a +random port number is selected for the server. A port number can also +be specified as a string, e.g. "80", or a symbol whose name will be +used, as well as an integer. This is not necessarily portable; either +getaddrinfo or getservbyname will be used to look up the port number. :type TYPE -- TYPE is the type of connection. The default (nil) is a stream type connection, `datagram' creates a datagram type connection, @@ -3303,6 +3304,11 @@ Otherwise, use getservbyname to lookup the service. */ if (!NILP (host)) { + /* Take a symbol as the service and convert it to a string. */ + if (SYMBOLP (service)) + { + service = Fsymbol_name (service); + } /* SERVICE can either be a string or int. Convert to a C string for later use by getaddrinfo. */ @@ -3347,6 +3353,12 @@ /* We end up here if getaddrinfo is not defined, or in case no hostname has been specified (e.g. for a local server process). */ + /* Take a symbol as the service and convert it to a string. */ + if (SYMBOLP (service)) + { + service = Fsymbol_name (service); + } + if (EQ (service, Qt)) port = 0; else if (INTEGERP (service)) --=-=-=--