Add prs_dump_before to dump everything from the start of the prs
authorMartin Pool <mbp@samba.org>
Wed, 2 Jan 2002 07:48:07 +0000 (07:48 +0000)
committerMartin Pool <mbp@samba.org>
Wed, 2 Jan 2002 07:48:07 +0000 (07:48 +0000)
buffer up to the current position, and use this to dump pipe buffers
just before parsing.
(This used to be commit 92a3ab274e6cf09a8ba39b91f8bbacba6de40b37)

source3/rpc_client/cli_pipe.c
source3/rpc_parse/parse_prs.c

index 0d2f6b17e0bff68457908d093e97948cc2f7c733..63abbc1c5679addfbbb09907fd23654609370d50 100644 (file)
@@ -796,7 +796,7 @@ BOOL rpc_api_pipe_req(struct cli_state *cli, uint8 op_num,
        /* Optionally capture for use in debugging */
        slprintf(dump_name, sizeof(dump_name) - 1, "call_%s",
                 cli_pipe_get_name(cli));
-       prs_dump(dump_name, op_num, data);
+       prs_dump_before(dump_name, op_num, data);
 
        /*
         * The auth_len doesn't include the RPC_HDR_AUTH_LEN.
index f902210b7b8afb38fba6b171af9a05b5ce927d30..8bb9f1c70aad5495d1fd04703be0208be80427a4 100644 (file)
 
 #include "includes.h"
 
-/*******************************************************************
-dump a prs to a file
- ********************************************************************/
+/**
+ * Dump a prs to a file: from the current location through to the end.
+ **/
 void prs_dump(char *name, int v, prs_struct *ps)
+{
+       prs_dump_region(name, v, ps, ps->data_offset, ps->buffer_size);
+}
+
+
+/**
+ * Dump from the start of the prs to the current location.
+ **/
+void prs_dump_before(char *name, int v, prs_struct *ps)
+{
+       prs_dump_region(name, v, ps, 0, ps->data_offset);
+}
+
+
+/**
+ * Dump everything from the start of the prs up to the current location.
+ **/
+void prs_dump_region(char *name, int v, prs_struct *ps,
+                    int from_off, int to_off)
 {
        int fd, i;
        pstring fname;
@@ -41,7 +60,7 @@ void prs_dump(char *name, int v, prs_struct *ps)
                if (fd != -1 || errno != EEXIST) break;
        }
        if (fd != -1) {
-               write(fd, ps->data_p + ps->data_offset, ps->buffer_size - ps->data_offset);
+               write(fd, ps->data_p + from_off, to_off - from_off);
                close(fd);
                DEBUG(0,("created %s\n", fname));
        }