~ubuntu-branches/ubuntu/precise/foomatic-filters/precise-proposed

« back to all changes in this revision

Viewing changes to options.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Raboud, Translation updates
  • Date: 2011-02-09 15:38:14 UTC
  • mfrom: (1.2.4 upstream) (6.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20110209153814-noiljpseb0kzdlzs
Tags: 4.0.6-1
* Upload to unstable.

[ Translation updates ]
* Japanese: Indent correctly.

* Explicitly depend on bash (Closes: #600179)

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
                             filter should be piped */
43
43
int ps_accounting = 1;
44
44
char cupsfilter [256];
 
45
int jobentitymaxlen = 0;
 
46
int userentitymaxlen = 0;
 
47
int hostentitymaxlen = 0;
 
48
int titleentitymaxlen = 0;
 
49
int optionsentitymaxlen = 0;
45
50
 
46
51
/* JCL prefix to put before the JCL options
47
52
 (Can be modified by a "*JCLBegin:" keyword in the ppd file): */
1084
1089
{
1085
1090
    jobparams_t *job = get_current_job();
1086
1091
    char *pdest = dest;
1087
 
    const char *psrc = src;
 
1092
    const char *psrc = src, *p = NULL;
1088
1093
    const char *repl;
1089
1094
    struct tm *t = localtime(&job->time);
1090
1095
    char tmpstr[10];
1091
 
    size_t s;
 
1096
    size_t s, l, n;
1092
1097
 
1093
1098
    while (*psrc && pdest - dest < size - 1) {
1094
1099
 
1095
1100
        if (*psrc == '&') {
1096
1101
            psrc++;
1097
1102
            repl = NULL;
 
1103
            p = NULL;
 
1104
            l = 0;
1098
1105
 
1099
1106
            /* Replace HTML/XML entities by the original characters */
1100
 
            if (!prefixcmp(psrc, "apos;"))
 
1107
            if (!prefixcmp(psrc, "apos")) {
1101
1108
                repl = "\'";
1102
 
            else if (!prefixcmp(psrc, "quot;"))
 
1109
                p = psrc + 4;
 
1110
            } else if (!prefixcmp(psrc, "quot")) {
1103
1111
                repl = "\"";
1104
 
            else if (!prefixcmp(psrc, "gt;"))
 
1112
                p = psrc + 4;
 
1113
            } else if (!prefixcmp(psrc, "gt")) {
1105
1114
                repl = ">";
1106
 
            else if (!prefixcmp(psrc, "lt;"))
 
1115
                p = psrc + 2;
 
1116
            } else if (!prefixcmp(psrc, "lt")) {
1107
1117
                repl = "<";
1108
 
            else if (!prefixcmp(psrc, "amp;"))
 
1118
                p = psrc + 2;
 
1119
            } else if (!prefixcmp(psrc, "amp")) {
1109
1120
                repl = "&";
 
1121
                p = psrc + 3;
1110
1122
 
1111
1123
            /* Replace special entities by job->data */
1112
 
            else if (!prefixcmp(psrc, "job;"))
 
1124
            } else if (!prefixcmp(psrc, "job")) {
1113
1125
                repl = job->id;
1114
 
            else if (!prefixcmp(psrc, "user;"))
 
1126
                p = psrc + 3;
 
1127
                if (jobentitymaxlen != 0)
 
1128
                    l = jobentitymaxlen;
 
1129
            } else if (!prefixcmp(psrc, "user")) {
1115
1130
                repl = job->user;
1116
 
            else if (!prefixcmp(psrc, "host;"))
 
1131
                p = psrc + 4;
 
1132
                if (userentitymaxlen != 0)
 
1133
                    l = userentitymaxlen;
 
1134
            } else if (!prefixcmp(psrc, "host")) {
1117
1135
                repl = job->host;
1118
 
            else if (!prefixcmp(psrc, "title;"))
 
1136
                p = psrc + 4;
 
1137
                if (hostentitymaxlen != 0)
 
1138
                    l = hostentitymaxlen;
 
1139
            } else if (!prefixcmp(psrc, "title")) {
1119
1140
                repl = job->title;
1120
 
            else if (!prefixcmp(psrc, "copies;"))
 
1141
                p = psrc + 5;
 
1142
                if (titleentitymaxlen != 0)
 
1143
                    l = titleentitymaxlen;
 
1144
            } else if (!prefixcmp(psrc, "copies")) {
1121
1145
                repl = job->copies;
1122
 
            else if (!prefixcmp(psrc, "rbinumcopies;")) {
 
1146
                p = psrc + 6;
 
1147
            } else if (!prefixcmp(psrc, "rbinumcopies")) {
1123
1148
                if (job->rbinumcopies > 0) {
1124
1149
                    snprintf(tmpstr, 10, "%d", job->rbinumcopies);
1125
1150
                    repl = tmpstr;
1126
1151
                }
1127
1152
                else
1128
1153
                    repl = job->copies;
 
1154
                p = psrc + 12;
1129
1155
            }
1130
 
            else if (!prefixcmp(psrc, "options;"))
 
1156
            else if (!prefixcmp(psrc, "options")) {
1131
1157
                repl = job->optstr->data;
1132
 
            else if (!prefixcmp(psrc, "year;")) {
 
1158
                p = psrc + 7;
 
1159
                if (optionsentitymaxlen != 0)
 
1160
                    l = optionsentitymaxlen;
 
1161
            } else if (!prefixcmp(psrc, "year")) {
1133
1162
                sprintf(tmpstr, "%04d", t->tm_year + 1900);
1134
1163
                repl = tmpstr;
 
1164
                p = psrc + 4;
1135
1165
            }
1136
 
            else if (!prefixcmp(psrc, "month;")) {
 
1166
            else if (!prefixcmp(psrc, "month")) {
1137
1167
                sprintf(tmpstr, "%02d", t->tm_mon + 1);
1138
1168
                repl = tmpstr;
 
1169
                p = psrc + 5;
1139
1170
            }
1140
 
            else if (!prefixcmp(psrc, "date;")) {
 
1171
            else if (!prefixcmp(psrc, "date")) {
1141
1172
                sprintf(tmpstr, "%02d", t->tm_mday);
1142
1173
                repl = tmpstr;
 
1174
                p = psrc + 4;
1143
1175
            }
1144
 
            else if (!prefixcmp(psrc, "hour;")) {
 
1176
            else if (!prefixcmp(psrc, "hour")) {
1145
1177
                sprintf(tmpstr, "%02d", t->tm_hour);
1146
1178
                repl = tmpstr;
 
1179
                p = psrc + 4;
1147
1180
            }
1148
 
            else if (!prefixcmp(psrc, "min;")) {
 
1181
            else if (!prefixcmp(psrc, "min")) {
1149
1182
                sprintf(tmpstr, "%02d", t->tm_min);
1150
1183
                repl = tmpstr;
 
1184
                p = psrc + 3;
1151
1185
            }
1152
 
            else if (!prefixcmp(psrc, "sec;")) {
 
1186
            else if (!prefixcmp(psrc, "sec")) {
1153
1187
                sprintf(tmpstr, "%02d", t->tm_sec);
1154
1188
                repl = tmpstr;
 
1189
                p = psrc + 3;
1155
1190
            }
1156
 
 
 
1191
            if (p) {
 
1192
                n = strtol(p, (char **)(&p), 0);
 
1193
                if (n != 0)
 
1194
                    l = n;
 
1195
                if (*p != ';')
 
1196
                    repl = NULL;
 
1197
            } else
 
1198
                repl = NULL;
1157
1199
            if (repl) {
1158
 
                s = size - (pdest - dest) - 1;
 
1200
                if ((l == 0) || (l > strlen(repl)))
 
1201
                    l = strlen(repl);
 
1202
                s = size - (pdest - dest) - 1;
1159
1203
                strncpy(pdest, repl, s);
1160
 
                if (s < strlen(repl))
1161
 
                  pdest += s;
1162
 
                else
1163
 
                  pdest += strlen(repl);
1164
 
                psrc = strchr(psrc, ';') +1;
 
1204
                if (s < l)
 
1205
                    pdest += s;
 
1206
                else
 
1207
                    pdest += l;
 
1208
                psrc = p + 1;
1165
1209
            }
1166
1210
            else {
1167
1211
                *pdest = '&';
1704
1748
                 "longer supported by Foomatic >4.0. Exiting.\n");
1705
1749
            exit(1); /* TODO exit more gracefully */
1706
1750
        }
 
1751
        else if (!strcmp(key, "FoomaticRIPJobEntityMaxLength")) {
 
1752
            /*  "*FoomaticRIPJobEntityMaxLength: <length>" */
 
1753
            sscanf(value->data, "%d", &jobentitymaxlen);
 
1754
        }
 
1755
        else if (!strcmp(key, "FoomaticRIPUserEntityMaxLength")) {
 
1756
            /*  "*FoomaticRIPUserEntityMaxLength: <length>" */
 
1757
            sscanf(value->data, "%d", &userentitymaxlen);
 
1758
        }
 
1759
        else if (!strcmp(key, "FoomaticRIPHostEntityMaxLength")) {
 
1760
            /*  "*FoomaticRIPHostEntityMaxLength: <length>" */
 
1761
            sscanf(value->data, "%d", &hostentitymaxlen);
 
1762
        }
 
1763
        else if (!strcmp(key, "FoomaticRIPTitleEntityMaxLength")) {
 
1764
            /*  "*FoomaticRIPTitleEntityMaxLength: <length>" */
 
1765
            sscanf(value->data, "%d", &titleentitymaxlen);
 
1766
        }
 
1767
        else if (!strcmp(key, "FoomaticRIPOptionsEntityMaxLength")) {
 
1768
            /*  "*FoomaticRIPOptionsEntityMaxLength: <length>" */
 
1769
            sscanf(value->data, "%d", &optionsentitymaxlen);
 
1770
        }
1707
1771
    }
1708
1772
 
1709
1773
    fclose(fh);