RIP BOOL. Convert BOOL -> bool. I found a few interesting
[nivanova/samba-autobuild/.git] / source3 / rpc_parse / parse_eventlog.c
index 0f0b02748b3c26df453f09e621644f640521e046..70226bca151d82551ba332e5d6a539eb73041ac6 100644 (file)
@@ -5,7 +5,7 @@
  *  
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation; either version 3 of the License, or
  *  (at your option) any later version.
  *  
  *  This program is distributed in the hope that it will be useful,
@@ -14,8 +14,7 @@
  *  GNU General Public License for more details.
  *  
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
  
 #include "includes.h"
@@ -26,7 +25,7 @@
 /********************************************************************
 ********************************************************************/
 
-BOOL prs_ev_open_unknown0( const char *desc, prs_struct *ps, int depth, EVENTLOG_OPEN_UNKNOWN0 *u )
+bool prs_ev_open_unknown0( const char *desc, prs_struct *ps, int depth, EVENTLOG_OPEN_UNKNOWN0 *u )
 {
        if ( !u )
                return False;
@@ -42,7 +41,7 @@ BOOL prs_ev_open_unknown0( const char *desc, prs_struct *ps, int depth, EVENTLOG
 /********************************************************************
 ********************************************************************/
 
-BOOL eventlog_io_q_open_eventlog(const char *desc, EVENTLOG_Q_OPEN_EVENTLOG *q_u,
+bool eventlog_io_q_open_eventlog(const char *desc, EVENTLOG_Q_OPEN_EVENTLOG *q_u,
                                 prs_struct *ps, int depth)
 {
        if(q_u == NULL)
@@ -54,7 +53,7 @@ BOOL eventlog_io_q_open_eventlog(const char *desc, EVENTLOG_Q_OPEN_EVENTLOG *q_u
        if(!prs_align(ps))
                return False;
 
-       if ( !prs_pointer("", ps, depth, (void**)&q_u->unknown0, sizeof(EVENTLOG_OPEN_UNKNOWN0), (PRS_POINTER_CAST)prs_ev_open_unknown0))
+       if ( !prs_pointer("", ps, depth, (void*)&q_u->unknown0, sizeof(EVENTLOG_OPEN_UNKNOWN0), (PRS_POINTER_CAST)prs_ev_open_unknown0))
                return False;
 
        if ( !prs_unistr4("logname", ps, depth, &q_u->logname) )
@@ -75,7 +74,7 @@ BOOL eventlog_io_q_open_eventlog(const char *desc, EVENTLOG_Q_OPEN_EVENTLOG *q_u
        return True;
 }
 
-BOOL eventlog_io_r_open_eventlog(const char *desc, EVENTLOG_R_OPEN_EVENTLOG *r_u,
+bool eventlog_io_r_open_eventlog(const char *desc, EVENTLOG_R_OPEN_EVENTLOG *r_u,
                                 prs_struct *ps, int depth)
 {
        if(r_u == NULL)
@@ -96,7 +95,7 @@ BOOL eventlog_io_r_open_eventlog(const char *desc, EVENTLOG_R_OPEN_EVENTLOG *r_u
        return True;
 }
 
-BOOL eventlog_io_q_get_num_records(const char *desc, EVENTLOG_Q_GET_NUM_RECORDS *q_u,
+bool eventlog_io_q_get_num_records(const char *desc, EVENTLOG_Q_GET_NUM_RECORDS *q_u,
                                   prs_struct *ps, int depth)
 {
        if(q_u == NULL)
@@ -114,7 +113,7 @@ BOOL eventlog_io_q_get_num_records(const char *desc, EVENTLOG_Q_GET_NUM_RECORDS
        return True;
 }
 
-BOOL eventlog_io_r_get_num_records(const char *desc, EVENTLOG_R_GET_NUM_RECORDS *r_u,
+bool eventlog_io_r_get_num_records(const char *desc, EVENTLOG_R_GET_NUM_RECORDS *r_u,
                                   prs_struct *ps, int depth)
 {
        if(r_u == NULL)
@@ -135,7 +134,7 @@ BOOL eventlog_io_r_get_num_records(const char *desc, EVENTLOG_R_GET_NUM_RECORDS
        return True;
 }
 
-BOOL eventlog_io_q_get_oldest_entry(const char *desc, EVENTLOG_Q_GET_OLDEST_ENTRY *q_u,
+bool eventlog_io_q_get_oldest_entry(const char *desc, EVENTLOG_Q_GET_OLDEST_ENTRY *q_u,
                                    prs_struct *ps, int depth)
 {
        if(q_u == NULL)
@@ -153,7 +152,7 @@ BOOL eventlog_io_q_get_oldest_entry(const char *desc, EVENTLOG_Q_GET_OLDEST_ENTR
        return True;
 }
 
-BOOL eventlog_io_r_get_oldest_entry(const char *desc, EVENTLOG_R_GET_OLDEST_ENTRY *r_u,
+bool eventlog_io_r_get_oldest_entry(const char *desc, EVENTLOG_R_GET_OLDEST_ENTRY *r_u,
                                    prs_struct *ps, int depth)
 {
        if(r_u == NULL)
@@ -174,46 +173,7 @@ BOOL eventlog_io_r_get_oldest_entry(const char *desc, EVENTLOG_R_GET_OLDEST_ENTR
        return True;
 }
 
-BOOL eventlog_io_q_close_eventlog(const char *desc, EVENTLOG_Q_CLOSE_EVENTLOG *q_u,
-                                 prs_struct *ps, int depth)
-{
-       if(q_u == NULL)
-               return False;
-
-       prs_debug(ps, depth, desc, "eventlog_io_q_close_eventlog");
-       depth++;
-    
-       if(!(prs_align(ps)))
-               return False;
-
-       if(!(smb_io_pol_hnd("log handle", &(q_u->handle), ps, depth)))
-               return False;
-
-       return True;
-}
-
-BOOL eventlog_io_r_close_eventlog(const char *desc, EVENTLOG_R_CLOSE_EVENTLOG *r_u,
-                                 prs_struct *ps, int depth)
-{
-       if(r_u == NULL)
-               return False;
-
-       prs_debug(ps, depth, desc, "eventlog_io_r_close_eventlog");
-       depth++;
-
-       if(!(prs_align(ps)))
-               return False;
-
-       if(!(smb_io_pol_hnd("log handle", &(r_u->handle), ps, depth)))
-               return False;
-
-       if(!(prs_ntstatus("status code", ps, depth, &r_u->status)))
-               return False;
-
-       return True;
-}
-
-BOOL eventlog_io_q_read_eventlog(const char *desc, EVENTLOG_Q_READ_EVENTLOG *q_u,
+bool eventlog_io_q_read_eventlog(const char *desc, EVENTLOG_Q_READ_EVENTLOG *q_u,
                                 prs_struct *ps, int depth)
 {
        if(q_u == NULL)
@@ -246,7 +206,7 @@ BOOL eventlog_io_q_read_eventlog(const char *desc, EVENTLOG_Q_READ_EVENTLOG *q_u
    DWORD sent_size -- sum of EVENTLOGRECORD lengths if records returned, 0 otherwise
    DWORD real_size -- 0 if records returned, otherwise length of next record to be returned
    WERROR status */
-BOOL eventlog_io_r_read_eventlog(const char *desc,
+bool eventlog_io_r_read_eventlog(const char *desc,
                                 EVENTLOG_Q_READ_EVENTLOG *q_u,
                                 EVENTLOG_R_READ_EVENTLOG *r_u,
                                 prs_struct *ps,
@@ -294,7 +254,7 @@ BOOL eventlog_io_r_read_eventlog(const char *desc,
 
        while(entry != NULL && record_written < record_total)
        {
-               DEBUG(10, ("eventlog_io_r_read_eventlog: writing record [%d] out of [%d].\n", record_written, record_total));
+               DEBUG(11, ("eventlog_io_r_read_eventlog: writing record [%d] out of [%d].\n", record_written, record_total));
 
                /* Encode the actual eventlog record record */
 
@@ -353,18 +313,20 @@ BOOL eventlog_io_r_read_eventlog(const char *desc,
 
        /* Now pad with whitespace until the end of the response buffer */
 
-       r_u->end_of_entries_padding =
-               SMB_CALLOC_ARRAY(uint8,
-                                q_u->max_read_size - r_u->num_bytes_in_resp);
+       if (q_u->max_read_size - r_u->num_bytes_in_resp) {
+               if (!r_u->end_of_entries_padding) {
+                       return False;
+               }
 
-       if(!(prs_uint8s(False, "end of entries padding", ps, 
-               depth, r_u->end_of_entries_padding,
-               (q_u->max_read_size - r_u->num_bytes_in_resp))))
-       {
-               return False;
-       }
+               if(!(prs_uint8s(False, "end of entries padding", ps, 
+                               depth, r_u->end_of_entries_padding,
+                               (q_u->max_read_size - r_u->num_bytes_in_resp)))) {
+                       free(r_u->end_of_entries_padding);
+                       return False;
+               }
 
-       free(r_u->end_of_entries_padding);
+               free(r_u->end_of_entries_padding);
+       }
 
        /* We had better be DWORD aligned here */
 
@@ -392,7 +354,7 @@ BOOL eventlog_io_r_read_eventlog(const char *desc,
    I'm not sure where the \?? is coming from, or why the ${CWD} of the client process
    would be added in given that the backup file gets written on the server side. */
 
-BOOL eventlog_io_q_clear_eventlog(const char *desc, EVENTLOG_Q_CLEAR_EVENTLOG *q_u,
+bool eventlog_io_q_clear_eventlog(const char *desc, EVENTLOG_Q_CLEAR_EVENTLOG *q_u,
                                  prs_struct *ps, int depth)
 {
        if(q_u == NULL)
@@ -413,7 +375,7 @@ BOOL eventlog_io_q_clear_eventlog(const char *desc, EVENTLOG_Q_CLEAR_EVENTLOG *q
 
 }
 
-BOOL eventlog_io_r_clear_eventlog(const char *desc, EVENTLOG_R_CLEAR_EVENTLOG *r_u,
+bool eventlog_io_r_clear_eventlog(const char *desc, EVENTLOG_R_CLEAR_EVENTLOG *r_u,
                                  prs_struct *ps, int depth)
 {
        if(r_u == NULL)