Ignore:
Timestamp:
Nov 29, 2012, 1:59:04 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.9

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/source3/printing/print_iprint.c

    r745 r751  
    3535#define NOVELL_SERVER_VERSION_OES_SP1           33554432
    3636
     37#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5)
     38#define HAVE_CUPS_1_6 1
     39#endif
     40
     41#ifndef HAVE_CUPS_1_6
     42#define ippGetCount(attr)     attr->num_values
     43#define ippGetGroupTag(attr)  attr->group_tag
     44#define ippGetName(attr)      attr->name
     45#define ippGetValueTag(attr)  attr->value_tag
     46#define ippGetStatusCode(ipp) ipp->request.status.status_code
     47#define ippGetBoolean(attr, element) attr->values[element].boolean
     48#define ippGetInteger(attr, element) attr->values[element].integer
     49#define ippGetString(attr, element, language) attr->values[element].string.text
     50
     51static ipp_attribute_t *
     52ippFirstAttribute(ipp_t *ipp)
     53{
     54  if (!ipp)
     55    return (NULL);
     56  return (ipp->current = ipp->attrs);
     57}
     58
     59static ipp_attribute_t *
     60ippNextAttribute(ipp_t *ipp)
     61{
     62  if (!ipp || !ipp->current)
     63    return (NULL);
     64  return (ipp->current = ipp->current->next);
     65}
     66
     67static int ippSetOperation(ipp_t *ipp, ipp_op_t op)
     68{
     69    ipp->request.op.operation_id = op;
     70    return (1);
     71}
     72
     73static int ippSetRequestId(ipp_t *ipp, int request_id)
     74{
     75    ipp->request.any.request_id = request_id;
     76    return (1);
     77}
     78#endif
     79
    3780/*
    3881 * 'iprint_passwd_cb()' - The iPrint password callback...
     
    93136        request = ippNew();
    94137
    95         request->request.op.operation_id = (ipp_op_t)OPERATION_NOVELL_MGMT;
    96         request->request.op.request_id   = 1;
     138        ippSetOperation(request, (ipp_op_t)OPERATION_NOVELL_MGMT);
     139        ippSetRequestId(request, 1);
    97140
    98141        language = cupsLangDefault();
     
    115158
    116159        if (((response = cupsDoRequest(http, request, "/ipp/")) == NULL) ||
    117             (response->request.status.status_code >= IPP_OK_CONFLICT))
     160            (ippGetStatusCode(response) >= IPP_OK_CONFLICT))
    118161                goto out;
    119162
    120163        if (((attr = ippFindAttribute(response, "server-version",
    121164                                      IPP_TAG_STRING)) != NULL)) {
    122                 if ((ver = strstr(attr->values[0].string.text,
     165                if ((ver = strstr(ippGetString(attr, 0, NULL),
    123166                                  NOVELL_SERVER_VERSION_STRING)) != NULL) {
    124167                        ver += strlen(NOVELL_SERVER_VERSION_STRING);
     
    136179                }
    137180
    138                 if ((os = strstr(attr->values[0].string.text,
     181                if ((os = strstr(ippGetString(attr, 0, NULL),
    139182                                  NOVELL_SERVER_SYSNAME)) != NULL) {
    140183                        os += strlen(NOVELL_SERVER_SYSNAME);
     
    185228        request = ippNew();
    186229
    187         request->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES;
    188         request->request.op.request_id   = reqId;
     230        ippSetOperation(request, IPP_GET_PRINTER_ATTRIBUTES);
     231        ippSetRequestId(request, reqId);
    189232
    190233        language = cupsLangDefault();
     
    231274        }
    232275
    233         for (attr = response->attrs; attr != NULL;) {
     276        for (attr = ippFirstAttribute(response); attr != NULL;) {
    234277               /*
    235278                * Skip leading attributes until we hit a printer...
    236279                */
    237280
    238                 while (attr != NULL && attr->group_tag != IPP_TAG_PRINTER)
    239                         attr = attr->next;
     281                while (attr != NULL && ippGetGroupTag(attr) != IPP_TAG_PRINTER)
     282                        attr = ippNextAttribute(response);
    240283
    241284                if (attr == NULL)
     
    251294                secure     = 0;
    252295
    253                 while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER) {
    254                         if (strcmp(attr->name, "printer-name") == 0 &&
    255                             attr->value_tag == IPP_TAG_NAME)
    256                                 name = attr->values[0].string.text;
    257 
    258                         if (strcmp(attr->name, "printer-info") == 0 &&
    259                             (attr->value_tag == IPP_TAG_TEXT ||
    260                             attr->value_tag == IPP_TAG_TEXTLANG))
    261                                 info = attr->values[0].string.text;
     296                while (attr != NULL && ippGetGroupTag(attr) == IPP_TAG_PRINTER) {
     297                        if (strcmp(ippGetName(attr), "printer-name") == 0 &&
     298                            ippGetValueTag(attr) == IPP_TAG_NAME)
     299                                name = ippGetString(attr, 0, NULL);
     300
     301                        if (strcmp(ippGetName(attr), "printer-info") == 0 &&
     302                            (ippGetValueTag(attr) == IPP_TAG_TEXT ||
     303                            ippGetValueTag(attr) == IPP_TAG_TEXTLANG))
     304                                info = ippGetString(attr, 0, NULL);
    262305
    263306                       /*
     
    267310                        * printer should show up
    268311                        */
    269                         if (!strcmp(attr->name, "smb-enabled") &&
    270                             ((attr->value_tag == IPP_TAG_INTEGER &&
    271                             !attr->values[0].integer) ||
    272                             (attr->value_tag == IPP_TAG_BOOLEAN &&
    273                             !attr->values[0].boolean)))
     312                        if (!strcmp(ippGetName(attr), "smb-enabled") &&
     313                            ((ippGetValueTag(attr) == IPP_TAG_INTEGER &&
     314                            !ippGetInteger(attr, 0)) ||
     315                            (ippGetValueTag(attr) == IPP_TAG_BOOLEAN &&
     316                            !ippGetBoolean(attr, 0))))
    274317                                smb_enabled = 0;
    275318
     
    280323                        * printer should show up
    281324                        */
    282                         if (!strcmp(attr->name, "security-enabled") &&
    283                             ((attr->value_tag == IPP_TAG_INTEGER &&
    284                             attr->values[0].integer) ||
    285                             (attr->value_tag == IPP_TAG_BOOLEAN &&
    286                             attr->values[0].boolean)))
     325                        if (!strcmp(ippGetName(attr), "security-enabled") &&
     326                            ((ippGetValueTag(attr) == IPP_TAG_INTEGER &&
     327                            ippGetInteger(attr, 0)) ||
     328                            (ippGetValueTag(attr) == IPP_TAG_BOOLEAN &&
     329                            ippGetBoolean(attr, 0))))
    287330                                secure = 1;
    288331
    289                         attr = attr->next;
     332                        attr = ippNextAttribute(response);
    290333                }
    291334
     
    344387        request = ippNew();
    345388
    346         request->request.op.operation_id =
    347                 (ipp_op_t)OPERATION_NOVELL_LIST_PRINTERS;
    348         request->request.op.request_id   = 1;
     389        ippSetOperation(request, (ipp_op_t)OPERATION_NOVELL_LIST_PRINTERS);
     390        ippSetRequestId(request, 1);
    349391
    350392        language = cupsLangDefault();
     
    369411        }
    370412
    371         for (attr = response->attrs; attr != NULL;) {
     413        for (attr = ippFirstAttribute(response); attr != NULL;) {
    372414               /*
    373415                * Skip leading attributes until we hit a printer...
    374416                */
    375417
    376                 while (attr != NULL && attr->group_tag != IPP_TAG_PRINTER)
    377                         attr = attr->next;
     418                while (attr != NULL && ippGetGroupTag(attr) != IPP_TAG_PRINTER)
     419                        attr = ippNextAttribute(response);
    378420
    379421                if (attr == NULL)
     
    384426                */
    385427
    386                 while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER)
     428                while (attr != NULL && ippGetGroupTag(attr) == IPP_TAG_PRINTER)
    387429                {
    388                         if (strcmp(attr->name, "printer-name") == 0 &&
    389                             (attr->value_tag == IPP_TAG_URI ||
    390                              attr->value_tag == IPP_TAG_NAME ||
    391                              attr->value_tag == IPP_TAG_TEXT ||
    392                              attr->value_tag == IPP_TAG_NAMELANG ||
    393                              attr->value_tag == IPP_TAG_TEXTLANG))
     430                        if (strcmp(ippGetName(attr), "printer-name") == 0 &&
     431                            (ippGetValueTag(attr) == IPP_TAG_URI ||
     432                             ippGetValueTag(attr) == IPP_TAG_NAME ||
     433                             ippGetValueTag(attr) == IPP_TAG_TEXT ||
     434                             ippGetValueTag(attr) == IPP_TAG_NAMELANG ||
     435                             ippGetValueTag(attr) == IPP_TAG_TEXTLANG))
    394436                        {
    395                                 for (i = 0; i<attr->num_values; i++)
     437                                for (i = 0; i<ippGetCount(attr); i++)
    396438                                {
    397                                         char *url = attr->values[i].string.text;
     439                                        char *url = ippGetString(attr, i, NULL);
    398440                                        if (!url || !strlen(url))
    399441                                                continue;
     
    401443                                }
    402444                        }
    403                         attr = attr->next;
     445                        attr = ippNextAttribute(response);
    404446                }
    405447        }
     
    467509        request = ippNew();
    468510
    469         request->request.op.operation_id = IPP_CANCEL_JOB;
    470         request->request.op.request_id   = 1;
     511        ippSetOperation(request, IPP_CANCEL_JOB);
     512        ippSetRequestId(request, 1);
    471513
    472514        language = cupsLangDefault();
     
    494536
    495537        if ((response = cupsDoRequest(http, request, httpPath)) != NULL) {
    496                 if (response->request.status.status_code >= IPP_OK_CONFLICT) {
     538                if (ippGetStatusCode(response) >= IPP_OK_CONFLICT) {
    497539                        DEBUG(0,("Unable to cancel job %d - %s\n", pjob->sysjob,
    498540                                ippErrorString(cupsLastError())));
     
    565607        request = ippNew();
    566608
    567         request->request.op.operation_id = IPP_HOLD_JOB;
    568         request->request.op.request_id   = 1;
     609        ippSetOperation(request, IPP_HOLD_JOB);
     610        ippSetRequestId(request, 1);
    569611
    570612        language = cupsLangDefault();
     
    594636
    595637        if ((response = cupsDoRequest(http, request, httpPath)) != NULL) {
    596                 if (response->request.status.status_code >= IPP_OK_CONFLICT) {
     638                if (ippGetStatusCode(response) >= IPP_OK_CONFLICT) {
    597639                        DEBUG(0,("Unable to hold job %d - %s\n", pjob->sysjob,
    598640                                ippErrorString(cupsLastError())));
     
    665707        request = ippNew();
    666708
    667         request->request.op.operation_id = IPP_RELEASE_JOB;
    668         request->request.op.request_id   = 1;
     709        ippSetOperation(request, IPP_RELEASE_JOB);
     710        ippSetRequestId(request, 1);
    669711
    670712        language = cupsLangDefault();
     
    694736
    695737        if ((response = cupsDoRequest(http, request, httpPath)) != NULL) {
    696                 if (response->request.status.status_code >= IPP_OK_CONFLICT) {
     738                if (ippGetStatusCode(response) >= IPP_OK_CONFLICT) {
    697739                        DEBUG(0,("Unable to release job %d - %s\n", pjob->sysjob,
    698740                                ippErrorString(cupsLastError())));
     
    723765 */
    724766
    725 static int iprint_job_submit(int snum, struct printjob *pjob)
     767static int iprint_job_submit(int snum, struct printjob *pjob,
     768                             enum printing_types printing_type,
     769                             char *lpq_cmd)
    726770{
    727771        int             ret = 1;                /* Return value */
     
    764808        request = ippNew();
    765809
    766         request->request.op.operation_id = IPP_PRINT_JOB;
    767         request->request.op.request_id   = 1;
     810        ippSetOperation(request, IPP_PRINT_JOB);
     811        ippSetRequestId(request, 1);
    768812
    769813        language = cupsLangDefault();
     
    798842
    799843        if ((response = cupsDoFileRequest(http, request, uri, pjob->filename)) != NULL) {
    800                 if (response->request.status.status_code >= IPP_OK_CONFLICT) {
     844                if (ippGetStatusCode(response) >= IPP_OK_CONFLICT) {
    801845                        DEBUG(0,("Unable to print file to %s - %s\n",
    802846                                 lp_printername(snum),
     
    818862
    819863                attr = ippFindAttribute(response, "job-id", IPP_TAG_INTEGER);
    820                 if (attr != NULL && attr->group_tag == IPP_TAG_JOB)
     864                if (attr != NULL && ippGetGroupTag(attr) == IPP_TAG_JOB)
    821865                {
    822                         pjob->sysjob = attr->values[0].integer;
     866                        pjob->sysjob = ippGetInteger(attr, 0);
    823867                }
    824868        }
     
    867911        int             job_k_octets;   /* job-k-octets attribute */
    868912        time_t          job_time;       /* time-at-creation attribute */
    869         time_t          printer_current_time = 0;       /* printer's current time */
    870913        time_t          printer_up_time = 0;    /* printer's uptime */
    871914        ipp_jstate_t    job_status;     /* job-status attribute */
     
    940983        request = ippNew();
    941984
    942         request->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES;
    943         request->request.op.request_id   = 2;
     985        ippSetOperation(request, IPP_GET_PRINTER_ATTRIBUTES);
     986        ippSetRequestId(request, 2);
    944987
    945988        language = cupsLangDefault();
     
    9721015        }
    9731016
    974         if (response->request.status.status_code >= IPP_OK_CONFLICT) {
     1017        if (ippGetStatusCode(response) >= IPP_OK_CONFLICT) {
    9751018                DEBUG(0,("Unable to get printer status for %s - %s\n", printername,
    976                          ippErrorString(response->request.status.status_code)));
     1019                         ippErrorString(ippGetStatusCode(response))));
    9771020                *q = queue;
    9781021                goto out;
     
    9841027
    9851028        if ((attr = ippFindAttribute(response, "printer-state", IPP_TAG_ENUM)) != NULL) {
    986                 if (attr->values[0].integer == IPP_PRINTER_STOPPED)
     1029                if (ippGetInteger(attr, 0) == IPP_PRINTER_STOPPED)
    9871030                        status->status = LPSTAT_STOPPED;
    9881031                else
     
    9921035        if ((attr = ippFindAttribute(response, "printer-state-message",
    9931036                                     IPP_TAG_TEXT)) != NULL)
    994                 fstrcpy(status->message, attr->values[0].string.text);
    995 
    996         if ((attr = ippFindAttribute(response, "printer-current-time",
    997                                      IPP_TAG_DATE)) != NULL)
    998                 printer_current_time = ippDateToTime(attr->values[0].date);
     1037                fstrcpy(status->message, ippGetString(attr, 0, NULL));
    9991038
    10001039        if ((attr = ippFindAttribute(response, "printer-up-time",
    10011040                                     IPP_TAG_INTEGER)) != NULL)
    1002                 printer_up_time = attr->values[0].integer;
     1041                printer_up_time = ippGetInteger(attr, 0);
    10031042
    10041043        ippDelete(response);
     
    10171056        request = ippNew();
    10181057
    1019         request->request.op.operation_id = IPP_GET_JOBS;
    1020         request->request.op.request_id   = 3;
     1058        ippSetOperation(request, IPP_GET_JOBS);
     1059        ippSetRequestId(request, 3);
    10211060
    10221061        ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
     
    10461085        }
    10471086
    1048         if (response->request.status.status_code >= IPP_OK_CONFLICT) {
     1087        if (ippGetStatusCode(response) >= IPP_OK_CONFLICT) {
    10491088                DEBUG(0,("Unable to get jobs for %s - %s\n", uri,
    1050                          ippErrorString(response->request.status.status_code)));
     1089                         ippErrorString(ippGetStatusCode(response))));
    10511090                goto out;
    10521091        }
     
    10601099        queue  = NULL;
    10611100
    1062         for (attr = response->attrs; attr != NULL; attr = attr->next) {
     1101        for (attr = ippFirstAttribute(response); attr != NULL; attr = ippNextAttribute(response)) {
    10631102               /*
    10641103                * Skip leading attributes until we hit a job...
    10651104                */
    10661105
    1067                 while (attr != NULL && attr->group_tag != IPP_TAG_JOB)
    1068                         attr = attr->next;
     1106                while (attr != NULL && ippGetGroupTag(attr) != IPP_TAG_JOB)
     1107                        attr = ippNextAttribute(response);
    10691108
    10701109                if (attr == NULL)
     
    11011140                job_name     = NULL;
    11021141
    1103                 while (attr != NULL && attr->group_tag == IPP_TAG_JOB) {
    1104                         if (attr->name == NULL) {
    1105                                 attr = attr->next;
     1142                while (attr != NULL && ippGetGroupTag(attr) == IPP_TAG_JOB) {
     1143                        if (ippGetName(attr) == NULL) {
     1144                                attr = ippNextAttribute(response);
    11061145                                break;
    11071146                        }
    11081147
    1109                         if (strcmp(attr->name, "job-id") == 0 &&
    1110                             attr->value_tag == IPP_TAG_INTEGER)
    1111                                 job_id = attr->values[0].integer;
    1112 
    1113                         if (strcmp(attr->name, "job-k-octets") == 0 &&
    1114                             attr->value_tag == IPP_TAG_INTEGER)
    1115                                 job_k_octets = attr->values[0].integer;
    1116 
    1117                         if (strcmp(attr->name, "job-priority") == 0 &&
    1118                             attr->value_tag == IPP_TAG_INTEGER)
    1119                                 job_priority = attr->values[0].integer;
    1120 
    1121                         if (strcmp(attr->name, "job-state") == 0 &&
    1122                             attr->value_tag == IPP_TAG_ENUM)
    1123                                 job_status = (ipp_jstate_t)(attr->values[0].integer);
    1124 
    1125                         if (strcmp(attr->name, "time-at-creation") == 0 &&
    1126                             attr->value_tag == IPP_TAG_INTEGER)
     1148                        if (strcmp(ippGetName(attr), "job-id") == 0 &&
     1149                            ippGetValueTag(attr) == IPP_TAG_INTEGER)
     1150                                job_id = ippGetInteger(attr, 0);
     1151
     1152                        if (strcmp(ippGetName(attr), "job-k-octets") == 0 &&
     1153                            ippGetValueTag(attr) == IPP_TAG_INTEGER)
     1154                                job_k_octets = ippGetInteger(attr, 0);
     1155
     1156                        if (strcmp(ippGetName(attr), "job-priority") == 0 &&
     1157                            ippGetValueTag(attr) == IPP_TAG_INTEGER)
     1158                                job_priority = ippGetInteger(attr, 0);
     1159
     1160                        if (strcmp(ippGetName(attr), "job-state") == 0 &&
     1161                            ippGetValueTag(attr) == IPP_TAG_ENUM)
     1162                                job_status = (ipp_jstate_t)ippGetInteger(attr, 0);
     1163
     1164                        if (strcmp(ippGetName(attr), "time-at-creation") == 0 &&
     1165                            ippGetValueTag(attr) == IPP_TAG_INTEGER)
    11271166                        {
    11281167                               /*
     
    11341173
    11351174                                if (jobUseUnixTime)
    1136                                         job_time = attr->values[0].integer;
     1175                                        job_time = ippGetInteger(attr, 0);
    11371176                                else
    1138                                         job_time = time(NULL) - printer_up_time + attr->values[0].integer;
     1177                                        job_time = time(NULL) - printer_up_time + ippGetInteger(attr, 0);
    11391178                        }
    11401179
    1141                         if (strcmp(attr->name, "job-name") == 0 &&
    1142                             (attr->value_tag == IPP_TAG_NAMELANG ||
    1143                              attr->value_tag == IPP_TAG_NAME))
    1144                                 job_name = attr->values[0].string.text;
    1145 
    1146                         if (strcmp(attr->name, "job-originating-user-name") == 0 &&
    1147                             (attr->value_tag == IPP_TAG_NAMELANG ||
    1148                              attr->value_tag == IPP_TAG_NAME))
    1149                                 user_name = attr->values[0].string.text;
    1150 
    1151                         attr = attr->next;
     1180                        if (strcmp(ippGetName(attr), "job-name") == 0 &&
     1181                            (ippGetValueTag(attr) == IPP_TAG_NAMELANG ||
     1182                             ippGetValueTag(attr) == IPP_TAG_NAME))
     1183                                job_name = ippGetString(attr, 0, NULL);
     1184
     1185                        if (strcmp(ippGetName(attr), "job-originating-user-name") == 0 &&
     1186                            (ippGetValueTag(attr) == IPP_TAG_NAMELANG ||
     1187                             ippGetValueTag(attr) == IPP_TAG_NAME))
     1188                                user_name = ippGetString(attr, 0, NULL);
     1189
     1190                        attr = ippNextAttribute(response);
    11521191                }
    11531192
     
    11631202                }
    11641203
    1165                 temp->job      = job_id;
     1204                temp->sysjob   = job_id;
    11661205                temp->size     = job_k_octets * 1024;
    11671206                temp->status   = job_status == IPP_JOB_PENDING ? LPQ_QUEUED :
Note: See TracChangeset for help on using the changeset viewer.