All of lore.kernel.org
 help / color / mirror / Atom feed
From: Per Jessen <per@computer.org>
To: linux-diald@vger.kernel.org
Subject: possible patch regarding problems parsing /etc/protocols
Date: Sat, 26 Oct 2002 11:26:44 +0200	[thread overview]
Message-ID: <200210261126.44206.per@computer.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 578 bytes --]

All,
I'm sure there is a reason why utils.c isn't using the getservent/getprotoent services from netdb.h - 
maybe platform related ? I don't know - but here is a patch that 1) uses those services for accessing
/etc/protocols and /etc/services, and thereby fixes the minor problem with comments in either file.
At least it works on Linux. 

http://mitglied.lycos.de/pjessen/patches/patch-diald-1.0-utils

-- 

regards,
Per Jessen, Zurich
http://www.enidan.com - home of the J1 serial console.

Genius may have its limitations, but stupidity is not thus handicapped.

[-- Attachment #2: patch-diald-1.0-utils --]
[-- Type: text/x-diff, Size: 1060 bytes --]

--- diald-1.0/utils.c	Sat Jun 16 21:51:39 2001
+++ diald-1.0.pj/utils.c	Sat Oct 26 10:50:57 2002
@@ -2,6 +2,7 @@
 
 #include <diald.h>
 
+#include <netdb.h>
 
 /* Grumble. Attempt to generate a nicely formatted ascii date without
  * a built in newline.
@@ -35,6 +36,35 @@
     return i;
 }
 
+int getprotocol(const char *name)
+{
+        struct protoent *p;
+
+        return  NULL!=(p=getprotobyname(name)) ? p->p_proto : 0;
+}
+
+char *getprotonumber(int proto)
+{
+        static char buf[16];
+        struct protoent *p;
+
+        if ( NULL!=(p=getprotobynumber(proto)) )
+                strcpy(buf,p->p_name);
+        else
+                sprintf(buf, "%d", proto);
+
+        return buf;
+}
+
+
+int getservice(const char *name, const char *proto)
+{
+        struct servent *service;
+
+        return  NULL!=(service=getservbyname( name, proto)) ? ntohs(service->s_port) : 0;
+}
+
+#if 0
 struct proto {
 	char *name;
 	int proto;
@@ -151,6 +181,7 @@
         }
     return 0;
 }
+#endif
 
 #if 0
 /* Stuff needed because to keep checker happy,

             reply	other threads:[~2002-10-26  9:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-26  9:26 Per Jessen [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-12-04 12:27 possible patch regarding problems parsing /etc/protocols Per Jessen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200210261126.44206.per@computer.org \
    --to=per@computer.org \
    --cc=linux-diald@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.