Skip to content

Printing to a binary file doesn't work #250

@rjpontefract

Description

@rjpontefract

Looking at the code I see that the print files are opened as follows:

static void printer_open(unsigned val)
{
    switch(print_dest) {
        case PDEST_NONE:
            break;
        case PDEST_STDOUT:
            if (val) {
                print_fp = stdout;
                printer_outchar(val, print_fp);
            }
            break;
        case PDEST_FILE_TEXT:
            if (val)
                printer_open_file(val, "wt");
            break;
        case PDEST_FILE_BIN:
            printer_open_file(val, "rb");
            break;
        case PDEST_PIPE_TEXT:
            if (val)
                printer_open_pipe(val, "rt");
            break;
        case PDEST_PIPE_BIN:
            printer_open_pipe(val, "rb");
    }
}

I'm curious as to why the binary files and both pipes are opened in read mode. Should they all be opened in append mode which seems appropriate for a printer file?

Also what does the "t" mean in the mode string, it's not documented on either Linux or macOS as far as I can tell.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions