svn commit: samba r24089 - in branches/SAMBA_3_2/source/smbd: .

vlendec at samba.org vlendec at samba.org
Tue Jul 31 08:06:57 GMT 2007


Author: vlendec
Date: 2007-07-31 08:06:56 +0000 (Tue, 31 Jul 2007)
New Revision: 24089

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24089

Log:
Add reply_prep/post_legacy 

Routines to ease the transition to the new API


Modified:
   branches/SAMBA_3_2/source/smbd/process.c


Changeset:
Modified: branches/SAMBA_3_2/source/smbd/process.c
===================================================================
--- branches/SAMBA_3_2/source/smbd/process.c	2007-07-31 07:57:33 UTC (rev 24088)
+++ branches/SAMBA_3_2/source/smbd/process.c	2007-07-31 08:06:56 UTC (rev 24089)
@@ -67,6 +67,60 @@
 	req->outbuf = NULL;
 }
 
+/*
+ * From within a converted call you might have to call non-converted
+ * subroutines that still take the old inbuf/outbuf/lenght/bufsize
+ * parameters. This takes a struct smb_request and prepares the legacy
+ * parameters.
+ */
+
+BOOL reply_prep_legacy(struct smb_request *req,
+		       char **pinbuf, char **poutbuf,
+		       int *psize, int *pbufsize)
+{
+	const int bufsize = (BUFFER_SIZE + LARGE_WRITEX_HDR_SIZE
+			     + SAFETY_MARGIN);
+	char *inbuf, *outbuf;
+
+	if (!(inbuf = TALLOC_ARRAY(req, char, bufsize))) {
+		DEBUG(0, ("Could not allocate legacy inbuf\n"));
+		return False;
+	}
+	memcpy(inbuf, req->inbuf, MIN(smb_len(req->inbuf)+4, bufsize));
+	req->inbuf = (uint8 *)inbuf;
+
+	if (!(outbuf = TALLOC_ARRAY(req, char, bufsize))) {
+		DEBUG(0, ("Could not allocate legacy outbuf\n"));
+		return False;
+	}
+	req->outbuf = (uint8 *)outbuf;
+
+	construct_reply_common(inbuf, outbuf);
+
+	*pinbuf   = inbuf;
+	*poutbuf  = outbuf;
+	*psize    = smb_len(inbuf)+4;
+	*pbufsize = bufsize;
+
+	return True;
+}
+
+/*
+ * Post-process the output of the legacy routine so that the result fits into
+ * the new reply_xxx API
+ */
+
+void reply_post_legacy(struct smb_request *req, int outsize)
+{
+	if (outsize > 0) {
+		smb_setlen((char *)req->inbuf, (char *)req->outbuf,
+			   outsize);
+	}
+	else {
+		TALLOC_FREE(req->outbuf);
+	}
+}
+
 /****************************************************************************
  structure to hold a linked list of queued messages.
  for processing.



More information about the samba-cvs mailing list