Job Attributes type determination

vladimir vova25 at gmail.com
Wed Jan 31 06:24:57 PST 2007


I'm sorry too
Well, in general, I need to get Job attributes of specified JOB and display this data to user.
I build two arrays: for JOB_ATTRIB_NAME and for JOB_ATTRIB_VALUE correspondingly by calling for cgiSetArray.
My problem is about to pass third parameter: cgiSetArray receive it as string but attr->values[0] may have different data types(date, string, integer, etc).
The question: do I have to perform type determination by myself or exists some API function to do this?
I try to do something like below:
....
request = ippNewRequest(IPP_GET_JOB_ATTRIBUTES);

     snprintf(job_uri, sizeof(job_uri), "ipp://localhost/jobs/%d", job_id);
     ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri",
                   NULL, job_uri);

// Responce
if ((response = cupsDoRequest(http, request, "/")) != NULL)
    {
	i=0;
for (attr = response->attrs; attr; attr = attr->next)
     {
       if (attr->group_tag != IPP_TAG_JOB || !attr->name)
         continue;

	cgiSetArray("JOB_ATTRIB_NAME", i, attr->name);

      switch (attr->value_tag) {
	case IPP_TAG_INTEGER:

               sprintf(szTmpStr,"%s",attr->values[0].date);
		cgiSetArray("JOB_ATTRIB_VALUE", i, szTmpStr);
                break;
case IPP_TAG_DATE:
		printf("%d Date %d <br>", i,attr->values[0].integer);
	default:
             cgiSetArray("JOB_ATTRIB_VALUE", i,                                  attr->values[0].string.text);
}


	i++;
     }


> vladimir wrote:
> > Whether there is a API function an allowing to pass at values of job attributes directly to cgiSetArray() without additional analysis of its type by something like:
> > switch(attr->value_tag){
> >  case IPP_TAG_INTEGER:
> > ..
> > case IPP_TAGE_DATE:
> > default ...
> > }
> > ?
>
> I'm sorry, I don't know what you are trying to do?!?
>
> --
> ______________________________________________________________________
> Michael Sweet, Easy Software Products           mike at easysw dot com
> Internet Printing and Document Software          http://www.easysw.com





More information about the cups-devel mailing list