netatalk: print_cups.c File Reference

netatalk 4.5.1
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
print_cups.c File Reference
`#include <ctype.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <unistd.h>`
`#include <sys/types.h>`
`#include <sys/param.h>`
`#include <errno.h>`
`#include <cups/ipp.h>`
`#include <cups/cups.h>`
`#include <cups/language.h>`
`#include <atalk/unicode.h>`
`#include <atalk/logger.h>`
`#include <atalk/atp.h>`
`#include <atalk/pap.h>`
`#include <atalk/util.h>`
`#include "printer.h"`
`#include "print_cups.h"`

## Macros
#define | MAXCHOOSERLEN 31

## Functions
static int | convert_to_mac_name (const char *encoding, char *inptr, char *outptr, size_t outlen)
| Convert to Mac printer name.
static size_t | to_ascii (char *inbuf, char **outbuf)
static int | cups_mangle_printer_name (struct printer *pr, struct printer *printers)
| Mangles the printer name if two CUPS printer provide the same Chooser Name.
static void | cups_free_printer (struct printer *pr)
const char * | cups_get_language (void)
static const char * | cups_passwd_cb (const char *prompt, http_t *http, const char *method, const char *resource, void *user_data)
| The CUPS password callback...
int | cups_printername_ok (char *name)
| Verify supplied printer name is a valid cups printer.
const char * | cups_get_printer_ppd (char *name)
int | cups_get_printer_status (struct printer *pr)
int | cups_print_job (char *name, const char *filename, char *job, char *username, char *cupsoptions)
struct printer * | cups_autoadd_printers (struct printer *defprinter, struct printer *printers)
int | cups_check_printer (struct printer *pr, struct printer *printers, int replace)
| check if a printer with this name already exists.

## Variables
static const char * | cups_status_msg []

## Macro Definition Documentation

## ◆ MAXCHOOSERLEN

#define MAXCHOOSERLEN 31

## Function Documentation

## ◆ convert_to_mac_name()

int convert_to_mac_name | ( | const char * | encoding,
|  | char * | inptr,
|  | char * | outptr,
|  | size_t | outlen )
| static

Convert to Mac printer name.

Note
  1) Convert from encoding to MacRoman
  2) Shorten to MAXCHOOSERLEN (31)
  3) Replace @ and _ as they are illegal

Returns
  -1 on failure, length of name on success; outpr contains name in MacRoman

## ◆ cups_autoadd_printers()

struct printer * cups_autoadd_printers | ( | struct printer * | defprinter,
|  | struct printer * | printers )

## ◆ cups_check_printer()

int cups_check_printer | ( | struct printer * | pr,
|  | struct printer * | printers,
|  | int | replace )

check if a printer with this name already exists.

Note
  if yes, and replace = 1 the existing printer is replaced with the new one. This allows to overwrite printer settings
  created by cupsautoadd. It also used by cups_mangle_printer.

## ◆ cups_free_printer()

void cups_free_printer | ( | struct printer * | pr | ) |
| static

## ◆ cups_get_language()

const char * cups_get_language | ( | void |  | ) |

## ◆ cups_get_printer_ppd()

const char * cups_get_printer_ppd | ( | char * | name | ) |

## ◆ cups_get_printer_status()

int cups_get_printer_status | ( | struct printer * | pr | ) |

## ◆ cups_mangle_printer_name()

int cups_mangle_printer_name | ( | struct printer * | pr,
|  | struct printer * | printers )
| static

Mangles the printer name if two CUPS printer provide the same Chooser Name.

Note
  Append 'nn' to the chooser name, if it is longer than 28 char we overwrite the last three chars

Returns
  0 on Success, 2 on Error

## ◆ cups_passwd_cb()

const char * cups_passwd_cb | ( | const char * | prompt,
|  | http_t * | http,
|  | const char * | method,
|  | const char * | resource,
|  | void * | user_data )
| static

The CUPS password callback...

Note
  O - Password or NULL
  I - Prompt

Returns
  NULL (not implemented)

## ◆ cups_print_job()

int cups_print_job | ( | char * | name,
|  | const char * | filename,
|  | char * | job,
|  | char * | username,
|  | char * | cupsoptions )

pass the job to cups

## ◆ cups_printername_ok()

int cups_printername_ok | ( | char * | name | ) |

Verify supplied printer name is a valid cups printer.

Note
  O - 1 if printer name OK
  I - Name of printer

## ◆ to_ascii()

size_t to_ascii | ( | char * | inptr,
|  | char ** | outptr )
| static

fallback ASCII conversion

## Variable Documentation

## ◆ cups_status_msg

const char* cups_status_msg[]
| static

Initial value:
= {
"status: busy; info: \"%s\" is rejecting jobs; ",
"status: idle; info: \"%s\" is stopped, accepting jobs ; ",
"status: idle; info: \"%s\" is ready ; ",
"status: busy; info: \"%s\" is processing a job ; ",
}