Exemplo n.º 1
0
papi_status_t
ipp_cancel_job(papi_service_t svc, papi_attribute_t **request,
		papi_attribute_t ***response)
{
	papi_status_t status;
	papi_attribute_t **operational = NULL;

	char *message = NULL;
	char *queue = NULL;
	int id = -1;

	/* Get operational attributes from the request */
	(void) papiAttributeListGetCollection(request, NULL,
				"operational-attributes-group", &operational);

	/*
	 * the operational-attributes-group must contain:
	 *	job-uri (or printer-uri/job-id)
	 */
	get_printer_id(operational, &queue, &id);
	if (id < 0) {
		ipp_set_status(response, PAPI_BAD_REQUEST,
				"missing job-uri or job-id");
		return (PAPI_BAD_REQUEST);
	} else if (queue == NULL) {
		ipp_set_status(response, PAPI_BAD_REQUEST,
				"missing printer-uri or job-uri");
		return (PAPI_BAD_REQUEST);
	}

	/*
	 * the operational-attributes-group may contain:
	 *	message
	 */
	(void) papiAttributeListGetString(operational, NULL,
				"message", &message);

	status = papiJobCancel(svc, queue, id);
	if (status != PAPI_OK) {
		ipp_set_status(response, status,
				"cancel failed: %s-%d: %s",
				(queue ? queue : "(null)"), id,
				ipp_svc_status_mesg(svc, status));
	} else if (message != NULL) {	/* add unsupported attribute group */
		papi_attribute_t **unsupported = NULL;

		papiAttributeListAddValue(&unsupported, PAPI_ATTR_EXCL,
					"message", PAPI_COLLECTION, NULL);
		(void) papiAttributeListAddCollection(response,
			PAPI_ATTR_REPLACE, "unsupported-attributes-group",
			unsupported);
		papiAttributeListFree(unsupported);

		status = PAPI_OK_SUBST;
		ipp_set_status(response, status,
			"unsupported attribute in request");
	}

	return (status);
}
Exemplo n.º 2
0
papi_status_t
papiAttributeListAddBoolean(papi_attribute_t ***list, int flags,
			char *name, char boolean)
{
	papi_attribute_value_t v;

	v.boolean = boolean;
	return (papiAttributeListAddValue(list, flags, name, PAPI_BOOLEAN, &v));
}
Exemplo n.º 3
0
papi_status_t
papiAttributeListAddInteger(papi_attribute_t ***list, int flags,
			char *name, int integer)
{
	papi_attribute_value_t v;

	v.integer = integer;
	return (papiAttributeListAddValue(list, flags, name, PAPI_INTEGER, &v));
}
Exemplo n.º 4
0
papi_status_t
papiAttributeListAddString(papi_attribute_t ***list, int flags,
			char *name, char *string)
{
	papi_attribute_value_t v;

	v.string = (char *)string;
	return (papiAttributeListAddValue(list, flags, name, PAPI_STRING, &v));
}
Exemplo n.º 5
0
papi_status_t
papiAttributeListAddMetadata(papi_attribute_t ***list, int flags,
			char *name, papi_metadata_t metadata)
{
	papi_attribute_value_t v;

	v.metadata = metadata;
	return (papiAttributeListAddValue(list, flags, name,
				PAPI_METADATA, &v));
}
Exemplo n.º 6
0
papi_status_t
papiAttributeListAddCollection(papi_attribute_t ***list, int flags,
			char *name, papi_attribute_t **collection)
{
	papi_attribute_value_t v;

	v.collection = (papi_attribute_t **)collection;
	return (papiAttributeListAddValue(list, flags, name,
				PAPI_COLLECTION, &v));
}
Exemplo n.º 7
0
papi_status_t
papiAttributeListAddDatetime(papi_attribute_t ***list, int flags,
			char *name, time_t datetime)
{
	papi_attribute_value_t v;

	v.datetime = datetime;
	return (papiAttributeListAddValue(list, flags, name,
				PAPI_DATETIME, &v));
}
Exemplo n.º 8
0
papi_status_t
papiAttributeListAddRange(papi_attribute_t ***list, int flags,
			char *name, int lower, int upper)
{
	papi_attribute_value_t v;

	v.range.lower = lower;
	v.range.upper = upper;
	return (papiAttributeListAddValue(list, flags, name, PAPI_RANGE, &v));
}
Exemplo n.º 9
0
static papi_status_t
copy_attribute(papi_attribute_t ***list, papi_attribute_t *attribute)
{
	papi_status_t status;
	int i = 0;

	if ((list == NULL) || (attribute == NULL) ||
	    (attribute->values == NULL))
		return (PAPI_BAD_ARGUMENT);

	for (status = papiAttributeListAddValue(list, PAPI_ATTR_EXCL,
					attribute->name, attribute->type,
					attribute->values[i]);
	     ((status == PAPI_OK) && (attribute->values[i] != NULL));
	     status = papiAttributeListAddValue(list, PAPI_ATTR_APPEND,
					attribute->name, attribute->type,
					attribute->values[i]))
		i++;

	return (status);
}
Exemplo n.º 10
0
papi_status_t
papiAttributeListAddResolution(papi_attribute_t ***list, int flags,
			char *name, int xres, int yres,
			papi_resolution_unit_t units)
{
	papi_attribute_value_t v;

	v.resolution.xres = xres;
	v.resolution.yres = yres;
	v.resolution.units = units;
	return (papiAttributeListAddValue(list, flags, name,
				PAPI_RESOLUTION, &v));
}
Exemplo n.º 11
0
papi_status_t
papiAttributeListFromString(papi_attribute_t ***attrs,
		int flags, char *string)
{
	papi_status_t result = PAPI_OK;
	int	   next = 0;
	char	 *attrString = NULL;
	papi_attribute_t attr;

	if ((attrs != NULL) && (string != NULL) &&
	    ((flags & ~(PAPI_ATTR_APPEND+PAPI_ATTR_REPLACE+PAPI_ATTR_EXCL))
			== 0)) {
		attrString = _getNextAttr(string, &next);
		while ((result == PAPI_OK) && (attrString != NULL)) {
			result = _parseAttributeString(attrString, &attr);
			if ((result == PAPI_OK) && (attr.name != NULL)) {
				/* add this attribute to the list */
				if ((attr.values != NULL) &&
				    (attr.values[0] != NULL)) {
					result = papiAttributeListAddValue(
							attrs, PAPI_ATTR_APPEND,
							attr.name, attr.type,
							attr.values[0]);
					free(attr.values[0]);
					free(attr.values);
				} else {
					result = PAPI_TEMPORARY_ERROR;
				}
			}
			free(attrString);

			attrString = _getNextAttr(string, &next);
		}
	}
	else
	{
		result = PAPI_BAD_ARGUMENT;
	}

	return (result);
}
Exemplo n.º 12
0
/*
 * for an older application that may have been linked with a pre-v1.0
 * PAPI implementation.
 */
papi_status_t
papiAttributeListAdd(papi_attribute_t ***attrs, int flags, char *name,
		papi_attribute_value_type_t type, papi_attribute_value_t *value)
{
	return (papiAttributeListAddValue(attrs, flags, name, type, value));
}
Exemplo n.º 13
0
static papi_status_t
psm_modifyAttrsList(char *file, papi_attribute_t **attrs,
    papi_attribute_t ***newAttrs)

{
	papi_status_t result = PAPI_OK;
	papi_attribute_t  *nextAttr = NULL;
	papi_attribute_value_t  **values = NULL;
	void *iter = NULL;
	FILE *fd = NULL;
	register int fD = 0;
	char aBuff[200];
	char *a = NULL;
	char *p = NULL;
	int count = 0;
	int n = 0;

	fd = fopen(file, "r");
	if (fd != NULL) {
		fD = fileno(fd);
		a = &aBuff[0];
		p = &aBuff[0];
		count = read(fD, &aBuff[0], sizeof (aBuff) - 1);
		while ((result == PAPI_OK) && (count > 0)) {
			aBuff[count+n] = '\0';
			if (count == sizeof (aBuff) - n - 1) {
				p = strrchr(aBuff, '\n');
				if (p != NULL) {
					/* terminate at last complete line */
					*p = '\0';
				}
			}
			result = papiAttributeListFromString(
				newAttrs, PAPI_ATTR_EXCL, aBuff);

			if (result == PAPI_OK) {
				/*
				 * handle any part lines and then read the next
				 * buffer from the file
				 */
				n = 0;
				if (p != a) {
					p++; /* skip NL */
					n = sizeof (aBuff) - 1 - (p - a);
					strncpy(aBuff, p, n);
				}
				count = read(fD, &aBuff[n],
					sizeof (aBuff) - n - 1);
				p = &aBuff[0];
			}
		}
		fclose(fd);
	}

	/* now modify the attribute list with the new attributes in 'attrs' */

	nextAttr = papiAttributeListGetNext((papi_attribute_t **)attrs, &iter);
	while ((result == PAPI_OK) && (nextAttr != NULL)) {
		values = nextAttr->values;

		if ((values != NULL) && (*values != NULL)) {
			result = papiAttributeListAddValue(newAttrs,
						    PAPI_ATTR_REPLACE,
						    nextAttr->name,
						    nextAttr->type, *values);
			values++;
		}

		while ((result == PAPI_OK) &&
			(values != NULL) && (*values != NULL)) {
			result = papiAttributeListAddValue(newAttrs,
						    PAPI_ATTR_APPEND,
						    nextAttr->name,
						    nextAttr->type, *values);
			values++;
		}
		nextAttr =
		    papiAttributeListGetNext((papi_attribute_t **)attrs, &iter);
	}

	return (result);
} /* papi_modifyAttrsList() */