static int RemoveLast() { SrvJob *job; int status; LockQueue(); job = LastQueueEntry; if (job) { LastQueueEntry = job->h.previous; if(LastQueueEntry) LastQueueEntry->h.next = 0; else FirstQueueEntry = 0; FreeJob(job); printf("Removed pending action"); status = 1; } else { status = 0; } UnlockQueue(); return status; }
static void AbortJob(SrvJob *job) { if (job) { SendReply(job,SrvJobFINISHED,ServerABORT,0,0); FreeJob(job); } }
static void *Worker(void *arg) { SrvJob *job; pthread_cleanup_push(ThreadCleanup,0); WorkerThreadRunning = 1; ProgLoc = 1; while (job = NextJob(1)) { char *save_text; ProgLoc = 2; ServerSetDetailProc(0); ProgLoc = 3; SetCurrentJob(job); ProgLoc = 4; if ((job->h.flags & SrvJobBEFORE_NOTIFY) != 0) { ProgLoc = 5; SendReply(job,SrvJobSTARTING,1,0,0); } ProgLoc = 6; switch (job->h.op) { case SrvAction: DoSrvAction(job); break; case SrvClose: DoSrvClose(job); break; case SrvCreatePulse: DoSrvCreatePulse(job); break; case SrvCommand: DoSrvCommand(job); break; case SrvMonitor: DoSrvMonitor(job); break; } ProgLoc = 7; SetCurrentJob(0); ProgLoc = 8; FreeJob(job); ProgLoc = 9; save_text = current_job_text; current_job_text = 0; if (save_text) free(save_text); ProgLoc = 10; } LeftWorkerLoop++; pthread_cleanup_pop(1); return 0; }
BOOL WINAPI LocalSetJob(HANDLE hPrinter, DWORD JobId, DWORD Level, PBYTE pJobInfo, DWORD Command) { DWORD dwErrorCode; PLOCAL_HANDLE pHandle; PLOCAL_JOB pJob; PLOCAL_PRINTER_HANDLE pPrinterHandle; WCHAR wszFullPath[MAX_PATH]; // Check if this is a printer handle. pHandle = (PLOCAL_HANDLE)hPrinter; if (pHandle->HandleType != HandleType_Printer) { dwErrorCode = ERROR_INVALID_HANDLE; goto Cleanup; } pPrinterHandle = (PLOCAL_PRINTER_HANDLE)pHandle->pSpecificHandle; // Get the desired job. pJob = LookupElementSkiplist(&GlobalJobList, &JobId, NULL); if (!pJob || pJob->pPrinter != pPrinterHandle->pPrinter) { dwErrorCode = ERROR_INVALID_PARAMETER; goto Cleanup; } // Setting job information is handled differently for each level. if (Level) { if (Level == 1) dwErrorCode = _LocalSetJobLevel1(pPrinterHandle, pJob, (PJOB_INFO_1W)pJobInfo); else if (Level == 2) dwErrorCode = _LocalSetJobLevel2(pPrinterHandle, pJob, (PJOB_INFO_2W)pJobInfo); else dwErrorCode = ERROR_INVALID_LEVEL; } if (dwErrorCode != ERROR_SUCCESS) goto Cleanup; // If we do spooled printing, the job information is written down into a shadow file. if (!(pPrinterHandle->pPrinter->dwAttributes & PRINTER_ATTRIBUTE_DIRECT)) { // Write the job data into the shadow file. GetJobFilePath(L"SHD", JobId, wszFullPath); WriteJobShadowFile(wszFullPath, pJob); } // Perform an additional command if desired. if (Command) { if (Command == JOB_CONTROL_SENT_TO_PRINTER) { // This indicates the end of the Print Job. // Cancel the Job at the Print Processor. if (pJob->hPrintProcessor) pJob->pPrintProcessor->pfnControlPrintProcessor(pJob->hPrintProcessor, JOB_CONTROL_CANCEL); FreeJob(pJob); // TODO: All open handles associated with the job need to be invalidated. // This certainly needs handle tracking... } else { ERR("Unimplemented SetJob Command: %lu!\n", Command); } } dwErrorCode = ERROR_SUCCESS; Cleanup: SetLastError(dwErrorCode); return (dwErrorCode == ERROR_SUCCESS); }