⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 print_iprint.c

📁 samba-3.0.22.tar.gz 编译smb服务器的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
	if (http)		httpClose(http);	return ret;}/* * 'iprint_job_delete()' - Delete a job. */static int iprint_job_delete(const char *sharename, const char *lprm_command, struct printjob *pjob){	int		ret = 1;		/* Return value */	http_t		*http = NULL;		/* HTTP connection to server */	ipp_t		*request = NULL,	/* IPP Request */			*response = NULL;	/* IPP Response */	cups_lang_t	*language = NULL;	/* Default language */	char		uri[HTTP_MAX_URI];	/* printer-uri attribute */	char		httpPath[HTTP_MAX_URI];	/* path portion of the printer-uri */	DEBUG(5,("iprint_job_delete(%s, %p (%d))\n", sharename, pjob, pjob->sysjob));       /*	* Make sure we don't ask for passwords...	*/	cupsSetPasswordCB(iprint_passwd_cb);       /*	* Try to connect to the server...	*/	if ((http = httpConnect(iprint_server(), ippPort())) == NULL) {		DEBUG(0,("Unable to connect to iPrint server %s - %s\n", 			 iprint_server(), strerror(errno)));		goto out;	}       /*	* Build an IPP_CANCEL_JOB request, which uses the following	* attributes:	*	*    attributes-charset	*    attributes-natural-language	*    printer-uri	*    job-id	*    requesting-user-name	*/	request = ippNew();	request->request.op.operation_id = IPP_CANCEL_JOB;	request->request.op.request_id   = 1;	language = cupsLangDefault();	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,	             "attributes-charset", NULL, "utf-8");	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,	             "attributes-natural-language", NULL, language->language);	slprintf(uri, sizeof(uri) - 1, "ipp://%s/ipp/%s", iprint_server(), sharename);	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri);	ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id", pjob->sysjob);	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",	             NULL, pjob->user);       /*	* Do the request and get back a response...	*/	slprintf(httpPath, sizeof(httpPath) - 1, "/ipp/%s", sharename);	if ((response = cupsDoRequest(http, request, httpPath)) != NULL) {		if (response->request.status.status_code >= IPP_OK_CONFLICT) {			DEBUG(0,("Unable to cancel job %d - %s\n", pjob->sysjob,				ippErrorString(cupsLastError())));		} else {			ret = 0;		}	} else {		DEBUG(0,("Unable to cancel job %d - %s\n", pjob->sysjob,			ippErrorString(cupsLastError())));	} out:	if (response)		ippDelete(response);	if (language)		cupsLangFree(language);	if (http)		httpClose(http);	return ret;}/* * 'iprint_job_pause()' - Pause a job. */static int iprint_job_pause(int snum, struct printjob *pjob){	int		ret = 1;		/* Return value */	http_t		*http = NULL;		/* HTTP connection to server */	ipp_t		*request = NULL,	/* IPP Request */			*response = NULL;	/* IPP Response */	cups_lang_t	*language = NULL;	/* Default language */	char		uri[HTTP_MAX_URI];	/* printer-uri attribute */	char		httpPath[HTTP_MAX_URI];	/* path portion of the printer-uri */	DEBUG(5,("iprint_job_pause(%d, %p (%d))\n", snum, pjob, pjob->sysjob));       /*	* Make sure we don't ask for passwords...	*/	cupsSetPasswordCB(iprint_passwd_cb);       /*	* Try to connect to the server...	*/	if ((http = httpConnect(iprint_server(), ippPort())) == NULL) {		DEBUG(0,("Unable to connect to iPrint server %s - %s\n", 			 iprint_server(), strerror(errno)));		goto out;	}       /*	* Build an IPP_HOLD_JOB request, which requires the following	* attributes:	*	*    attributes-charset	*    attributes-natural-language	*    printer-uri	*    job-id	*    requesting-user-name	*/	request = ippNew();	request->request.op.operation_id = IPP_HOLD_JOB;	request->request.op.request_id   = 1;	language = cupsLangDefault();	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,	             "attributes-charset", NULL, "utf-8");	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,	             "attributes-natural-language", NULL, language->language);	slprintf(uri, sizeof(uri) - 1, "ipp://%s/ipp/%s", iprint_server(), PRINTERNAME(snum));	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri);	ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id", pjob->sysjob);	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",	             NULL, pjob->user);       /*	* Do the request and get back a response...	*/	slprintf(httpPath, sizeof(httpPath) - 1, "/ipp/%s", PRINTERNAME(snum));	if ((response = cupsDoRequest(http, request, httpPath)) != NULL) {		if (response->request.status.status_code >= IPP_OK_CONFLICT) {			DEBUG(0,("Unable to hold job %d - %s\n", pjob->sysjob,				ippErrorString(cupsLastError())));		} else {			ret = 0;		}	} else {		DEBUG(0,("Unable to hold job %d - %s\n", pjob->sysjob,			ippErrorString(cupsLastError())));	} out:	if (response)		ippDelete(response);	if (language)		cupsLangFree(language);	if (http)		httpClose(http);	return ret;}/* * 'iprint_job_resume()' - Resume a paused job. */static int iprint_job_resume(int snum, struct printjob *pjob){	int		ret = 1;		/* Return value */	http_t		*http = NULL;		/* HTTP connection to server */	ipp_t		*request = NULL,	/* IPP Request */			*response = NULL;	/* IPP Response */	cups_lang_t	*language = NULL;	/* Default language */	char		uri[HTTP_MAX_URI];	/* printer-uri attribute */	char		httpPath[HTTP_MAX_URI];	/* path portion of the printer-uri */	DEBUG(5,("iprint_job_resume(%d, %p (%d))\n", snum, pjob, pjob->sysjob));       /*	* Make sure we don't ask for passwords...	*/	cupsSetPasswordCB(iprint_passwd_cb);       /*	* Try to connect to the server...	*/	if ((http = httpConnect(iprint_server(), ippPort())) == NULL) {		DEBUG(0,("Unable to connect to iPrint server %s - %s\n", 			 iprint_server(), strerror(errno)));		goto out;	}       /*	* Build an IPP_RELEASE_JOB request, which requires the following	* attributes:	*	*    attributes-charset	*    attributes-natural-language	*    printer-uri	*    job-id	*    requesting-user-name	*/	request = ippNew();	request->request.op.operation_id = IPP_RELEASE_JOB;	request->request.op.request_id   = 1;	language = cupsLangDefault();	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,	             "attributes-charset", NULL, "utf-8");	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,	             "attributes-natural-language", NULL, language->language);	slprintf(uri, sizeof(uri) - 1, "ipp://%s/ipp/%s", iprint_server(), PRINTERNAME(snum));	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri);	ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id", pjob->sysjob);	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",	             NULL, pjob->user);       /*	* Do the request and get back a response...	*/	slprintf(httpPath, sizeof(httpPath) - 1, "/ipp/%s", PRINTERNAME(snum));	if ((response = cupsDoRequest(http, request, httpPath)) != NULL) {		if (response->request.status.status_code >= IPP_OK_CONFLICT) {			DEBUG(0,("Unable to release job %d - %s\n", pjob->sysjob,				ippErrorString(cupsLastError())));		} else {			ret = 0;		}	} else {		DEBUG(0,("Unable to release job %d - %s\n", pjob->sysjob,			ippErrorString(cupsLastError())));	} out:	if (response)		ippDelete(response);	if (language)		cupsLangFree(language);	if (http)		httpClose(http);	return ret;}/* * 'iprint_job_submit()' - Submit a job for printing. */static int iprint_job_submit(int snum, struct printjob *pjob){	int		ret = 1;		/* Return value */	http_t		*http = NULL;		/* HTTP connection to server */	ipp_t		*request = NULL,	/* IPP Request */			*response = NULL;	/* IPP Response */	ipp_attribute_t	*attr;		/* Current attribute */	cups_lang_t	*language = NULL;	/* Default language */	char		uri[HTTP_MAX_URI]; /* printer-uri attribute */	char 		*clientname = NULL; 	/* hostname of client for job-originating-host attribute */	DEBUG(5,("iprint_job_submit(%d, %p (%d))\n", snum, pjob, pjob->sysjob));       /*	* Make sure we don't ask for passwords...	*/	cupsSetPasswordCB(iprint_passwd_cb);       /*	* Try to connect to the server...	*/	if ((http = httpConnect(iprint_server(), ippPort())) == NULL) {		DEBUG(0,("Unable to connect to iPrint server %s - %s\n", 			 iprint_server(), strerror(errno)));		goto out;	}       /*	* Build an IPP_PRINT_JOB request, which requires the following	* attributes:	*	*    attributes-charset	*    attributes-natural-language	*    printer-uri	*    requesting-user-name	*    [document-data]	*/	request = ippNew();	request->request.op.operation_id = IPP_PRINT_JOB;	request->request.op.request_id   = 1;	language = cupsLangDefault();	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,	             "attributes-charset", NULL, "utf-8");	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,	             "attributes-natural-language", NULL, language->language);	slprintf(uri, sizeof(uri) - 1, "ipp://%s/ipp/%s", iprint_server(), PRINTERNAME(snum));	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,	             "printer-uri", NULL, uri);	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",	             NULL, pjob->user);	clientname = client_name();	if (strcmp(clientname, "UNKNOWN") == 0) {		clientname = client_addr();	}	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,	             "job-originating-host-name", NULL,	             clientname);	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "job-name", NULL,	             pjob->jobname);       /*	* Do the request and get back a response...	*/	slprintf(uri, sizeof(uri) - 1, "/ipp/%s", PRINTERNAME(snum));	if ((response = cupsDoFileRequest(http, request, uri, pjob->filename)) != NULL) {		if (response->request.status.status_code >= IPP_OK_CONFLICT) {			DEBUG(0,("Unable to print file to %s - %s\n", PRINTERNAME(snum),			         ippErrorString(cupsLastError())));		} else {			ret = 0;		}	} else {		DEBUG(0,("Unable to print file to `%s' - %s\n", PRINTERNAME(snum),			 ippErrorString(cupsLastError())));	}	if ( ret == 0 )		unlink(pjob->filename);	/* else print_job_end will do it for us */	if ( ret == 0 ) {		attr = ippFindAttribute(response, "job-id", IPP_TAG_INTEGER);		if (attr != NULL && attr->group_tag == IPP_TAG_JOB)		{			pjob->sysjob = attr->values[0].integer;		}	} out:	if (response)		ippDelete(response);	if (language)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -