charset: look for the codepages in the right place
[ira/wip.git] / librpc / gen_ndr / srv_eventlog.c
index 950daa5dd1f175442c42c9972ed81b74a3eafdbb..2cab792adf9b146f935d0792be71f986ca626be7 100644 (file)
@@ -265,6 +265,8 @@ static bool api_eventlog_DeregisterEventSource(pipes_struct *p)
                NDR_PRINT_IN_DEBUG(eventlog_DeregisterEventSource, r);
        }
 
+       ZERO_STRUCT(r->out);
+       r->out.handle = r->in.handle;
        r->out.result = _eventlog_DeregisterEventSource(p, r);
 
        if (p->rng_fault_state) {
@@ -651,6 +653,13 @@ static bool api_eventlog_RegisterEventSourceW(pipes_struct *p)
                NDR_PRINT_IN_DEBUG(eventlog_RegisterEventSourceW, r);
        }
 
+       ZERO_STRUCT(r->out);
+       r->out.log_handle = talloc_zero(r, struct policy_handle);
+       if (r->out.log_handle == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
        r->out.result = _eventlog_RegisterEventSourceW(p, r);
 
        if (p->rng_fault_state) {
@@ -724,6 +733,13 @@ static bool api_eventlog_OpenBackupEventLogW(pipes_struct *p)
                NDR_PRINT_IN_DEBUG(eventlog_OpenBackupEventLogW, r);
        }
 
+       ZERO_STRUCT(r->out);
+       r->out.handle = talloc_zero(r, struct policy_handle);
+       if (r->out.handle == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
        r->out.result = _eventlog_OpenBackupEventLogW(p, r);
 
        if (p->rng_fault_state) {
@@ -889,6 +905,9 @@ static bool api_eventlog_ReportEventW(pipes_struct *p)
                NDR_PRINT_IN_DEBUG(eventlog_ReportEventW, r);
        }
 
+       ZERO_STRUCT(r->out);
+       r->out.record_number = r->in.record_number;
+       r->out.time_written = r->in.time_written;
        r->out.result = _eventlog_ReportEventW(p, r);
 
        if (p->rng_fault_state) {
@@ -1654,18 +1673,18 @@ static bool api_eventlog_WriteClusterEvents(pipes_struct *p)
        return true;
 }
 
-static bool api_eventlog_GetLogIntormation(pipes_struct *p)
+static bool api_eventlog_GetLogInformation(pipes_struct *p)
 {
        const struct ndr_interface_call *call;
        struct ndr_pull *pull;
        struct ndr_push *push;
        enum ndr_err_code ndr_err;
        DATA_BLOB blob;
-       struct eventlog_GetLogIntormation *r;
+       struct eventlog_GetLogInformation *r;
 
-       call = &ndr_table_eventlog.calls[NDR_EVENTLOG_GETLOGINTORMATION];
+       call = &ndr_table_eventlog.calls[NDR_EVENTLOG_GETLOGINFORMATION];
 
-       r = talloc(talloc_tos(), struct eventlog_GetLogIntormation);
+       r = talloc(talloc_tos(), struct eventlog_GetLogInformation);
        if (r == NULL) {
                return false;
        }
@@ -1689,10 +1708,23 @@ static bool api_eventlog_GetLogIntormation(pipes_struct *p)
        }
 
        if (DEBUGLEVEL >= 10) {
-               NDR_PRINT_IN_DEBUG(eventlog_GetLogIntormation, r);
+               NDR_PRINT_IN_DEBUG(eventlog_GetLogInformation, r);
+       }
+
+       ZERO_STRUCT(r->out);
+       r->out.buffer = talloc_zero_array(r, uint8_t, r->in.buf_size);
+       if (r->out.buffer == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       r->out.bytes_needed = talloc_zero(r, uint32_t);
+       if (r->out.bytes_needed == NULL) {
+               talloc_free(r);
+               return false;
        }
 
-       r->out.result = _eventlog_GetLogIntormation(p, r);
+       r->out.result = _eventlog_GetLogInformation(p, r);
 
        if (p->rng_fault_state) {
                talloc_free(r);
@@ -1701,7 +1733,7 @@ static bool api_eventlog_GetLogIntormation(pipes_struct *p)
        }
 
        if (DEBUGLEVEL >= 10) {
-               NDR_PRINT_OUT_DEBUG(eventlog_GetLogIntormation, r);
+               NDR_PRINT_OUT_DEBUG(eventlog_GetLogInformation, r);
        }
 
        push = ndr_push_init_ctx(r, NULL);
@@ -1800,6 +1832,82 @@ static bool api_eventlog_FlushEventLog(pipes_struct *p)
        return true;
 }
 
+static bool api_eventlog_ReportEventAndSourceW(pipes_struct *p)
+{
+       const struct ndr_interface_call *call;
+       struct ndr_pull *pull;
+       struct ndr_push *push;
+       enum ndr_err_code ndr_err;
+       DATA_BLOB blob;
+       struct eventlog_ReportEventAndSourceW *r;
+
+       call = &ndr_table_eventlog.calls[NDR_EVENTLOG_REPORTEVENTANDSOURCEW];
+
+       r = talloc(talloc_tos(), struct eventlog_ReportEventAndSourceW);
+       if (r == NULL) {
+               return false;
+       }
+
+       if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull = ndr_pull_init_blob(&blob, r, NULL);
+       if (pull == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       pull->flags |= LIBNDR_FLAG_REF_ALLOC;
+       ndr_err = call->ndr_pull(pull, NDR_IN, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(eventlog_ReportEventAndSourceW, r);
+       }
+
+       ZERO_STRUCT(r->out);
+       r->out.record_number = r->in.record_number;
+       r->out.time_written = r->in.time_written;
+       r->out.result = _eventlog_ReportEventAndSourceW(p, r);
+
+       if (p->rng_fault_state) {
+               talloc_free(r);
+               /* Return true here, srv_pipe_hnd.c will take care */
+               return true;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(eventlog_ReportEventAndSourceW, r);
+       }
+
+       push = ndr_push_init_ctx(r, NULL);
+       if (push == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       ndr_err = call->ndr_push(push, NDR_OUT, r);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               talloc_free(r);
+               return false;
+       }
+
+       blob = ndr_push_blob(push);
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+               talloc_free(r);
+               return false;
+       }
+
+       talloc_free(r);
+
+       return true;
+}
+
 
 /* Tables */
 static struct api_struct api_eventlog_cmds[] = 
@@ -1826,8 +1934,9 @@ static struct api_struct api_eventlog_cmds[] =
        {"EVENTLOG_REGISTERCLUSTERSVC", NDR_EVENTLOG_REGISTERCLUSTERSVC, api_eventlog_RegisterClusterSvc},
        {"EVENTLOG_DEREGISTERCLUSTERSVC", NDR_EVENTLOG_DEREGISTERCLUSTERSVC, api_eventlog_DeregisterClusterSvc},
        {"EVENTLOG_WRITECLUSTEREVENTS", NDR_EVENTLOG_WRITECLUSTEREVENTS, api_eventlog_WriteClusterEvents},
-       {"EVENTLOG_GETLOGINTORMATION", NDR_EVENTLOG_GETLOGINTORMATION, api_eventlog_GetLogIntormation},
+       {"EVENTLOG_GETLOGINFORMATION", NDR_EVENTLOG_GETLOGINFORMATION, api_eventlog_GetLogInformation},
        {"EVENTLOG_FLUSHEVENTLOG", NDR_EVENTLOG_FLUSHEVENTLOG, api_eventlog_FlushEventLog},
+       {"EVENTLOG_REPORTEVENTANDSOURCEW", NDR_EVENTLOG_REPORTEVENTANDSOURCEW, api_eventlog_ReportEventAndSourceW},
 };
 
 void eventlog_get_pipe_fns(struct api_struct **fns, int *n_fns)
@@ -1836,7 +1945,237 @@ void eventlog_get_pipe_fns(struct api_struct **fns, int *n_fns)
        *n_fns = sizeof(api_eventlog_cmds) / sizeof(struct api_struct);
 }
 
+NTSTATUS rpc_eventlog_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const struct ndr_interface_table *table, uint32_t opnum, void *_r)
+{
+       if (cli->pipes_struct == NULL) {
+               return NT_STATUS_INVALID_PARAMETER;
+       }
+
+       switch (opnum)
+       {
+               case NDR_EVENTLOG_CLEAREVENTLOGW: {
+                       struct eventlog_ClearEventLogW *r = (struct eventlog_ClearEventLogW *)_r;
+                       r->out.result = _eventlog_ClearEventLogW(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
+               case NDR_EVENTLOG_BACKUPEVENTLOGW: {
+                       struct eventlog_BackupEventLogW *r = (struct eventlog_BackupEventLogW *)_r;
+                       r->out.result = _eventlog_BackupEventLogW(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
+               case NDR_EVENTLOG_CLOSEEVENTLOG: {
+                       struct eventlog_CloseEventLog *r = (struct eventlog_CloseEventLog *)_r;
+                       ZERO_STRUCT(r->out);
+                       r->out.handle = r->in.handle;
+                       r->out.result = _eventlog_CloseEventLog(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
+               case NDR_EVENTLOG_DEREGISTEREVENTSOURCE: {
+                       struct eventlog_DeregisterEventSource *r = (struct eventlog_DeregisterEventSource *)_r;
+                       ZERO_STRUCT(r->out);
+                       r->out.handle = r->in.handle;
+                       r->out.result = _eventlog_DeregisterEventSource(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
+               case NDR_EVENTLOG_GETNUMRECORDS: {
+                       struct eventlog_GetNumRecords *r = (struct eventlog_GetNumRecords *)_r;
+                       ZERO_STRUCT(r->out);
+                       r->out.number = talloc_zero(mem_ctx, uint32_t);
+                       if (r->out.number == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+                       }
+
+                       r->out.result = _eventlog_GetNumRecords(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
+               case NDR_EVENTLOG_GETOLDESTRECORD: {
+                       struct eventlog_GetOldestRecord *r = (struct eventlog_GetOldestRecord *)_r;
+                       ZERO_STRUCT(r->out);
+                       r->out.oldest_entry = talloc_zero(mem_ctx, uint32_t);
+                       if (r->out.oldest_entry == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+                       }
+
+                       r->out.result = _eventlog_GetOldestRecord(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
+               case NDR_EVENTLOG_CHANGENOTIFY: {
+                       struct eventlog_ChangeNotify *r = (struct eventlog_ChangeNotify *)_r;
+                       r->out.result = _eventlog_ChangeNotify(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
+               case NDR_EVENTLOG_OPENEVENTLOGW: {
+                       struct eventlog_OpenEventLogW *r = (struct eventlog_OpenEventLogW *)_r;
+                       ZERO_STRUCT(r->out);
+                       r->out.handle = talloc_zero(mem_ctx, struct policy_handle);
+                       if (r->out.handle == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+                       }
+
+                       r->out.result = _eventlog_OpenEventLogW(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
+               case NDR_EVENTLOG_REGISTEREVENTSOURCEW: {
+                       struct eventlog_RegisterEventSourceW *r = (struct eventlog_RegisterEventSourceW *)_r;
+                       ZERO_STRUCT(r->out);
+                       r->out.log_handle = talloc_zero(mem_ctx, struct policy_handle);
+                       if (r->out.log_handle == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+                       }
+
+                       r->out.result = _eventlog_RegisterEventSourceW(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
+               case NDR_EVENTLOG_OPENBACKUPEVENTLOGW: {
+                       struct eventlog_OpenBackupEventLogW *r = (struct eventlog_OpenBackupEventLogW *)_r;
+                       ZERO_STRUCT(r->out);
+                       r->out.handle = talloc_zero(mem_ctx, struct policy_handle);
+                       if (r->out.handle == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+                       }
+
+                       r->out.result = _eventlog_OpenBackupEventLogW(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
+               case NDR_EVENTLOG_READEVENTLOGW: {
+                       struct eventlog_ReadEventLogW *r = (struct eventlog_ReadEventLogW *)_r;
+                       ZERO_STRUCT(r->out);
+                       r->out.data = talloc_zero_array(mem_ctx, uint8_t, r->in.number_of_bytes);
+                       if (r->out.data == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+                       }
+
+                       r->out.sent_size = talloc_zero(mem_ctx, uint32_t);
+                       if (r->out.sent_size == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+                       }
+
+                       r->out.real_size = talloc_zero(mem_ctx, uint32_t);
+                       if (r->out.real_size == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+                       }
+
+                       r->out.result = _eventlog_ReadEventLogW(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
+               case NDR_EVENTLOG_REPORTEVENTW: {
+                       struct eventlog_ReportEventW *r = (struct eventlog_ReportEventW *)_r;
+                       ZERO_STRUCT(r->out);
+                       r->out.record_number = r->in.record_number;
+                       r->out.time_written = r->in.time_written;
+                       r->out.result = _eventlog_ReportEventW(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
+               case NDR_EVENTLOG_CLEAREVENTLOGA: {
+                       struct eventlog_ClearEventLogA *r = (struct eventlog_ClearEventLogA *)_r;
+                       r->out.result = _eventlog_ClearEventLogA(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
+               case NDR_EVENTLOG_BACKUPEVENTLOGA: {
+                       struct eventlog_BackupEventLogA *r = (struct eventlog_BackupEventLogA *)_r;
+                       r->out.result = _eventlog_BackupEventLogA(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
+               case NDR_EVENTLOG_OPENEVENTLOGA: {
+                       struct eventlog_OpenEventLogA *r = (struct eventlog_OpenEventLogA *)_r;
+                       r->out.result = _eventlog_OpenEventLogA(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
+               case NDR_EVENTLOG_REGISTEREVENTSOURCEA: {
+                       struct eventlog_RegisterEventSourceA *r = (struct eventlog_RegisterEventSourceA *)_r;
+                       r->out.result = _eventlog_RegisterEventSourceA(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
+               case NDR_EVENTLOG_OPENBACKUPEVENTLOGA: {
+                       struct eventlog_OpenBackupEventLogA *r = (struct eventlog_OpenBackupEventLogA *)_r;
+                       r->out.result = _eventlog_OpenBackupEventLogA(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
+               case NDR_EVENTLOG_READEVENTLOGA: {
+                       struct eventlog_ReadEventLogA *r = (struct eventlog_ReadEventLogA *)_r;
+                       r->out.result = _eventlog_ReadEventLogA(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
+               case NDR_EVENTLOG_REPORTEVENTA: {
+                       struct eventlog_ReportEventA *r = (struct eventlog_ReportEventA *)_r;
+                       r->out.result = _eventlog_ReportEventA(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
+               case NDR_EVENTLOG_REGISTERCLUSTERSVC: {
+                       struct eventlog_RegisterClusterSvc *r = (struct eventlog_RegisterClusterSvc *)_r;
+                       r->out.result = _eventlog_RegisterClusterSvc(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
+               case NDR_EVENTLOG_DEREGISTERCLUSTERSVC: {
+                       struct eventlog_DeregisterClusterSvc *r = (struct eventlog_DeregisterClusterSvc *)_r;
+                       r->out.result = _eventlog_DeregisterClusterSvc(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
+               case NDR_EVENTLOG_WRITECLUSTEREVENTS: {
+                       struct eventlog_WriteClusterEvents *r = (struct eventlog_WriteClusterEvents *)_r;
+                       r->out.result = _eventlog_WriteClusterEvents(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
+               case NDR_EVENTLOG_GETLOGINFORMATION: {
+                       struct eventlog_GetLogInformation *r = (struct eventlog_GetLogInformation *)_r;
+                       ZERO_STRUCT(r->out);
+                       r->out.buffer = talloc_zero_array(mem_ctx, uint8_t, r->in.buf_size);
+                       if (r->out.buffer == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+                       }
+
+                       r->out.bytes_needed = talloc_zero(mem_ctx, uint32_t);
+                       if (r->out.bytes_needed == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+                       }
+
+                       r->out.result = _eventlog_GetLogInformation(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
+               case NDR_EVENTLOG_FLUSHEVENTLOG: {
+                       struct eventlog_FlushEventLog *r = (struct eventlog_FlushEventLog *)_r;
+                       r->out.result = _eventlog_FlushEventLog(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
+               case NDR_EVENTLOG_REPORTEVENTANDSOURCEW: {
+                       struct eventlog_ReportEventAndSourceW *r = (struct eventlog_ReportEventAndSourceW *)_r;
+                       ZERO_STRUCT(r->out);
+                       r->out.record_number = r->in.record_number;
+                       r->out.time_written = r->in.time_written;
+                       r->out.result = _eventlog_ReportEventAndSourceW(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
+               default:
+                       return NT_STATUS_NOT_IMPLEMENTED;
+       }
+}
+
 NTSTATUS rpc_eventlog_init(void)
 {
-       return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "eventlog", "eventlog", &ndr_table_eventlog.syntax_id, api_eventlog_cmds, sizeof(api_eventlog_cmds) / sizeof(struct api_struct));
+       return rpc_srv_register(SMB_RPC_INTERFACE_VERSION, "eventlog", "eventlog", &ndr_table_eventlog, api_eventlog_cmds, sizeof(api_eventlog_cmds) / sizeof(struct api_struct));
 }