]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - lib/rfcnb/session.c
Source Format Enforcement (#763)
[thirdparty/squid.git] / lib / rfcnb / session.c
index c3b87df56fecfbb3f56f4bf1cb2c77a97ee81ba5..d4daadeaec4bf315cf1d769e5a1c12331b0326fc 100644 (file)
@@ -1,4 +1,10 @@
-#include "config.h"
+/*
+ * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
 
 /* UNIX RFCNB (RFC1001/RFC1002) NetBIOS implementation
  *
@@ -6,7 +12,6 @@
  * Session Routines ...
  *
  * Copyright (C) Richard Sharpe 1996
- *
  */
 
 /*
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include "squid.h"
+
 int RFCNB_errno = 0;
 int RFCNB_saved_errno = 0;
 #define RFCNB_ERRNO
 
 #include "rfcnb/std-includes.h"
 #include <netinet/tcp.h>
-#include "rfcnb/rfcnb.h"
-#include "rfcnb/rfcnb-priv.h"
 #include "rfcnb/rfcnb-io.h"
+#include "rfcnb/rfcnb-priv.h"
 #include "rfcnb/rfcnb-util.h"
+#include "rfcnb/rfcnb.h"
 
 #if HAVE_STRING_H
 #include <string.h>
@@ -42,13 +49,8 @@ int RFCNB_saved_errno = 0;
 
 int RFCNB_Stats[RFCNB_MAX_STATS];
 
-typedef void RFCNB_Prot_Print_Routine(FILE * fd, int dir, struct RFCNB_Pkt *pkt, int header, int payload);
 RFCNB_Prot_Print_Routine *Prot_Print_Routine = NULL;   /* Pointer to protocol print routine */
 
-int RFCNB_Get_Last_Errno(void);
-int RFCNB_Get_Error_Msg(int code, char *msg_buf, int len);
-void RFCNB_Register_Print_Routine(RFCNB_Prot_Print_Routine * fn);
-
 /* Set up a session with a remote name. We are passed Called_Name as a
  * string which we convert to a NetBIOS name, ie space terminated, up to
  * 16 characters only if we need to. If Called_Address is not empty, then
@@ -84,11 +86,12 @@ RFCNB_Call(char *Called_Name, char *Calling_Name, char *Called_Address, int port
     con->errn = 0;              /* no error yet */
     con->timeout = 0;           /* no timeout   */
     con->redirects = 0;
+    con->redirect_list = con->last_addr = NULL;
 
     /* Resolve that name into an IP address */
 
     Service_Address = Called_Name;
-    if (strcmp(Called_Address, "") != 0) {      /* If the Called Address = "" */
+    if (strlen(Called_Address) != 0) {      /* If the Called Address = "" */
         Service_Address = Called_Address;
     }
     if ((errno = RFCNB_Name_To_IP(Service_Address, &Dest_IP)) < 0) {    /* Error */
@@ -213,6 +216,7 @@ RFCNB_Send(struct RFCNB_Con *Con_Handle, struct RFCNB_Pkt *udata, int Length)
 
         /* No need to change RFCNB_errno as it was done by put_pkt ...     */
 
+        RFCNB_Free_Pkt(pkt);
         return (RFCNBE_Bad);    /* Should be able to write that lot ... */
 
     }
@@ -261,7 +265,7 @@ RFCNB_Recv(void *con_Handle, struct RFCNB_Pkt *Data, int Length)
 #ifdef RFCNB_DEBUG
         fprintf(stderr, "Bad packet return in RFCNB_Recv... \n");
 #endif
-
+        RFCNB_Free_Pkt(pkt);
         return (RFCNBE_Bad);
 
     }
@@ -327,23 +331,3 @@ RFCNB_Get_Last_Error()
     return (RFCNB_errno);
 }
 
-/* Pick up saved errno as well */
-int
-RFCNB_Get_Last_Errno()
-{
-    return (RFCNB_saved_errno);
-}
-
-/* Pick up the last error response and return in string ...             */
-int
-RFCNB_Get_Error_Msg(int code, char *msg_buf, int len)
-{
-    return (strncpy(msg_buf, RFCNB_Error_Strings[abs(code)], len) != NULL);
-}
-
-/* Register a higher level protocol print routine */
-void
-RFCNB_Register_Print_Routine(RFCNB_Prot_Print_Routine * fn)
-{
-    Prot_Print_Routine = fn;
-}