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];
1093
1098
while (*psrc && pdest - dest < size - 1) {
1095
1100
if (*psrc == '&') {
1099
1106
/* Replace HTML/XML entities by the original characters */
1100
if (!prefixcmp(psrc, "apos;"))
1107
if (!prefixcmp(psrc, "apos")) {
1102
else if (!prefixcmp(psrc, "quot;"))
1110
} else if (!prefixcmp(psrc, "quot")) {
1104
else if (!prefixcmp(psrc, "gt;"))
1113
} else if (!prefixcmp(psrc, "gt")) {
1106
else if (!prefixcmp(psrc, "lt;"))
1116
} else if (!prefixcmp(psrc, "lt")) {
1108
else if (!prefixcmp(psrc, "amp;"))
1119
} else if (!prefixcmp(psrc, "amp")) {
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;"))
1127
if (jobentitymaxlen != 0)
1128
l = jobentitymaxlen;
1129
} else if (!prefixcmp(psrc, "user")) {
1115
1130
repl = job->user;
1116
else if (!prefixcmp(psrc, "host;"))
1132
if (userentitymaxlen != 0)
1133
l = userentitymaxlen;
1134
} else if (!prefixcmp(psrc, "host")) {
1117
1135
repl = job->host;
1118
else if (!prefixcmp(psrc, "title;"))
1137
if (hostentitymaxlen != 0)
1138
l = hostentitymaxlen;
1139
} else if (!prefixcmp(psrc, "title")) {
1119
1140
repl = job->title;
1120
else if (!prefixcmp(psrc, "copies;"))
1142
if (titleentitymaxlen != 0)
1143
l = titleentitymaxlen;
1144
} else if (!prefixcmp(psrc, "copies")) {
1121
1145
repl = job->copies;
1122
else if (!prefixcmp(psrc, "rbinumcopies;")) {
1147
} else if (!prefixcmp(psrc, "rbinumcopies")) {
1123
1148
if (job->rbinumcopies > 0) {
1124
1149
snprintf(tmpstr, 10, "%d", job->rbinumcopies);
1128
1153
repl = job->copies;
1130
else if (!prefixcmp(psrc, "options;"))
1156
else if (!prefixcmp(psrc, "options")) {
1131
1157
repl = job->optstr->data;
1132
else if (!prefixcmp(psrc, "year;")) {
1159
if (optionsentitymaxlen != 0)
1160
l = optionsentitymaxlen;
1161
} else if (!prefixcmp(psrc, "year")) {
1133
1162
sprintf(tmpstr, "%04d", t->tm_year + 1900);
1136
else if (!prefixcmp(psrc, "month;")) {
1166
else if (!prefixcmp(psrc, "month")) {
1137
1167
sprintf(tmpstr, "%02d", t->tm_mon + 1);
1140
else if (!prefixcmp(psrc, "date;")) {
1171
else if (!prefixcmp(psrc, "date")) {
1141
1172
sprintf(tmpstr, "%02d", t->tm_mday);
1144
else if (!prefixcmp(psrc, "hour;")) {
1176
else if (!prefixcmp(psrc, "hour")) {
1145
1177
sprintf(tmpstr, "%02d", t->tm_hour);
1148
else if (!prefixcmp(psrc, "min;")) {
1181
else if (!prefixcmp(psrc, "min")) {
1149
1182
sprintf(tmpstr, "%02d", t->tm_min);
1152
else if (!prefixcmp(psrc, "sec;")) {
1186
else if (!prefixcmp(psrc, "sec")) {
1153
1187
sprintf(tmpstr, "%02d", t->tm_sec);
1192
n = strtol(p, (char **)(&p), 0);
1158
s = size - (pdest - dest) - 1;
1200
if ((l == 0) || (l > strlen(repl)))
1202
s = size - (pdest - dest) - 1;
1159
1203
strncpy(pdest, repl, s);
1160
if (s < strlen(repl))
1163
pdest += strlen(repl);
1164
psrc = strchr(psrc, ';') +1;
1704
1748
"longer supported by Foomatic >4.0. Exiting.\n");
1705
1749
exit(1); /* TODO exit more gracefully */
1751
else if (!strcmp(key, "FoomaticRIPJobEntityMaxLength")) {
1752
/* "*FoomaticRIPJobEntityMaxLength: <length>" */
1753
sscanf(value->data, "%d", &jobentitymaxlen);
1755
else if (!strcmp(key, "FoomaticRIPUserEntityMaxLength")) {
1756
/* "*FoomaticRIPUserEntityMaxLength: <length>" */
1757
sscanf(value->data, "%d", &userentitymaxlen);
1759
else if (!strcmp(key, "FoomaticRIPHostEntityMaxLength")) {
1760
/* "*FoomaticRIPHostEntityMaxLength: <length>" */
1761
sscanf(value->data, "%d", &hostentitymaxlen);
1763
else if (!strcmp(key, "FoomaticRIPTitleEntityMaxLength")) {
1764
/* "*FoomaticRIPTitleEntityMaxLength: <length>" */
1765
sscanf(value->data, "%d", &titleentitymaxlen);
1767
else if (!strcmp(key, "FoomaticRIPOptionsEntityMaxLength")) {
1768
/* "*FoomaticRIPOptionsEntityMaxLength: <length>" */
1769
sscanf(value->data, "%d", &optionsentitymaxlen);