for (int k = 0; k < 8; k++)
{
t <<= 1;
- if (w + k < width) {
+ if (w + k < width)
+ {
if (bi_level)
threshold = 128;
else
i = 3;
else
i = 2;
- if (c1[i] == '_') {
+ if (c1[i] == '_')
+ {
i ++;
if (c1[i] < 'A' || c1[i] > 'Z' || c1[i + 1] < 'A' || c1[i + 1] > 'Z')
continue;
}
else
filename = location;
- } else {
+ }
+ else
+ {
if (cfGetURI(location, tmpfile, sizeof(tmpfile)))
filename = tmpfile;
}
*end ++ = *ptr;
ptr ++;
}
- } else
+ }
+ else
*end ++ = *ptr ++;
}
*end = '\0';
dbus_message_unref(message);
if (reply != NULL)
dbus_message_unref(reply);
- if (key != NULL) {
+ if (key != NULL)
+ {
for (i = 0; i < max_keys; i ++)
free(key[i]);
free(key);
// Open a pipe ...
//
- if (pipe(pipefds) < 0) {
+ if (pipe(pipefds) < 0)
+ {
if (log) log(ld, CF_LOGLEVEL_ERROR,
"cfFilterPOpen: Could not create pipe for %s: %s",
inputfd < 0 ? "input" : "output",
return (-1);
}
- if ((pid = fork()) == 0) {
+ if ((pid = fork()) == 0)
+ {
//
// Child process goes here...
//
// Update input and output FDs as needed...
//
- if (inputfd < 0) {
+ if (inputfd < 0)
+ {
inputseekable = 0;
infd = pipefds[0];
outfd = outputfd;
close(pipefds[1]);
- } else {
+ }
+ else
+ {
infd = inputfd;
outfd = pipefds[1];
close(pipefds[0]);
ret);
exit(ret);
- } else if (pid > 0) {
+ }
+ else if (pid > 0)
+ {
if (log) log(ld, CF_LOGLEVEL_INFO,
"cfFilterPOpen: Filter function (PID %d) started.", pid);
// Return file descriptor to stream to or from
//
- if (inputfd < 0) {
+ if (inputfd < 0)
+ {
close(pipefds[0]);
return (pipefds[1]);
- } else {
+ }
+ else
+ {
close(pipefds[1]);
return (pipefds[0]);
}
- } else {
+ }
+ else
+ {
//
// fork() error
for (filter = (cf_filter_filter_in_chain_t *)cupsArrayFirst(filter_chain);
filter;
- filter = (cf_filter_filter_in_chain_t *)cupsArrayNext(filter_chain)) {
- if (!filter->function) {
+ filter = (cf_filter_filter_in_chain_t *)cupsArrayNext(filter_chain))
+ {
+ if (!filter->function)
+ {
if (log) log(ld, CF_LOGLEVEL_INFO,
"cfFilterChain: Invalid filter: %s - Removing...",
filter->name ? filter->name : "Unspecified");
cupsArrayRemove(filter_chain, filter);
- } else
+ }
+ else
if (log) log(ld, CF_LOGLEVEL_INFO,
"cfFilterChain: Running filter: %s",
filter->name ? filter->name : "Unspecified");
for (filter = (cf_filter_filter_in_chain_t *)cupsArrayFirst(filter_chain);
filter;
- filter = next, current = 1 - current) {
+ filter = next, current = 1 - current)
+ {
next = (cf_filter_filter_in_chain_t *)cupsArrayNext(filter_chain);
- if (filterfds[1 - current][0] > 1) {
+ if (filterfds[1 - current][0] > 1)
+ {
close(filterfds[1 - current][0]);
filterfds[1 - current][0] = -1;
}
- if (filterfds[1 - current][1] > 1) {
+ if (filterfds[1 - current][1] > 1)
+ {
close(filterfds[1 - current][1]);
filterfds[1 - current][1] = -1;
}
- if (next) {
- if (pipe(filterfds[1 - current]) < 0) {
+ if (next)
+ {
+ if (pipe(filterfds[1 - current]) < 0)
+ {
if (log) log(ld, CF_LOGLEVEL_ERROR,
"cfFilterChain: Could not create pipe for output of %s: %s",
filter->name ? filter->name : "Unspecified filter",
}
fcntl_add_cloexec(filterfds[1 - current][0]);
fcntl_add_cloexec(filterfds[1 - current][1]);
- } else
+ }
+ else
filterfds[1 - current][1] = outputfd;
- if ((pid = fork()) == 0) {
+ if ((pid = fork()) == 0)
+ {
//
// Child process goes here...
//
filter->name ? filter->name : "Unspecified filter", ret);
exit(ret);
- } else if (pid > 0) {
+ }
+ else if (pid > 0)
+ {
if (log) log(ld, CF_LOGLEVEL_INFO,
"cfFilterChain: %s (PID %d) started.",
filter->name ? filter->name : "Unspecified filter", pid);
pid_entry->pid = pid;
pid_entry->name = filter->name ? filter->name : "Unspecified filter";
cupsArrayAdd(pids, pid_entry);
- } else {
+ }
+ else
+ {
if (log) log(ld, CF_LOGLEVEL_ERROR,
"cfFilterChain: Could not fork to start %s: %s",
filter->name ? filter->name : "Unspecified filter",
retval = 0;
- while (cupsArrayCount(pids) > 0) {
- if ((pid = wait(&status)) < 0) {
- if (errno == EINTR && iscanceled && iscanceled(icd)) {
+ while (cupsArrayCount(pids) > 0)
+ {
+ if ((pid = wait(&status)) < 0)
+ {
+ if (errno == EINTR && iscanceled && iscanceled(icd))
+ {
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"cfFilterChain: Job canceled, killing filters ...");
for (pid_entry = (filter_function_pid_t *)cupsArrayFirst(pids);
pid_entry;
- pid_entry = (filter_function_pid_t *)cupsArrayNext(pids)) {
+ pid_entry = (filter_function_pid_t *)cupsArrayNext(pids))
+ {
kill(pid_entry->pid, SIGTERM);
free(pid_entry);
}
break;
- } else
+ }
+ else
continue;
}
key.pid = pid;
if ((pid_entry = (filter_function_pid_t *)cupsArrayFind(pids, &key)) !=
- NULL) {
+ NULL)
+ {
cupsArrayRemove(pids, pid_entry);
- if (status) {
- if (WIFEXITED(status)) {
+ if (status)
+ {
+ if (WIFEXITED(status))
+ {
if (log) log(ld, CF_LOGLEVEL_ERROR,
"cfFilterChain: %s (PID %d) stopped with status %d",
pid_entry->name, pid, WEXITSTATUS(status));
- } else {
+ }
+ else
+ {
if (log) log(ld, CF_LOGLEVEL_ERROR,
"cfFilterChain: %s (PID %d) crashed on signal %d",
pid_entry->name, pid, WTERMSIG(status));
}
retval = 1;
- } else {
+ }
+ else
+ {
if (log) log(ld, CF_LOGLEVEL_INFO,
"cfFilterChain: %s (PID %d) exited with no errors.",
pid_entry->name, pid);
"cfFilterExternal (%s): Failed to connect input file descriptor with CUPS filter's stdin - %s",
filter_name, strerror(errno));
goto fd_error;
- } else
+ }
+ else
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"cfFilterExternal (%s): Connected input file descriptor %d to CUPS filter's stdin.",
filter_name, inputfd);
if (outputfd < 0)
outputfd = open("/dev/null", O_WRONLY);
- if (outputfd > 1) {
+ if (outputfd > 1)
+ {
fcntl_add_cloexec(outputfd);
dup2(outputfd, 1);
close(outputfd);
fcntl_add_cloexec(fd);
dup2(fd, 2);
close(fd);
- } else
+ }
+ else
close(fd);
}
else
{
dup2(sidefd, 4);
close(sidefd);
- } else
+ }
+ else
close(sidefd);
fcntl_add_nonblock(4);
}
fontname[iB ++] = fname[iA];
}
fontname[iB] = 0;
- } else
+ }
+ else
fontname[0] = 0;
if (!*fontname)
free(os2);
os2 = NULL;
}
- } else {
+ }
+ else
+ {
fprintf(stderr,"WARNING: no OS/2 table\n");
// e.g. Subsetted font from Ghostscript // e.g. CFF
}
_cfFontEmbedFontFileOpen(const char *filename)
{
// TODO? check magic
- if (...) {
+ if (...)
+ {
}
}
#endif // 0
mediapos = 7;
else
mediapos = 0;
- } else
+ }
+ else
mediapos = h->MediaPosition;
snprintf(tmpstr, sizeof(tmpstr), "-dMediaPosition=%d",
(unsigned)(mediapos));
goto out;
}
- } else
+ }
+ else
filename = NULL;
if (!inputseekable)
if (outformat == CF_FILTER_OUT_FORMAT_CUPS_RASTER ||
outformat == CF_FILTER_OUT_FORMAT_PWG_RASTER ||
outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER)
- if (write(outputfd, "RaS2", 4)) {};
+ if (write(outputfd, "RaS2", 4));
goto out;
}
if (doc_type == GS_DOC_TYPE_UNKNOWN)
if (outformat == CF_FILTER_OUT_FORMAT_CUPS_RASTER ||
outformat == CF_FILTER_OUT_FORMAT_PWG_RASTER ||
outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER)
- if (write(outputfd, "RaS2", 4)) {};
+ if (write(outputfd, "RaS2", 4));
goto out;
}
if (pages < 0)
if (outformat == CF_FILTER_OUT_FORMAT_CUPS_RASTER ||
outformat == CF_FILTER_OUT_FORMAT_PWG_RASTER ||
outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER)
- if (write(outputfd, "RaS2", 4)) {};
+ if (write(outputfd, "RaS2", 4));
goto out;
}
if (pagecount < 0)
// Copy input into temporary file if needed ...
//
- if (!inputseekable) {
+ if (!inputseekable)
+ {
if ((fd = cupsTempFd(tempfile, sizeof(tempfile))) < 0)
{
if (log) log(ld, CF_LOGLEVEL_ERROR,
// Because calculation error may be caused and
// result of ceil function may be larger than 1.
doc.xpages = doc.ypages = 1;
- } else {
+ }
+ else
+ {
doc.xpages = ceil(doc.xinches / doc.xprint);
doc.ypages = ceil(doc.yinches / doc.yprint);
}
doc.Collate = 0;
}
- if (((doc.xpages*doc.ypages) % 2) == 0) {
+ if (((doc.xpages*doc.ypages) % 2) == 0)
+ {
// even pages, disable EvenDuplex
doc.EvenDuplex = 0;
}
// Wait until we get a valid process ID or the job is canceled...
//
- while ((wait_pid = wait(&wait_status)) < 0 && errno == EINTR) {};
+ while ((wait_pid = wait(&wait_status)) < 0 && errno == EINTR);
if (wait_pid < 0)
break;
retval = 0; // Job attribute value out of range
}
}
- if (retval == 0) {
+ if (retval == 0)
+ {
// Use default value from printer attributes
snprintf(printer_attr_name, sizeof(printer_attr_name) - 1,
"%s-default", attr_name);
if ((attr = ippFindAttribute(printer_attrs, printer_attr_name,
- IPP_TAG_ZERO)) != NULL) {
+ IPP_TAG_ZERO)) != NULL)
+ {
retval = 1;
val = ippGetInteger(attr, 0);
}
// Next, find the decimal point...
//
- if (loc && loc->decimal_point) {
+ if (loc && loc->decimal_point)
+ {
dec = loc->decimal_point;
declen = (int)strlen(dec);
- } else {
+ }
+ else
+ {
dec = ".";
declen = 1;
}
// Copy everything up to the decimal point...
//
- if (tempdec) {
+ if (tempdec)
+ {
for (tempptr = temp, bufptr = buf;
tempptr < tempdec && bufptr < bufend;
*bufptr++ = *tempptr++);
tempptr += declen;
- if (*tempptr && bufptr < bufend) {
+ if (*tempptr && bufptr < bufend)
+ {
*bufptr++ = '.';
while (*tempptr && bufptr < bufend)
}
*bufptr = '\0';
- } else {
+ }
+ else
+ {
strlcpy(buf, temp, (size_t)(bufend - buf + 1));
bufptr = buf + strlen(buf);
}
*current_default = cfCopyResolution(*new_default, NULL);
}
retval = 1;
- } else
+ }
+ else
retval = 0;
finish:
i < count; i ++)
if (ippGetInteger(attr, i) < *custom_left)
*custom_left = ippGetInteger(attr, i);
- } else
+ }
+ else
*custom_left = 635;
if (custom_bottom == NULL)
i < count; i ++)
if (ippGetInteger(attr, i) < *custom_bottom)
*custom_bottom = ippGetInteger(attr, i);
- } else
+ }
+ else
*custom_bottom = 1270;
if (custom_right == NULL)
i < count; i ++)
if (ippGetInteger(attr, i) < *custom_right)
*custom_right = ippGetInteger(attr, i);
- } else
+ }
+ else
*custom_right = 635;
if (custom_top == NULL)
i < count; i ++)
if (ippGetInteger(attr, i) < *custom_top)
*custom_top = ippGetInteger(attr, i);
- } else
+ }
+ else
*custom_top = 1270;
if (mode != CF_GEN_SIZES_DEFAULT)
x = ippGetInteger(x_dim, 0);
y = ippGetInteger(y_dim, 0);
if (x > 0 && y > 0 &&
- (pwg = pwgMediaForSize(x, y)) != NULL) {
+ (pwg = pwgMediaForSize(x, y)) != NULL)
+ {
psname = (pwg->ppd != NULL ? pwg->ppd : pwg->pwg);
if (local_bottom == 0 && local_left == 0 &&
local_right == 0 && local_top == 0)
y_dim = ippFindAttribute(media_size, "y-dimension", IPP_TAG_ZERO);
// Move "if" for custom size parameters here
//if (ippGetValueTag(x_dim) == IPP_TAG_RANGE ||
- // ippGetValueTag(y_dim) == IPP_TAG_RANGE) {
+ // ippGetValueTag(y_dim) == IPP_TAG_RANGE)
+ //{
pwg = pwgMediaForSize(ippGetInteger(x_dim, 0),
ippGetInteger(y_dim, 0));
name = ippFindAttribute(media_col, "media-size-name",
pwg = pwgMediaForSize(ippGetInteger(x_dim, 0),
ippGetInteger(y_dim, 0));
- if (pwg) {
+ if (pwg)
+ {
if (!sizes && mode == CF_GEN_SIZES_DEFAULT)
continue;
snprintf(temp2->media + strlen(temp2->media),
sizeof(temp2->media) - strlen(temp2->media),
" %s", pwg_size);
- } else
+ }
+ else
cupsArrayAdd(*sizes, &temp);
}
}
val ++;
data_t::const_iterator it =
std::upper_bound(data.begin(), data.end(), std::make_pair(val, npos));
- if (it == data.begin()) {
+ if (it == data.begin())
+ {
if (it == data.end()) // empty
return (npos);
return (it->first);
_cfPDFToPDFIntervalSet::dump(pdftopdf_doc_t *doc) const // {{{
{
int len = data.size();
- if (len == 0) {
+ if (len == 0)
+ {
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
"cfFilterPDFToPDF: (empty)");
return;
}
len --;
- for (int iA = 0; iA < len; iA ++) {
+ for (int iA = 0; iA < len; iA ++)
+ {
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
"cfFilterPDFToPDF: [%d,%d)",
data[iA].first, data[iA].second);
}
- if (data[len].second == npos) {
+ if (data[len].second == npos)
+ {
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
"cfFilterPDFToPDF: [%d,inf)",
data[len].first);
- } else {
+ }
+ else
+ {
if (doc->logfunc) doc->logfunc(doc->logdata, CF_LOGLEVEL_DEBUG,
"cfFilterPDFToPDF: [%d,%d)",
data[len].first, data[len].second);
_cfPDFToPDFNupState::convert_order(int subpage) const // {{{
{
int subx, suby;
- if (param.first==pdftopdf_axis_e::X) {
+ if (param.first==pdftopdf_axis_e::X)
+ {
subx = subpage % param.nupX;
suby = subpage / param.nupX;
- } else {
+ }
+ else
+ {
subx = subpage / param.nupY;
suby = subpage % param.nupY;
}
param.copies_to_be_logged);
}
- if ((param.even_duplex || !param.odd_pages) && (outputno & 1)) {
+ if ((param.even_duplex || !param.odd_pages) && (outputno & 1))
+ {
// need to output empty page to not confuse duplex
proc.add_page(proc.new_page(param.page.width,
param.page.height, doc), param.reverse);
create_pdf_file(struct pdf_info * info,
const cf_filter_out_format_t &outformat)
{
- try {
+ try
+ {
info->pdf.emptyPDF();
info->outformat = outformat;
- } catch (...) {
+ }
+ catch (...)
+ {
return (1);
}
return (0);
bp_str[0] = '\0';
// Matrix
- if (!strcmp("/CalRGB", color_space) && matrix != NULL) {
+ if (!strcmp("/CalRGB", color_space) && matrix != NULL)
+ {
snprintf(matrix_str, sizeof(matrix_str),
"/Matrix [%g %g %g %g %g %g %g %g %g]",
matrix[0], matrix[1], matrix[2],
matrix[3], matrix[4], matrix[5],
matrix[6], matrix[7], matrix[8]);
- } else
+ }
+ else
matrix_str[0] = '\0';
// Write array string...
// for testing. Forces color management to enable.
if (outformat == CF_FILTER_OUT_FORMAT_PDF &&
(profile_name = cupsGetOption("profile", data->num_options,
- data->options)) != NULL) {
+ data->options)) != NULL)
+ {
set_profile(profile_name, &doc);
doc.cm_disabled = 0;
}
- if (doc.colorProfile != NULL)
+ if (doc.colorProfile != NULL)
if (log) log(ld, CF_LOGLEVEL_DEBUG,
"cfFilterPWGToPDF: TEST ICC Profile specified (color "
"management forced ON): \n[%s]", profile_name);
cfImageRGBToCMYK(src, dst, pixels);
// CMYK to KCMY
- for (unsigned int i = 0; i < pixels; i ++, bp += 3, dp += 4) {
+ for (unsigned int i = 0; i < pixels; i ++, bp += 3, dp += 4)
+ {
d = dp[3];
dp[3] = dp[2];
dp[2] = dp[1];
!strcasecmp(input_type, "urf") ||
!strcasecmp(input_type, "pwg-raster"))
{
- if (strcasecmp(output_type, "pdf")) {
+ if (strcasecmp(output_type, "pdf"))
+ {
if (strcasecmp(input_type, "vnd.cups-pdf"))
{
filter = malloc(sizeof(cf_filter_filter_in_chain_t));
out:
- if (ret) {
+ if (ret)
+ {
if (log) log(ld, CF_LOGLEVEL_ERROR,
"cfFilterUniversal: Unsupported combination of input and output formats: %s -> %s",
input, output);
// See if we a PPD database file...
//
- if (load_ppds_dat(filename, 0, &ppdlist, log, ld)) {
+ if (load_ppds_dat(filename, 0, &ppdlist, log, ld))
+ {
free_ppdlist(&ppdlist);
return(1);
}
close(efds[1]);
logfp = cupsFileOpenFd(efds[0], "r");
while (cupsFileGets(logfp, buf, sizeof(buf)))
- if (log) {
- if (strncmp(buf, "DEBUG: ", 7) == 0) {
+ if (log)
+ {
+ if (strncmp(buf, "DEBUG: ", 7) == 0)
+ {
log_level = CF_LOGLEVEL_DEBUG;
msg = buf + 7;
- } else if (strncmp(buf, "DEBUG2: ", 8) == 0) {
+ }
+ else if (strncmp(buf, "DEBUG2: ", 8) == 0)
+ {
log_level = CF_LOGLEVEL_DEBUG;
msg = buf + 8;
- } else if (strncmp(buf, "INFO: ", 6) == 0) {
+ }
+ else if (strncmp(buf, "INFO: ", 6) == 0)
+ {
log_level = CF_LOGLEVEL_INFO;
msg = buf + 6;
- } else if (strncmp(buf, "WARNING: ", 9) == 0) {
+ }
+ else if (strncmp(buf, "WARNING: ", 9) == 0)
+ {
log_level = CF_LOGLEVEL_WARN;
msg = buf + 9;
- } else if (strncmp(buf, "ERROR: ", 7) == 0) {
+ }
+ else if (strncmp(buf, "ERROR: ", 7) == 0)
+ {
log_level = CF_LOGLEVEL_ERROR;
msg = buf + 7;
- } else {
+ }
+ else
+ {
log_level = CF_LOGLEVEL_DEBUG;
msg = buf;
}
// Wait for the child process to exit...
//
- while (cpid > 0 || epid > 0) {
+ while (cpid > 0 || epid > 0)
+ {
if ((pid = wait(&wstatus)) < 0)
{
if (errno == EINTR)