From 3261f8029697c2c5b06a9b68e3f62e51e3466dfc Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Tue, 13 Nov 2001 17:06:16 +0000
Subject: [PATCH] Added smb_getfirstidx() API function.

---
 src/smblib/smblib.c | 14 ++++++++++++++
 src/smblib/smblib.h |  2 ++
 2 files changed, 16 insertions(+)

diff --git a/src/smblib/smblib.c b/src/smblib/smblib.c
index 31ca1776bf..8db6d256e9 100644
--- a/src/smblib/smblib.c
+++ b/src/smblib/smblib.c
@@ -534,6 +534,20 @@ int SMBCALL smb_getmsgidx(smb_t* smb, smbmsg_t* msg)
 	return(0);
 }
 
+/****************************************************************************/
+/* Reads the first index record in the open message base 					*/
+/****************************************************************************/
+int SMBCALL smb_getfirstidx(smb_t* smb, idxrec_t *idx)
+{
+	clearerr(smb->sid_fp);
+	fseek(smb->sid_fp,0,SEEK_SET);
+	if(!fread(idx,sizeof(idxrec_t),1,smb->sid_fp)) {
+		sprintf(smb->last_error,"reading index");
+		return(-2);
+	}
+	return(0);
+}
+
 /****************************************************************************/
 /* Reads the last index record in the open message base 					*/
 /****************************************************************************/
diff --git a/src/smblib/smblib.h b/src/smblib/smblib.h
index 4c9de40e25..316b58ac08 100644
--- a/src/smblib/smblib.h
+++ b/src/smblib/smblib.h
@@ -104,6 +104,7 @@ SMBEXPORT int 	SMBCALL smb_getstatus(smb_t* smb);
 SMBEXPORT int 	SMBCALL smb_putstatus(smb_t* smb);
 SMBEXPORT int 	SMBCALL smb_unlocksmbhdr(smb_t* smb);
 SMBEXPORT int 	SMBCALL smb_getmsgidx(smb_t* smb, smbmsg_t* msg);
+SMBEXPORT int 	SMBCALL smb_getfirstidx(smb_t* smb, idxrec_t *idx);
 SMBEXPORT int 	SMBCALL smb_getlastidx(smb_t* smb, idxrec_t *idx);
 SMBEXPORT uint	SMBCALL smb_getmsghdrlen(smbmsg_t* msg);
 SMBEXPORT ulong	SMBCALL smb_getmsgdatlen(smbmsg_t* msg);
@@ -171,6 +172,7 @@ SMBEXPORT void	SMBCALL smb_clearerr(FILE* fp);
 #pragma aux smb_putstatus		"_*"
 #pragma aux smb_unlocksmbhdr	"_*"
 #pragma aux smb_getmsgidx		"_*"
+#pragma aux smb_getfirstidx		"_*"
 #pragma aux smb_getlastidx		"_*"
 #pragma aux smb_getmsghdrlen	"_*"
 #pragma aux smb_getmsgdatlen	"_*"
-- 
GitLab