testprogs: print secdesc->Control in spoolss test.
[ira/wip.git] / testprogs / win32 / spoolss / printlib.c
index 0790144db1d84e0339dbfc4cb6eb4c2da512fa7e..b9198d46afb206168453a91766f61c4f35bb6050 100644 (file)
@@ -22,6 +22,7 @@
 #include <windows.h>
 #include <stdio.h>
 #include <assert.h>
+#include <sddl.h>
 
 void print_devmode(DEVMODE *pDevModeIn)
 {
@@ -125,24 +126,27 @@ void print_acl(const char* str, ACL *acl)
        return;
 }
 
-void print_sid(const char* str, SID *sid)
+void PrintLastError();
+
+void print_sid(LPSTR str, PSID sid)
 {
-       DWORD   i = 0;
+       LPSTR sid_string;
 
        printf("%s\n", str);
-       printf("0x%x\n", sid);
-       if (sid == NULL)
+
+       if (sid == NULL) {
+               printf("(null sid)\n");
+               return;
+       }
+
+       if (!ConvertSidToStringSid(sid, &sid_string)) {
+               PrintLastError();
                return;
-       printf("\t\tRevision\t\t0x%x\n", sid->Revision);
-       printf("\t\tSubAuthorityCount\t0x%x\n", sid->SubAuthorityCount);
-       printf("\t\tSubAuthority\n\t");
-       while (i < sid->SubAuthorityCount) {
-               printf("\t0x%x", sid->SubAuthority[i]);
-               if (i%4 == 3)
-                       printf("\n\t");
-               i++;
        }
 
+       printf("%s\n", sid_string);
+       LocalFree(sid_string);
+
        return;
 }
 
@@ -155,6 +159,7 @@ void print_secdesc(SECURITY_DESCRIPTOR *secdesc)
 
        printf("\tRevision\t= 0x%x\n", secdesc->Revision);
        printf("\tSbz1\t\t= 0x%x\n", secdesc->Sbz1);
+       printf("\tControl\t\t= 0x%x\n", secdesc->Control);
 #if 0
        print_sid("\tOwner\t\t= ", secdesc->Owner);
        print_sid("\tGroup\t\t= ",secdesc->Group);
@@ -248,6 +253,103 @@ void print_job_info_3(PJOB_INFO_3 info)
        return;
 }
 
+void print_job_info_4(PJOB_INFO_4 info)
+{
+       printf("\tJob ID\t\t= %d\n",            info->JobId);
+       printf("\tPrinter Name\t= %s\n",        info->pPrinterName);
+       printf("\tMachine Name\t= %s\n",        info->pMachineName);
+       printf("\tUser Name\t= %s\n",           info->pUserName);
+       printf("\tDocument\t= %s\n",            info->pDocument);
+       printf("\tDatatype\t= %s\n",            info->pDatatype);
+       printf("\tNotify Name\t= %s\n",         info->pNotifyName);
+       printf("\tPrint Processor\t= %s\n",     info->pPrintProcessor);
+       printf("\tDriver Name\t= %s\n",         info->pDriverName);
+       printf("\tStatus\t\t= %s\n",            info->pStatus);
+       printf("\tStatus\t\t= %d\n",            info->Status);
+       printf("\tPriority\t= %d\n",            info->Priority);
+       printf("\tPosition\t= %d\n",            info->Position);
+       printf("\tTotal Pages\t= %d\n",         info->TotalPages);
+       printf("\tPages Printed\t= %d\n",       info->PagesPrinted);
+       printf("\tStart Time\t= %d\n",          info->StartTime);
+       printf("\tUntil Time\t= %d\n",          info->UntilTime);
+       printf("\tTime\t\t= %d\n",              info->Time);
+       printf("\tSize\t\t= %d\n",              info->Size);
+       printf("\tSize High\t\t= 0x%016x\n",    info->SizeHigh);
+       printf("\tSubmitted (DD:MM:YY HH:MM:SS)\t= %d:%d:%d %d:%d:%d UTC\n",
+               info->Submitted.wDay, info->Submitted.wMonth,
+               info->Submitted.wYear, info->Submitted.wHour,
+               info->Submitted.wMinute, info->Submitted.wSecond);
+       printf("\tDevice Mode Information\n");
+       printf("\t-----------------------\n");
+       print_devmode(info->pDevMode);
+       printf("\tSecurity Descriptor Information\n");
+       printf("\t-------------------------------\n");
+       print_secdesc(info->pSecurityDescriptor);
+
+       return;
+}
+
+void print_job_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
+{
+       DWORD i;
+       PJOB_INFO_1     buffer1 = NULL;
+       PJOB_INFO_2     buffer2 = NULL;
+       PJOB_INFO_3     buffer3 = NULL;
+       PJOB_INFO_4     buffer4 = NULL;
+
+       if (!buffer) {
+               return;
+       }
+
+       switch (level) {
+       case 1:
+               buffer1 = (PJOB_INFO_1)buffer;
+               break;
+       case 2:
+               buffer2 = (PJOB_INFO_2)buffer;
+               break;
+       case 3:
+               buffer3 = (PJOB_INFO_3)buffer;
+               break;
+       case 4:
+               buffer4 = (PJOB_INFO_4)buffer;
+               break;
+       default:
+               break;
+       }
+
+       printf("Job Info Level %d:\n", level);
+
+       switch (level) {
+       case 1:
+               for (i=0; i<count; i++) {
+                       print_job_info_1(&buffer1[i]);
+                       printf("\n");
+               }
+               break;
+       case 2:
+               for (i=0; i<count; i++) {
+                       print_job_info_2(&buffer2[i]);
+                       printf("\n");
+               }
+               break;
+       case 3:
+               for (i=0; i<count; i++) {
+                       print_job_info_3(&buffer3[i]);
+                       printf("\n");
+               }
+               break;
+       case 4:
+               for (i=0; i<count; i++) {
+                       print_job_info_4(&buffer4[i]);
+                       printf("\n");
+               }
+               break;
+       default:
+               break;
+       }
+}
+
 void print_monitor_info_1(PMONITOR_INFO_1 info)
 {
        printf("\tMonitor Name\t= %s\n",        info->pName);
@@ -264,6 +366,47 @@ void print_monitor_info_2(PMONITOR_INFO_2 info)
        return;
 }
 
+void print_monitor_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
+{
+       DWORD i;
+       PMONITOR_INFO_1 buffer1 = NULL;
+       PMONITOR_INFO_2 buffer2 = NULL;
+
+       if (!buffer) {
+               return;
+       }
+
+       switch (level) {
+       case 1:
+               buffer1 = (PMONITOR_INFO_1)buffer;
+               break;
+       case 2:
+               buffer2 = (PMONITOR_INFO_2)buffer;
+               break;
+       default:
+               break;
+       }
+
+       printf("Monitor Info Level %d:\n", level);
+
+       switch (level) {
+       case 1:
+               for (i=0; i<count; i++) {
+                       print_monitor_info_1(&buffer1[i]);
+                       printf("\n");
+               }
+               break;
+       case 2:
+               for (i=0; i<count; i++) {
+                       print_monitor_info_2(&buffer2[i]);
+                       printf("\n");
+               }
+               break;
+       default:
+               break;
+       }
+}
+
 void print_port_info_1(PPORT_INFO_1 info)
 {
        printf("\tPort Name\t= %s\n",   info->pName);
@@ -445,11 +588,9 @@ void print_printer_info_2(PPRINTER_INFO_2 info)
        printf("\tDevice Mode Information\n");
        printf("\t-----------------------\n");
        print_devmode(info->pDevMode);
-#if 0
        printf("\tSecurity Descriptor Information\n");
        printf("\t-------------------------------\n");
        print_secdesc(info->pSecurityDescriptor);
-#endif
        return;
 }
 
@@ -596,6 +737,75 @@ void print_printprocessor_info_1(PPRINTPROCESSOR_INFO_1 info)
        return;
 }
 
+void print_printprocessor_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
+{
+       DWORD i;
+       PPRINTPROCESSOR_INFO_1 buffer1 = NULL;
+
+       if (!buffer) {
+               return;
+       }
+
+       switch (level) {
+       case 1:
+               buffer1 = (PPRINTPROCESSOR_INFO_1)buffer;
+               break;
+       default:
+               break;
+       }
+
+       printf("Print Processor Info Level %d:\n", level);
+
+       switch (level) {
+       case 1:
+               for (i=0; i<count; i++) {
+                       print_printprocessor_info_1(&buffer1[i]);
+                       printf("\n");
+               }
+               break;
+       default:
+               break;
+       }
+}
+
+void print_datatypes_info_1(PDATATYPES_INFO_1 info)
+{
+       printf("\tDataTypes Name\t= %s\n", info->pName);
+
+       return;
+}
+
+void print_datatypes_info_bylevel(DWORD level, LPBYTE buffer, DWORD count)
+{
+       DWORD i;
+       PDATATYPES_INFO_1 buffer1 = NULL;
+
+       if (!buffer) {
+               return;
+       }
+
+       switch (level) {
+       case 1:
+               buffer1 = (PDATATYPES_INFO_1)buffer;
+               break;
+       default:
+               break;
+       }
+
+       printf("DataTypes Info Level %d:\n", level);
+
+       switch (level) {
+       case 1:
+               for (i=0; i<count; i++) {
+                       print_datatypes_info_1(&buffer1[i]);
+                       printf("\n");
+               }
+               break;
+       default:
+               break;
+       }
+}
+
 void print_driver_info_1(PDRIVER_INFO_1 info)
 {
        printf("\tDriver Name\t= %s\n\n",       info->pName);