summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2007-07-31 08:06:56 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:29:04 -0500
commit15dc8917dbe5a1fed5ca909bb1bee24cff59db0f (patch)
tree0c10b66c0b2d0d04440001bbf25d2b87d45dc2af /source3/smbd
parent4254af71803b122449887258ac0e721f67ed39a3 (diff)
downloadsamba-15dc8917dbe5a1fed5ca909bb1bee24cff59db0f.tar.gz
samba-15dc8917dbe5a1fed5ca909bb1bee24cff59db0f.tar.bz2
samba-15dc8917dbe5a1fed5ca909bb1bee24cff59db0f.zip
r24089: Add reply_prep/post_legacy
Routines to ease the transition to the new API (This used to be commit 1bb2b341e2cb6c0175376dc8bd2d1ce6d9c6c00e)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/process.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index e99d70f236..1fba7e487c 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -67,6 +67,60 @@ void init_smb_request(struct smb_request *req, const uint8 *inbuf)
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.