~ubuntu-branches/ubuntu/oneiric/cups/oneiric-proposed

« back to all changes in this revision

Viewing changes to scheduler/subscriptions.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt, Till Kamppeter, Martin Pitt
  • Date: 2011-08-07 12:53:12 UTC
  • mfrom: (1.2.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20110807125312-s323cyb3oqaxaemo
Tags: 1.5.0-1
[ Till Kamppeter ]
* New upstream release
* debian/patches/usb-backend-no-segfault-on-bad-device-id.patch,
  debian/patches/usb-backend-accept-old-usblp-uris.patch,
  debian/patches/use-ps2write-ghostscript-device-for-pdftops-filter.patch:
  Removed, included upstream.
* debian/patches/poppler-based-pdftops-fixes.patch,
  debian/patches/do-not-emit-ps-level-3-with-poppler.patch: Replaced patch
  by a new one only containing the parts which remain after removing the
  parts included upstream.
* debian/patches/pidfile.patch,
  debian/patches/ppd-poll-with-client-conf.patch,
  debian/patches/cups-avahi.patch,
  debian/patches/drop_unnecessary_dependencies.patch,
  debian/patches/do-not-broadcast-with-hostnames.patch,
  debian/patches/ppdc-dynamic-linking.patch,
  debian/patches/pstops-based-workflow-only-for-printing-ps-on-a-ps-printer.patch:
  Manually regenerated to adapt to upstream changes.
* debian/patches/manpage-translations.patch,
  debian/patches/rootbackends-worldreadable.patch,
  debian/patches/no-conffile-timestamp.patch,
  debian/patches/read-embedded-options-from-incoming-postscript-and-add-to-ipp-attrs.patch,
  debian/patches/cups-snmp-oids-device-id-hp-ricoh.patch,
  debian/patches/configure-default-browse-protocols.patch,
  debian/patches/logfiles_adm_readable.patch,
  debian/patches/confdirperms.patch,
  debian/patches/printer-filtering.patch,
  debian/patches/show-compile-command-lines.patch,
  debian/patches/log-debug-history-nearly-unlimited.patch:
  Refreshed using quilt.
* debian/patches/default-ripcache-size-auto.patch: Dropped, as once,
  Ghostscript 9.04 is ignoring the cache size value as it crashes easily
  otherwise (Ghostscript upstream bug #691586) and second, CUPS defaults to
  more reasonable 128 MB (now only used for imagetops).
* debian/patches/support-gzipped-charmaps.patch: Dropped, as the SBCS and
  VBCS character maps are not used any more by CUPS.
* debian/rules: Enable threads in the ./configure command line, as otherwise
  CUPS 1.5.0 does not build at all.
* debian/local/filters/pdf-filters/filter/pdftoijs.cxx,
  debian/local/filters/pdf-filters/filter/pdftoraster.cxx,
  debian/local/filters/pdf-filters/pdftoopvp/pdftoopvp.cxx,
  debian/local/filters/pdf-filters/pdftopdf/pdftopdf.cxx: Under CUPS 1.5.x.
  all programs using the PPD API of CUPS need to explicitly include
  "<cups/ppd.h>". Updated the PDF filter add-on package.
* debian/local/filters/pdf-filters/addtocups: Make the addition of the
  pdftopdf and pdftoopvp directories also work with CUPS 1.5.x.
* debian/local/filters/pdf-filters/addtocups,
  debian/local/filters/pdf-filters/removefromcups: Added a symbolic link
  cups/i18n.h, so that texttopdf builds.
* debian/cups-client.install: Install the new ipptool and its sample
  files and manpages.
* debian/cups-client.install: Commented out lines for dropped man page
  translations: ipptool, lppasswd, client.conf, ipptoolfile, cupsenable,
  lpadmin, lpinfo, cupsreject, cupsdisable, cupsaccept
* debian/cups-common.install, debian/rules: The /usr/share/cups/charmaps
  directory got removed from CUPS.
* debian/libcups2-dev.install: cups/i18n.h got renamed to
  cups/language-private.h. Install this as /usr/include/cups/i18n.h.
* debian/libcups2.symbols, debian/libcupsmime1.symbols: Updated.
* debian/cups.lintian-overrides, debian/cups.postinst, debian/cups.prerm,
  debian/cups.templates, debian/local/apparmor-profile: The "scsi"
  CUPS backend got dropped upstream, removed its treatment from these files.

[ Martin Pitt ]
* Add Serbian (Cyrillic) debconf translations, thanks Zlatan Todoric.
  (Closes: #635105)
* Add Serbian (Latin) debconf translations, thanks Zlatan Todoric.
  (Closes: #635108)
* debian/local/apparmor-profile: Allow access to serial printers on USB
  adapters. (LP: #677432)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * "$Id: subscriptions.c 9445 2011-01-08 00:03:51Z mike $"
 
2
 * "$Id: subscriptions.c 9793 2011-05-20 03:49:49Z mike $"
3
3
 *
4
4
 *   Subscription routines for the CUPS scheduler.
5
5
 *
480
480
    cupsd_subscription_t *sub,          /* I - Subscription object */
481
481
    int                  update)        /* I - 1 = update subscriptions.conf */
482
482
{
483
 
  int   i;                              /* Looping var */
484
 
 
485
 
 
486
483
 /*
487
484
  * Close the pipe to the notifier as needed...
488
485
  */
503
500
  cupsdClearString(&(sub->owner));
504
501
  cupsdClearString(&(sub->recipient));
505
502
 
506
 
  if (sub->events)
507
 
  {
508
 
    for (i = 0; i < sub->num_events; i ++)
509
 
      cupsd_delete_event(sub->events[i]);
510
 
 
511
 
    free(sub->events);
512
 
  }
 
503
  cupsArrayDelete(sub->events);
513
504
 
514
505
  free(sub);
515
506
 
744
735
  */
745
736
 
746
737
  snprintf(line, sizeof(line), "%s/subscriptions.conf", ServerRoot);
747
 
  if ((fp = cupsFileOpen(line, "r")) == NULL)
748
 
  {
749
 
    if (errno != ENOENT)
750
 
      cupsdLogMessage(CUPSD_LOG_ERROR,
751
 
                      "LoadAllSubscriptions: Unable to open %s - %s", line,
752
 
                      strerror(errno));
 
738
  if ((fp = cupsdOpenConfFile(line)) == NULL)
753
739
    return;
754
 
  }
755
740
 
756
741
 /*
757
742
  * Read all of the lines from the file...
763
748
 
764
749
  while (cupsFileGetConf(fp, line, sizeof(line), &value, &linenum))
765
750
  {
766
 
    if (!strcasecmp(line, "NextSubscriptionId") && value)
 
751
    if (!_cups_strcasecmp(line, "NextSubscriptionId") && value)
767
752
    {
768
753
     /*
769
754
      * NextSubscriptionId NNN
773
758
      if (i >= NextSubscriptionId && i > 0)
774
759
        NextSubscriptionId = i;
775
760
    }
776
 
    else if (!strcasecmp(line, "<Subscription"))
 
761
    else if (!_cups_strcasecmp(line, "<Subscription"))
777
762
    {
778
763
     /*
779
764
      * <Subscription #>
792
777
        break;
793
778
      }
794
779
    }
795
 
    else if (!strcasecmp(line, "</Subscription>"))
 
780
    else if (!_cups_strcasecmp(line, "</Subscription>"))
796
781
    {
797
782
      if (!sub)
798
783
      {
814
799
                      "Syntax error on line %d of subscriptions.conf.",
815
800
                      linenum);
816
801
    }
817
 
    else if (!strcasecmp(line, "Events"))
 
802
    else if (!_cups_strcasecmp(line, "Events"))
818
803
    {
819
804
     /*
820
805
      * Events name
855
840
        value = valueptr;
856
841
      }
857
842
    }
858
 
    else if (!strcasecmp(line, "Owner"))
 
843
    else if (!_cups_strcasecmp(line, "Owner"))
859
844
    {
860
845
     /*
861
846
      * Owner
871
856
        break;
872
857
      }
873
858
    }
874
 
    else if (!strcasecmp(line, "Recipient"))
 
859
    else if (!_cups_strcasecmp(line, "Recipient"))
875
860
    {
876
861
     /*
877
862
      * Recipient uri
887
872
        break;
888
873
      }
889
874
    }
890
 
    else if (!strcasecmp(line, "JobId"))
 
875
    else if (!_cups_strcasecmp(line, "JobId"))
891
876
    {
892
877
     /*
893
878
      * JobId #
911
896
        break;
912
897
      }
913
898
    }
914
 
    else if (!strcasecmp(line, "PrinterName"))
 
899
    else if (!_cups_strcasecmp(line, "PrinterName"))
915
900
    {
916
901
     /*
917
902
      * PrinterName name
935
920
        break;
936
921
      }
937
922
    }
938
 
    else if (!strcasecmp(line, "UserData"))
 
923
    else if (!_cups_strcasecmp(line, "UserData"))
939
924
    {
940
925
     /*
941
926
      * UserData encoded-string
997
982
        break;
998
983
      }
999
984
    }
1000
 
    else if (!strcasecmp(line, "LeaseDuration"))
 
985
    else if (!_cups_strcasecmp(line, "LeaseDuration"))
1001
986
    {
1002
987
     /*
1003
988
      * LeaseDuration #
1016
1001
        break;
1017
1002
      }
1018
1003
    }
1019
 
    else if (!strcasecmp(line, "Interval"))
 
1004
    else if (!_cups_strcasecmp(line, "Interval"))
1020
1005
    {
1021
1006
     /*
1022
1007
      * Interval #
1032
1017
        break;
1033
1018
      }
1034
1019
    }
1035
 
    else if (!strcasecmp(line, "ExpirationTime"))
 
1020
    else if (!_cups_strcasecmp(line, "ExpirationTime"))
1036
1021
    {
1037
1022
     /*
1038
1023
      * ExpirationTime #
1048
1033
        break;
1049
1034
      }
1050
1035
    }
1051
 
    else if (!strcasecmp(line, "NextEventId"))
 
1036
    else if (!_cups_strcasecmp(line, "NextEventId"))
1052
1037
    {
1053
1038
     /*
1054
1039
      * NextEventId #
1089
1074
{
1090
1075
  int                   i;              /* Looping var */
1091
1076
  cups_file_t           *fp;            /* subscriptions.conf file */
1092
 
  char                  temp[1024];     /* Temporary string */
1093
 
  char                  backup[1024];   /* subscriptions.conf.O file */
 
1077
  char                  filename[1024], /* subscriptions.conf filename */
 
1078
                        temp[1024];     /* Temporary string */
1094
1079
  cupsd_subscription_t  *sub;           /* Current subscription */
1095
1080
  time_t                curtime;        /* Current time */
1096
1081
  struct tm             *curdate;       /* Current date */
1103
1088
  * Create the subscriptions.conf file...
1104
1089
  */
1105
1090
 
1106
 
  snprintf(temp, sizeof(temp), "%s/subscriptions.conf", ServerRoot);
1107
 
  snprintf(backup, sizeof(backup), "%s/subscriptions.conf.O", ServerRoot);
1108
 
 
1109
 
  if (rename(temp, backup))
1110
 
  {
1111
 
    if (errno != ENOENT)
1112
 
      cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to backup subscriptions.conf - %s",
1113
 
                      strerror(errno));
1114
 
  }
1115
 
 
1116
 
  if ((fp = cupsFileOpen(temp, "w")) == NULL)
1117
 
  {
1118
 
    cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to save subscriptions.conf - %s",
1119
 
                    strerror(errno));
1120
 
 
1121
 
    if (rename(backup, temp))
1122
 
      cupsdLogMessage(CUPSD_LOG_ERROR,
1123
 
                      "Unable to restore subscriptions.conf - %s",
1124
 
                      strerror(errno));
 
1091
  snprintf(filename, sizeof(filename), "%s/subscriptions.conf", ServerRoot);
 
1092
 
 
1093
  if ((fp = cupsdCreateConfFile(filename, ConfigFilePerm)) == NULL)
1125
1094
    return;
1126
 
  }
1127
 
  else
1128
 
    cupsdLogMessage(CUPSD_LOG_INFO, "Saving subscriptions.conf...");
1129
 
 
1130
 
 /*
1131
 
  * Restrict access to the file...
1132
 
  */
1133
 
 
1134
 
  fchown(cupsFileNumber(fp), getuid(), Group);
1135
 
  fchmod(cupsFileNumber(fp), ConfigFilePerm);
 
1095
 
 
1096
  cupsdLogMessage(CUPSD_LOG_INFO, "Saving subscriptions.conf...");
1136
1097
 
1137
1098
 /*
1138
1099
  * Write a small header to the file...
1233
1194
    cupsFilePuts(fp, "</Subscription>\n");
1234
1195
  }
1235
1196
 
1236
 
  cupsFileClose(fp);
 
1197
  cupsdCloseCreatedConfFile(fp, filename);
1237
1198
}
1238
1199
 
1239
1200
 
1426
1387
 
1427
1388
  if (!sub->events)
1428
1389
  {
1429
 
    sub->events = calloc(MaxEvents, sizeof(cupsd_event_t *));
 
1390
    sub->events = cupsArrayNew3((cups_array_func_t)NULL, NULL,
 
1391
                                (cups_ahash_func_t)NULL, 0,
 
1392
                                (cups_acopy_func_t)NULL,
 
1393
                                (cups_afree_func_t)cupsd_delete_event);
1430
1394
 
1431
1395
    if (!sub->events)
1432
1396
    {
1441
1405
  * Purge an old event as needed...
1442
1406
  */
1443
1407
 
1444
 
  if (sub->num_events >= MaxEvents)
 
1408
  if (cupsArrayCount(sub->events) >= MaxEvents)
1445
1409
  {
1446
1410
   /*
1447
1411
    * Purge the oldest event in the cache...
1448
1412
    */
1449
1413
 
1450
 
    cupsd_delete_event(sub->events[0]);
 
1414
    cupsArrayRemove(sub->events, cupsArrayFirst(sub->events));
1451
1415
 
1452
 
    sub->num_events --;
1453
1416
    sub->first_event_id ++;
1454
 
 
1455
 
    memmove(sub->events, sub->events + 1,
1456
 
            sub->num_events * sizeof(cupsd_event_t *));
1457
1417
  }
1458
1418
 
1459
1419
 /*
1463
1423
  * event cache limit, we don't need to check for overflow here...
1464
1424
  */
1465
1425
 
1466
 
  sub->events[sub->num_events] = event;
1467
 
  sub->num_events ++;
 
1426
  cupsArrayAdd(sub->events, event);
1468
1427
 
1469
1428
 /*
1470
1429
  * Deliver the event...
1675
1634
 
1676
1635
 
1677
1636
/*
1678
 
 * End of "$Id: subscriptions.c 9445 2011-01-08 00:03:51Z mike $".
 
1637
 * End of "$Id: subscriptions.c 9793 2011-05-20 03:49:49Z mike $".
1679
1638
 */