1{ 2 ***************************************************************************** 3 This file is part of the Printer4Lazarus package 4 5 See the file COPYING.modifiedLGPL.txt, included in this distribution, 6 for details about the license. 7 ***************************************************************************** 8 9 Author: Olivier GUILBAUD 10 11 Abstract: 12 This code provide an interface with Common UNIX Printing System (CUPS). 13 it is based on cups.h version 1.47 14 This code is tested with the 1.1.19 of CUPS 15 16 link: 17 http://www.cups.org 18 http://localhost:631/spm.html (for documentation) 19 20 See : /usr/share/doc/cups/licence.txt 21 22 Required 23 CUPS 1.1.19 or more 24 libCUPS 25 26 History 27 sept 14 2003 - Create 28 nov 04 2003 - First release 29 mars 08 2005 - Dynamique link lib by Jesus Reyes (big thanks) 30 - Some modifications for work with Mdk 10.1 31 nov 26 2017 - Moved to directory packages/libcups/ under FPC 3.1.1 sources. 32 Can be removed from Lazarus sources when FPC 3.2.0 is the minimum requirement. 33------------------------------------------------------------------------------} 34unit cupsdyn; 35 36{$mode objfpc}{$H+} 37{.$define UseLibC} 38interface 39 40 41uses 42 Classes, SysUtils, dynlibs, 43 {$ifdef UseLibC} 44 {$IFDEF darwin} 45 miniCupsLibc 46 {$ELSE} 47 Libc 48 {$ENDIF} 49 {$else} 50 baseunix, unix, sockets 51 {$endif} 52 ; 53 54{$PACKRECORDS C} 55 56{.$LINKLIB ssl} 57{.$LINKLIB crypto} 58{.$LINKLIB nsl} 59 60{$ifndef UseLibC} 61type 62 sockaddr_in = TSockAddr; 63 pfd_set = PFDSet; 64 PFILE = pointer; 65{$endif} 66 67// 68// 69// CUPS_language types & consts 70// 71// 72type 73 //Message Indices 74 cups_msg_t=( 75 CUPS_MSG_OK, 76 CUPS_MSG_CANCEL, 77 CUPS_MSG_HELP, 78 CUPS_MSG_QUIT, 79 CUPS_MSG_CLOSE, 80 CUPS_MSG_YES, 81 CUPS_MSG_NO, 82 CUPS_MSG_ON, 83 CUPS_MSG_OFF, 84 CUPS_MSG_SAVE, 85 CUPS_MSG_DISCARD, 86 CUPS_MSG_DEFAULT, 87 CUPS_MSG_OPTIONS, 88 CUPS_MSG_MORE_INFO, 89 CUPS_MSG_BLACK, 90 CUPS_MSG_COLOR, 91 CUPS_MSG_CYAN, 92 CUPS_MSG_MAGENTA, 93 CUPS_MSG_YELLOW, 94 CUPS_MSG_COPYRIGHT, 95 CUPS_MSG_GENERAL, 96 CUPS_MSG_PRINTER, 97 CUPS_MSG_IMAGE, 98 CUPS_MSG_HPGL2, 99 CUPS_MSG_EXTRA, 100 CUPS_MSG_DOCUMENT, 101 CUPS_MSG_OTHER, 102 CUPS_MSG_PRINT_PAGES, 103 CUPS_MSG_ENTIRE_DOCUMENT, 104 CUPS_MSG_PAGE_RANGE, 105 CUPS_MSG_REVERSE_ORDER, 106 CUPS_MSG_PAGE_FORMAT, 107 CUPS_MSG_1_UP, 108 CUPS_MSG_2_UP, 109 CUPS_MSG_4_UP, 110 CUPS_MSG_IMAGE_SCALING, 111 CUPS_MSG_USE_NATURAL_IMAGE_SIZE, 112 CUPS_MSG_ZOOM_BY_PERCENT, 113 CUPS_MSG_ZOOM_BY_PPI, 114 CUPS_MSG_MIRROR_IMAGE, 115 CUPS_MSG_COLOR_SATURATION, 116 CUPS_MSG_COLOR_HUE, 117 CUPS_MSG_FIT_TO_PAGE, 118 CUPS_MSG_SHADING, 119 CUPS_MSG_DEFAULT_PEN_WIDTH, 120 CUPS_MSG_GAMMA_CORRECTION, 121 CUPS_MSG_BRIGHTNESS, 122 CUPS_MSG_ADD, 123 CUPS_MSG_DELETE, 124 CUPS_MSG_MODIFY, 125 CUPS_MSG_PRINTER_URI, 126 CUPS_MSG_PRINTER_NAME, 127 CUPS_MSG_PRINTER_LOCATION, 128 CUPS_MSG_PRINTER_INFO, 129 CUPS_MSG_PRINTER_MAKE_AND_MODEL, 130 CUPS_MSG_DEVICE_URI, 131 CUPS_MSG_FORMATTING_PAGE, 132 CUPS_MSG_PRINTING_PAGE, 133 CUPS_MSG_INITIALIZING_PRINTER, 134 CUPS_MSG_PRINTER_STATE, 135 CUPS_MSG_ACCEPTING_JOBS, 136 CUPS_MSG_NOT_ACCEPTING_JOBS, 137 CUPS_MSG_PRINT_JOBS, 138 CUPS_MSG_CLASS, 139 CUPS_MSG_LOCAL, 140 CUPS_MSG_REMOTE, 141 CUPS_MSG_DUPLEXING, 142 CUPS_MSG_STAPLING, 143 CUPS_MSG_FAST_COPIES, 144 CUPS_MSG_COLLATED_COPIES, 145 CUPS_MSG_PUNCHING, 146 CUPS_MSG_COVERING, 147 CUPS_MSG_BINDING, 148 CUPS_MSG_SORTING, 149 CUPS_MSG_SMALL, 150 CUPS_MSG_MEDIUM, 151 CUPS_MSG_LARGE, 152 CUPS_MSG_VARIABLE, 153 CUPS_MSG_IDLE, 154 CUPS_MSG_PROCESSING, 155 CUPS_MSG_STOPPED, 156 CUPS_MSG_ALL, 157 CUPS_MSG_ODD, 158 CUPS_MSG_EVEN_PAGES, 159 CUPS_MSG_DARKER_LIGHTER, 160 CUPS_MSG_MEDIA_SIZE, 161 CUPS_MSG_MEDIA_TYPE, 162 CUPS_MSG_MEDIA_SOURCE, 163 CUPS_MSG_ORIENTATION, 164 CUPS_MSG_PORTRAIT, 165 CUPS_MSG_LANDSCAPE, 166 CUPS_MSG_JOB_STATE, 167 CUPS_MSG_JOB_NAME, 168 CUPS_MSG_USER_NAME, 169 CUPS_MSG_PRIORITY, 170 CUPS_MSG_COPIES, 171 CUPS_MSG_FILE_SIZE, 172 CUPS_MSG_PENDING, 173 CUPS_MSG_OUTPUT_MODE, 174 CUPS_MSG_RESOLUTION, 175 CUPS_MSG_TEXT, 176 CUPS_MSG_PRETTYPRINT, 177 CUPS_MSG_MARGINS, 178 CUPS_MSG_LEFT, 179 CUPS_MSG_RIGHT, 180 CUPS_MSG_BOTTOM, 181 CUPS_MSG_TOP, 182 CUPS_MSG_FILENAME, 183 CUPS_MSG_PRINT, 184 CUPS_MSG_OPTIONS_INSTALLED, 185 CUPS_MSG_AUTO, 186 CUPS_MSG_HTTP_BASE:= 200, 187 CUPS_MSG_HTTP_END := 505, 188 CUPS_MSG_MAX 189 ); 190 191 //Language Encodings 192 cups_encoding_t=( 193 CUPS_US_ASCII, 194 CUPS_ISO8859_1, 195 CUPS_ISO8859_2, 196 CUPS_ISO8859_3, 197 CUPS_ISO8859_4, 198 CUPS_ISO8859_5, 199 CUPS_ISO8859_6, 200 CUPS_ISO8859_7, 201 CUPS_ISO8859_8, 202 CUPS_ISO8859_9, 203 CUPS_ISO8859_10, 204 CUPS_UTF8, 205 CUPS_ISO8859_13, 206 CUPS_ISO8859_14, 207 CUPS_ISO8859_15, 208 CUPS_WINDOWS_874, 209 CUPS_WINDOWS_1250, 210 CUPS_WINDOWS_1251, 211 CUPS_WINDOWS_1252, 212 CUPS_WINDOWS_1253, 213 CUPS_WINDOWS_1254, 214 CUPS_WINDOWS_1255, 215 CUPS_WINDOWS_1256, 216 CUPS_WINDOWS_1257, 217 CUPS_WINDOWS_1258, 218 CUPS_KOI8_R, 219 CUPS_KOI8_U 220 ); 221 222 Pcups_lang_str=^cups_lang_str; 223 cups_lang_str = record 224 next : Pcups_lang_str; //Next language in cache 225 used : longint; //Number of times this entry has been used 226 encoding : cups_encoding_t; //Text encoding 227 language : array[0..15] of char; //Language/locale name 228 messages : array[0..Ord(CUPS_MSG_MAX)-1] of Pchar; //Message array 229 end; 230 cups_lang_t = cups_lang_str; 231 Pcups_lang_t=^cups_lang_t; 232 233 234// 235// 236// CUPS_HTTP types & consts 237// 238// 239const 240 HTTP_MAX_URI = 1024; //Max length of URI string 241 HTTP_MAX_HOST = 256; //Max length of hostname string 242 HTTP_MAX_BUFFER = 2048; //Max length of data buffer 243 HTTP_MAX_VALUE = 256; //Max header field value length 244 245type 246 //---------------------------------------------------------------------------- 247 // md5.h 248 //---------------------------------------------------------------------------- 249 Pmd5_byte_t=^md5_byte_t; 250 md5_byte_t = byte; //8-bit byte 251 md5_word_t=dword; //32-bit word 252 253 //Define the state of the MD5 Algorithm. 254 md5_state_s = record 255 count : array[0..1] of md5_word_t; //message length in bits, lsw first 256 abcd : array[0..3] of md5_word_t; //digest buffer 257 buf : array[0..63] of md5_byte_t;//accumulate block 258 end; 259 md5_state_t = md5_state_s; 260 {-----------------------------------------------------------------------------} 261 262 //States are server-oriented 263 http_state_t=( 264 HTTP_WAITING, //Waiting for command 265 HTTP_OPTIONS, //OPTIONS command, waiting for blank line 266 HTTP_GET, //GET command, waiting for blank line 267 HTTP_GET_SEND, //GET command, sending data 268 HTTP_HEAD, //HEAD command, waiting for blank line 269 HTTP_POST, //POST command, waiting for blank line 270 HTTP_POST_RECV, //POST command, receiving data 271 HTTP_POST_SEND, //POST command, sending data 272 HTTP_PUT, //PUT command, waiting for blank line 273 HTTP_PUT_RECV, //PUT command, receiving data 274 HTTP_DELETE, //DELETE command, waiting for blank line 275 HTTP_TRACE, //TRACE command, waiting for blank line 276 HTTP_CLOSE, //CLOSE command, waiting for blank line 277 HTTP_STATUS //Command complete, sending status 278 ); 279 280 //HTTP version numbers... 281 http_version_t=( 282 HTTP_0_9 := 9, //HTTP/0.9 283 HTTP_1_0 := 100, //HTTP/1.0 284 HTTP_1_1 := 101 //HTTP/1.1 285 ); 286 287 //HTTP keep-alive values... 288 http_keepalive_t=( 289 HTTP_KEEPALIVE_OFF := 0, 290 HTTP_KEEPALIVE_ON 291 ); 292 293 //HTTP transfer encoding values... 294 http_encoding_t=( 295 HTTP_ENCODE_LENGTH, //Data is sent with Content-Length 296 HTTP_ENCODE_CHUNKED //Data is chunked 297 ); 298 299 //HTTP encryption values... 300 http_encryption_t=( 301 HTTP_ENCRYPT_IF_REQUESTED, //Encrypt if requested (TLS upgrade) 302 HTTP_ENCRYPT_NEVER, //Never encrypt 303 HTTP_ENCRYPT_REQUIRED, //Encryption is required (TLS upgrade) 304 HTTP_ENCRYPT_ALWAYS //Always encrypt (SSL) 305 ); 306 307 //HTTP authentication types... 308 http_auth_t=( 309 HTTP_AUTH_NONE, //No authentication in use 310 HTTP_AUTH_BASIC, //Basic authentication in use 311 HTTP_AUTH_MD5, //Digest authentication in use 312 HTTP_AUTH_MD5_SESS, //MD5-session authentication in use 313 HTTP_AUTH_MD5_INT, //Digest authentication in use for body 314 HTTP_AUTH_MD5_SESS_INT //MD5-session authentication in use for body 315 ); 316 317 //HTTP status codes... 318 http_status_t=( 319 HTTP_ERROR := -1, //An error response from httpXxxx() */ 320 321 HTTP_CONTINUE := 100, //Everything OK, keep going... */ 322 HTTP_SWITCHING_PROTOCOLS, //HTTP upgrade to TLS/SSL */ 323 324 HTTP_OK := 200, //OPTIONS/GET/HEAD/POST/TRACE command was successful */ 325 HTTP_CREATED, //PUT command was successful */ 326 HTTP_ACCEPTED, //DELETE command was successful */ 327 HTTP_NOT_AUTHORITATIVE, //Information isn't authoritative */ 328 HTTP_NO_CONTENT, //Successful command, no new data */ 329 HTTP_RESET_CONTENT, //Content was reset/recreated */ 330 HTTP_PARTIAL_CONTENT, //Only a partial file was recieved/sent */ 331 332 HTTP_MULTIPLE_CHOICES:=300, //Multiple files match request */ 333 HTTP_MOVED_PERMANENTLY, //Document has moved permanently */ 334 HTTP_MOVED_TEMPORARILY, //Document has moved temporarily */ 335 HTTP_SEE_OTHER, //See this other link... */ 336 HTTP_NOT_MODIFIED, //File not modified */ 337 HTTP_USE_PROXY, //Must use a proxy to access this URI */ 338 339 HTTP_BAD_REQUEST := 400, //Bad request */ 340 HTTP_UNAUTHORIZED, //Unauthorized to access host */ 341 HTTP_PAYMENT_REQUIRED, //Payment required */ 342 HTTP_FORBIDDEN, //Forbidden to access this URI */ 343 HTTP_NOT_FOUND, //URI was not found */ 344 HTTP_METHOD_NOT_ALLOWED, //Method is not allowed */ 345 HTTP_NOT_ACCEPTABLE, //Not Acceptable */ 346 HTTP_PROXY_AUTHENTICATION, //Proxy Authentication is Required */ 347 HTTP_REQUEST_TIMEOUT, //Request timed out */ 348 HTTP_CONFLICT, //Request is self-conflicting */ 349 HTTP_GONE, //Server has gone away */ 350 HTTP_LENGTH_REQUIRED, //A content length or encoding is required */ 351 HTTP_PRECONDITION, //Precondition failed */ 352 HTTP_REQUEST_TOO_LARGE, //Request entity too large */ 353 HTTP_URI_TOO_LONG, //URI too long */ 354 HTTP_UNSUPPORTED_MEDIATYPE, //The requested media type is unsupported */ 355 HTTP_UPGRADE_REQUIRED:= 426,//Upgrade to SSL/TLS required */ 356 357 HTTP_SERVER_ERROR := 500, //Internal server error */ 358 HTTP_NOT_IMPLEMENTED, //Feature not implemented */ 359 HTTP_BAD_GATEWAY, //Bad gateway */ 360 HTTP_SERVICE_UNAVAILABLE, //Service is unavailable */ 361 HTTP_GATEWAY_TIMEOUT, //Gateway connection timed out */ 362 HTTP_NOT_SUPPORTED //HTTP version not supported */ 363 ); 364 365 //HTTP field names... 366 http_field_t=( 367 HTTP_FIELD_UNKNOWN := -1, 368 HTTP_FIELD_ACCEPT_LANGUAGE, 369 HTTP_FIELD_ACCEPT_RANGES, 370 HTTP_FIELD_AUTHORIZATION, 371 HTTP_FIELD_CONNECTION, 372 HTTP_FIELD_CONTENT_ENCODING, 373 HTTP_FIELD_CONTENT_LANGUAGE, 374 HTTP_FIELD_CONTENT_LENGTH, 375 HTTP_FIELD_CONTENT_LOCATION, 376 HTTP_FIELD_CONTENT_MD5, 377 HTTP_FIELD_CONTENT_RANGE, 378 HTTP_FIELD_CONTENT_TYPE, 379 HTTP_FIELD_CONTENT_VERSION, 380 HTTP_FIELD_DATE, 381 HTTP_FIELD_HOST, 382 HTTP_FIELD_IF_MODIFIED_SINCE, 383 HTTP_FIELD_IF_UNMODIFIED_SINCE, 384 HTTP_FIELD_KEEP_ALIVE, 385 HTTP_FIELD_LAST_MODIFIED, 386 HTTP_FIELD_LINK, 387 HTTP_FIELD_LOCATION, 388 HTTP_FIELD_RANGE, 389 HTTP_FIELD_REFERER, 390 HTTP_FIELD_RETRY_AFTER, 391 HTTP_FIELD_TRANSFER_ENCODING, 392 HTTP_FIELD_UPGRADE, 393 HTTP_FIELD_USER_AGENT, 394 HTTP_FIELD_WWW_AUTHENTICATE, 395 HTTP_FIELD_MAX 396 ); 397 398 Phttp_t=^http_t; 399 http_t=record 400 fd : longint; //File descriptor for this socket 401 blocking : longint; //To block or not to block 402 error : longint; //Last error on read 403 activity : time_t; //Time since last read/write 404 state : http_state_t; //State of client 405 status : http_status_t; //Status of last request 406 version : http_version_t;//Protocol version 407 keep_alive : http_keepalive_t; //Keep-alive supported? 408 hostaddr : sockaddr_in; //Address of connected host 409 hostname : array[0..(HTTP_MAX_HOST)-1] of char; //Name of connected host 410 fields : array[0..Ord(HTTP_FIELD_MAX)-1] of array[0..(HTTP_MAX_VALUE)-1] of char; //Field values 411 data : ^char; //Pointer to data buffer 412 data_encoding : http_encoding_t; //Chunked or not 413 data_remaining : longint; //Number of bytes left 414 used : longint; //Number of bytes used in buffer 415 buffer : array[0..(HTTP_MAX_BUFFER)-1] of char; //Buffer for messages 416 auth_type : longint; //Authentication in use 417 md5_state : md5_state_t; //MD5 state 418 nonce : array[0..(HTTP_MAX_VALUE)-1] of char; //Nonce value 419 nonce_count : longint; //Nonce count 420 tls : pointer; //TLS state information 421 encryption : http_encryption_t; //Encryption requirements 422 input_set : Pfd_set; //select() set for httpWait() 423 end; 424 TArrayChar32=array[0..32] of char; 425 426 427// 428// 429// cups_ppd types and consts 430// 431// 432const 433 //PPD size limits (defined in Adobe spec 434 PPD_MAX_NAME = 41; //Maximum size of name + 1 for nul 435 PPD_MAX_TEXT = 81; //Maximum size of text + 1 for nul 436 PPD_MAX_LINE = 256; //Maximum size of line + 1 for nul 437 PPD_VERSION = '4.3'; //Kept in sync with Adobe version number 438 439Type 440 //UI types ... 441 ppd_ui_t=( 442 PPD_UI_BOOLEAN, //True or False option 443 PPD_UI_PICKONE, //Pick one from a list 444 PPD_UI_PICKMANY //Pick zero or more from a list 445 ); 446 447 //Order dependency sections 448 ppd_section_t=( 449 PPD_ORDER_ANY, //Option code can be anywhere in the file 450 PPD_ORDER_DOCUMENT, //... must be in the DocumentSetup section 451 PPD_ORDER_EXIT, //... must be sent prior to the document 452 PPD_ORDER_JCL, //... must be sent as a JCL command 453 PPD_ORDER_PAGE, //... must be in the PageSetup section 454 PPD_ORDER_PROLOG //... must be in the Prolog section 455 ); 456 457 //Colorspaces 458 ppd_cs_t=( 459 PPD_CS_CMYK := -4, //CMYK colorspace 460 PPD_CS_CMY, //CMY colorspace 461 PPD_CS_GRAY := 1, //Grayscale colorspace 462 PPD_CS_RGB := 3, //RGB colorspace 463 PPD_CS_RGBK, //RGBK (K = gray) colorspace 464 PPD_CS_N //DeviceN colorspace 465 ); 466 467 //Status Codes 468 ppd_status_t=( 469 PPD_OK := 0, //OK 470 PPD_FILE_OPEN_ERROR, //Unable to open PPD file 471 PPD_NULL_FILE, //NULL PPD file pointer 472 PPD_ALLOC_ERROR, //Memory allocation error 473 PPD_MISSING_PPDADOBE4, //Missing PPD-Adobe-4.x header 474 PPD_MISSING_VALUE, //Missing value string 475 PPD_INTERNAL_ERROR, //Internal error 476 PPD_BAD_OPEN_GROUP, //Bad OpenGroup 477 PPD_NESTED_OPEN_GROUP, //openGroup without a CloseGroup first 478 PPD_BAD_OPEN_UI, //Bad OpenUI/JCLOpenUI 479 PPD_NESTED_OPEN_UI, //OpenUI/JCLOpenUI without a CloseUI/JCLCloseUI first 480 PPD_BAD_ORDER_DEPENDENCY, //Bad OrderDependency 481 PPD_BAD_UI_CONSTRAINTS, //Bad UIConstraints 482 PPD_MISSING_ASTERISK, //Missing asterisk in column 0 483 PPD_LINE_TOO_LONG, //Line longer than 255 chars 484 PPD_ILLEGAL_CHARACTER, //Illegal control character 485 PPD_ILLEGAL_MAIN_KEYWORD, //Illegal main keyword string 486 PPD_ILLEGAL_OPTION_KEYWORD, //Illegal option keyword string 487 PPD_ILLEGAL_TRANSLATION //Illegal translation string 488 ); 489 490 //PPD Attribute Structure 491 Pppd_attr_t =^ppd_attr_t; 492 PPppd_attr_t =^Pppd_attr_t; 493 ppd_attr_t = record 494 name : array[0..(PPD_MAX_NAME)-1] of char; //Name of attribute (cupsXYZ) 495 spec : array[0..(PPD_MAX_NAME + PPD_MAX_TEXT)-1] of char; //Specifier string, if any 496 value: Pchar; //Value string 497 end; 498 499 //Option choices 500 Pppd_choice_t=^ppd_choice_t; 501 PPppd_choice_t=^Pppd_choice_t; 502 PPPppd_choice_t=^PPppd_choice_t; 503 ppd_choice_t = record 504 marked : Char; //0 if not selected, 1 otherwise 505 choice : Array[0..(PPD_MAX_NAME)-1] of char;//Computer-readable option name 506 text : Array[0..(PPD_MAX_TEXT)-1] of char;//Human-readable option name 507 code : Pchar; //Code to send for this option 508 option : Pointer; //Pointer to parent option structure 509 end; 510 511 //Options 512 Pppd_option_t=^ppd_option_t; 513 ppd_option_t = record 514 conflicted : char; //0 if no conflicts exist, 1 otherwise 515 keyword : array[0..(PPD_MAX_NAME)-1] of char;//Option keyword name ("PageSize", etc.) 516 defchoice : array[0..(PPD_MAX_NAME)-1] of char;//Default option choice 517 text : array[0..(PPD_MAX_TEXT)-1] of char;//Human-readable text 518 ui : ppd_ui_t; //Type of UI option 519 section : ppd_section_t; //Section for command 520 order : integer; //Order number 521 num_choices: LongInt; //Number of option choices 522 choices : Pppd_choice_t; //Option choices 523 end; 524 525 //Groups 526 {Group text strings are limited to 39 chars + nul in order to 527 preserve binary compatibility and allow applications to get 528 the group's keyword name. } 529 Pppd_group_str=^ppd_group_str; 530 ppd_group_str = record 531 text : array[0..(PPD_MAX_TEXT - PPD_MAX_NAME)-1] of char; //Human-readable group name 532 name : array[0..(PPD_MAX_NAME)-1] of char; //Group name 533 num_options : longint; //Number of options 534 options : Pppd_option_t; //Options 535 num_subgroups : longint; //Number of sub-groups 536 subgroups : Pppd_group_str; //Sub-groups (max depth = 1) 537 end; 538 ppd_group_t = ppd_group_str; 539 Pppd_group_t= ^ppd_group_t; 540 541 //Constraints 542 Pppd_const_t=^ppd_const_t; 543 ppd_const_t = record 544 option1 : array[0..(PPD_MAX_NAME)-1] of char; //First keyword 545 choice1 : array[0..(PPD_MAX_NAME)-1] of char; //First option/choice (blank for all) 546 option2 : array[0..(PPD_MAX_NAME)-1] of char; //Second keyword 547 choice2 : array[0..(PPD_MAX_NAME)-1] of char; //Second option/choice (blank for all) 548 end; 549 550 //Page Sizes 551 Pppd_size_t=^ppd_size_t; 552 ppd_size_t = record 553 marked : LongInt; //Page size selected? 554 name : array[0..(PPD_MAX_NAME)-1] of char; //Media size option 555 width : single; //Width of media in points 556 length : single; //Length of media in points 557 left : single; //Left printable margin in points 558 bottom : single; //Bottom printable margin in points 559 right : single; //Right printable margin in points 560 top : single; //Top printable margin in points 561 end; 562 563 //Emulators 564 Pppd_emul_t=^ppd_emul_t; 565 ppd_emul_t = record 566 name : array[0..(PPD_MAX_NAME)-1] of char; //Emulator name 567 start: Pchar; //Code to switch to this emulation 568 stop : Pchar; //Code to stop this emulation 569 end; 570 571 //sRGB Color Profiles 572 Pppd_profile_t=^ppd_profile_t; 573 ppd_profile_t = record 574 resolution : array[0..(PPD_MAX_NAME)-1] of char; //Resolution or "-" 575 media_type : array[0..(PPD_MAX_NAME)-1] of char; //Media type of "-" 576 density : single; //Ink density to use 577 gamma : single; //Gamma correction to use 578 matrix : array[0..2] of array[0..2] of single; //Transform matrix 579 end; 580 581 //Files 582 Pppd_file_t=^ppd_file_t; 583 ppd_file_t = record 584 language_level : longint; //Language level of device 585 color_device : longint; //1=color device, 0=grayscale 586 variable_sizes : longint; //1 = supports variable sizes, 0 = doesn't 587 accurate_screens : longint; //1 = supports accurate screens, 0 = not 588 contone_only : longint; //1 = continuous tone only, 0 = not 589 landscape : longint; //-90 or 90 590 model_number : longint; //Device-specific model number 591 manual_copies : longint; //1 = Copies done manually, 0 = hardware 592 throughput : longint; //Pages per minute 593 colorspace : ppd_cs_t; //Default colorspace 594 patches : Pchar; //Patch commands to be sent to printer 595 num_emulations : longint; //Number of emulations supported 596 emulations : Pppd_emul_t; //Emulations and the code to invoke them 597 jcl_begin : Pchar; //Start JCL commands 598 jcl_ps : Pchar; //Enter PostScript interpreter 599 jcl_end : Pchar; //End JCL commands 600 lang_encoding : Pchar; //Language encoding 601 lang_version : Pchar; //Language version (English, Spanish, etc.) 602 modelname : Pchar; //Model name (general) 603 ttrasterizer : Pchar; //Truetype rasterizer 604 manufacturer : Pchar; //Manufacturer name 605 product : Pchar; //Product name (from PS RIP/interpreter) 606 nickname : Pchar; //Nickname (specific) 607 shortnickname : Pchar; //Short version of nickname 608 num_groups : longint; //Number of UI groups 609 groups : Pppd_group_t; //UI groups 610 num_sizes : longint; //Number of page sizes 611 sizes : Pppd_size_t; //Page sizes 612 custom_min : array[0..1] of single; //Minimum variable page size 613 custom_max : array[0..1] of single; //Maximum variable page size 614 custom_margins : array[0..3] of single; //Margins around page 615 num_consts : longint; //Number of UI/Non-UI constraints 616 consts : Pppd_const_t; //UI/Non-UI constraints 617 num_fonts : longint; //Number of pre-loaded fonts 618 fonts : PPchar; //Pre-loaded fonts 619 num_profiles : longint; //Number of sRGB color profiles 620 profiles : Pppd_profile_t; //sRGB color profiles 621 num_filters : longint; //Number of filters 622 filters : PPchar; //Filter strings... 623 flip_duplex : longint; //1 = Flip page for back sides (New in CUPS 1.1) 624 protocols : Pchar; //Protocols (BCP, TBCP) string (New in CUPS 1.1.19) 625 pcfilename : Pchar; //PCFileName string 626 num_attrs : longint; //Number of attributes 627 cur_attr : longint; //Current attribute 628 attrs : PPppd_attr_t; //Attributes 629 end; 630 631// 632// 633// cups_ipp types and consts 634// 635// 636const 637 IPP_VERSION = #1#1; 638 { IPP registered port number... This is the default value - applications 639 should use the ippPort() function so that you can customize things in 640 /etc/services if needed!} 641 IPP_PORT = 631; 642 IPP_MAX_NAME = 256; //Common limits... 643 IPP_MAX_VALUES = 10; //Now just an allocation increment 644 645Type 646 //Job States.... 647 ipp_jstate_t = (IPP_JOB_PENDING := 3, 648 IPP_JOB_HELD, 649 IPP_JOB_PROCESSING, 650 IPP_JOB_STOPPED, 651 IPP_JOB_CANCELLED, 652 IPP_JOB_ABORTED, 653 IPP_JOB_COMPLETED); 654 //Qualities... 655 ipp_quality_t= (IPP_QUALITY_DRAFT := 3, 656 IPP_QUALITY_NORMAL, 657 IPP_QUALITY_HIGH); 658 659 //Orientation... 660 ipp_orient_t = (IPP_PORTRAIT := 3, //No rotation 661 IPP_LANDSCAPE, //90 degrees counter-clockwise 662 IPP_REVERSE_LANDSCAPE, //90 degrees clockwise 663 IPP_REVERSE_PORTRAIT); //180 degrees 664 665 {Format tags for attribute formats... 666 Mask for copied attribute values 667 Bitflag for copied attribute values } 668 ipp_tag_t = (IPP_TAG_COPY := (-($7fffffff)) - 1, 669 IPP_TAG_ZERO := $00, 670 IPP_TAG_OPERATION, 671 IPP_TAG_JOB, 672 IPP_TAG_END, 673 IPP_TAG_PRINTER, 674 IPP_TAG_UNSUPPORTED_GROUP, 675 IPP_TAG_SUBSCRIPTION, 676 IPP_TAG_EVENT_NOTIFICATION, 677 IPP_TAG_UNSUPPORTED_VALUE := $10, 678 IPP_TAG_DEFAULT, 679 IPP_TAG_UNKNOWN, 680 IPP_TAG_NOVALUE, 681 IPP_TAG_NOTSETTABLE := $15, 682 IPP_TAG_DELETEATTR, 683 IPP_TAG_ADMINDEFINE, 684 IPP_TAG_INTEGER := $21, 685 IPP_TAG_BOOLEAN, 686 IPP_TAG_ENUM, 687 IPP_TAG_STRING := $30, 688 IPP_TAG_DATE, 689 IPP_TAG_RESOLUTION, 690 IPP_TAG_RANGE, 691 IPP_TAG_BEGIN_COLLECTION, 692 IPP_TAG_TEXTLANG, 693 IPP_TAG_NAMELANG, 694 IPP_TAG_END_COLLECTION, 695 IPP_TAG_TEXT := $41, 696 IPP_TAG_NAME, 697 IPP_TAG_KEYWORD := $44, 698 IPP_TAG_URI, 699 IPP_TAG_URISCHEME, 700 IPP_TAG_CHARSET, 701 IPP_TAG_LANGUAGE, 702 IPP_TAG_MIMETYPE, 703 IPP_TAG_MEMBERNAME, 704 IPP_TAG_MASK := $7fffffff 705 ); 706 707 //Resolution units... 708 ipp_res_t = (IPP_RES_PER_INCH := 3, 709 IPP_RES_PER_CM); 710 711 //Finishings... 712 ipp_finish_t = (IPP_FINISHINGS_NONE := 3, 713 IPP_FINISHINGS_STAPLE, 714 IPP_FINISHINGS_PUNCH, 715 IPP_FINISHINGS_COVER, 716 IPP_FINISHINGS_BIND, 717 IPP_FINISHINGS_SADDLE_STITCH, 718 IPP_FINISHINGS_EDGE_STITCH, 719 IPP_FINISHINGS_FOLD, 720 IPP_FINISHINGS_TRIM, 721 IPP_FINISHINGS_BALE, 722 IPP_FINISHINGS_BOOKLET_MAKER, 723 IPP_FINISHINGS_JOB_OFFSET, 724 IPP_FINISHINGS_STAPLE_TOP_LEFT := 20, 725 IPP_FINISHINGS_STAPLE_BOTTOM_LEFT, 726 IPP_FINISHINGS_STAPLE_TOP_RIGHT, 727 IPP_FINISHINGS_STAPLE_BOTTOM_RIGHT, 728 IPP_FINISHINGS_EDGE_STITCH_LEFT, 729 IPP_FINISHINGS_EDGE_STITCH_TOP, 730 IPP_FINISHINGS_EDGE_STITCH_RIGHT, 731 IPP_FINISHINGS_EDGE_STITCH_BOTTOM, 732 IPP_FINISHINGS_STAPLE_DUAL_LEFT, 733 IPP_FINISHINGS_STAPLE_DUAL_TOP, 734 IPP_FINISHINGS_STAPLE_DUAL_RIGHT, 735 IPP_FINISHINGS_STAPLE_DUAL_BOTTOM, 736 IPP_FINISHINGS_BIND_LEFT := 50, 737 IPP_FINISHINGS_BIND_TOP, 738 IPP_FINISHINGS_BIND_RIGHT, 739 IPP_FINISHINGS_BIND_BOTTOM 740 ); 741 742 ipp_status_t = (IPP_OK := $0000, 743 IPP_OK_SUBST, 744 IPP_OK_CONFLICT, 745 IPP_OK_IGNORED_SUBSCRIPTIONS, 746 IPP_OK_IGNORED_NOTIFICATIONS, 747 IPP_OK_TOO_MANY_EVENTS, 748 IPP_OK_BUT_CANCEL_SUBSCRIPTION, 749 IPP_REDIRECTION_OTHER_SITE := $300, 750 IPP_BAD_REQUEST := $0400, 751 IPP_FORBIDDEN, 752 IPP_NOT_AUTHENTICATED, 753 IPP_NOT_AUTHORIZED, 754 IPP_NOT_POSSIBLE, 755 IPP_TIMEOUT, 756 IPP_NOT_FOUND, 757 IPP_GONE, 758 IPP_REQUEST_ENTITY, 759 IPP_REQUEST_VALUE, 760 IPP_DOCUMENT_FORMAT, 761 IPP_ATTRIBUTES, 762 IPP_URI_SCHEME, 763 IPP_CHARSET,IPP_CONFLICT, 764 IPP_COMPRESSION_NOT_SUPPORTED, 765 IPP_COMPRESSION_ERROR, 766 IPP_DOCUMENT_FORMAT_ERROR, 767 IPP_DOCUMENT_ACCESS_ERROR, 768 IPP_ATTRIBUTES_NOT_SETTABLE, 769 IPP_IGNORED_ALL_SUBSCRIPTIONS, 770 IPP_TOO_MANY_SUBSCRIPTIONS, 771 IPP_IGNORED_ALL_NOTIFICATIONS, 772 IPP_PRINT_SUPPORT_FILE_NOT_FOUND, 773 IPP_INTERNAL_ERROR := $0500, 774 IPP_OPERATION_NOT_SUPPORTED, 775 IPP_SERVICE_UNAVAILABLE, 776 IPP_VERSION_NOT_SUPPORTED, 777 IPP_DEVICE_ERROR, 778 IPP_TEMPORARY_ERROR, 779 IPP_NOT_ACCEPTING, 780 IPP_PRINTER_BUSY, 781 IPP_ERROR_JOB_CANCELLED, 782 IPP_MULTIPLE_JOBS_NOT_SUPPORTED, 783 IPP_PRINTER_IS_DEACTIVATED); 784 785 //Printer States.... 786 ipp_pstate_t = (IPP_PRINTER_IDLE := 3, 787 IPP_PRINTER_PROCESSING, 788 IPP_PRINTER_STOPPED); 789 790 //IPP states... 791 ipp_state_t = (IPP_ERROR := -(1), //An error occurred 792 IPP_IDLE, //Nothing is happening/request completed 793 IPP_HEADER, //The request header needs to be sent/received 794 IPP_ATTRIBUTE, //One or more attributes need to be sent/received 795 IPP_DATA); //IPP request data needs to be sent/received 796 797 //IPP operations... 798 ipp_op_t = (IPP_PRINT_JOB := $0002, 799 IPP_PRINT_URI, 800 IPP_VALIDATE_JOB, 801 IPP_CREATE_JOB, 802 IPP_SEND_DOCUMENT, 803 IPP_SEND_URI, 804 IPP_CANCEL_JOB, 805 IPP_GET_JOB_ATTRIBUTES, 806 IPP_GET_JOBS, 807 IPP_GET_PRINTER_ATTRIBUTES, 808 IPP_HOLD_JOB, 809 IPP_RELEASE_JOB, 810 IPP_RESTART_JOB, 811 IPP_PAUSE_PRINTER := $0010, 812 IPP_RESUME_PRINTER, 813 IPP_PURGE_JOBS, 814 IPP_SET_PRINTER_ATTRIBUTES, 815 IPP_SET_JOB_ATTRIBUTES, 816 IPP_GET_PRINTER_SUPPORTED_VALUES, 817 IPP_CREATE_PRINTER_SUBSCRIPTION, 818 IPP_CREATE_JOB_SUBSCRIPTION, 819 IPP_GET_SUBSCRIPTION_ATTRIBUTES, 820 IPP_GET_SUBSCRIPTIONS, 821 IPP_RENEW_SUBSCRIPTION, 822 IPP_CANCEL_SUBSCRIPTION, 823 IPP_GET_NOTIFICATIONS, 824 IPP_SEND_NOTIFICATIONS, 825 IPP_GET_PRINT_SUPPORT_FILES := $0021, 826 IPP_ENABLE_PRINTER, 827 IPP_DISABLE_PRINTER, 828 IPP_PAUSE_PRINTER_AFTER_CURRENT_JOB, 829 IPP_HOLD_NEW_JOBS, 830 IPP_RELEASE_HELD_NEW_JOBS, 831 IPP_DEACTIVATE_PRINTER, 832 IPP_ACTIVATE_PRINTER, 833 IPP_RESTART_PRINTER, 834 IPP_SHUTDOWN_PRINTER, 835 IPP_STARTUP_PRINTER, 836 IPP_REPROCESS_JOB, 837 IPP_CANCEL_CURRENT_JOB, 838 IPP_SUSPEND_CURRENT_JOB, 839 IPP_RESUME_JOB, 840 IPP_PROMOTE_JOB, 841 IPP_SCHEDULE_JOB_AFTER, 842 IPP_PRIVATE := $4000, 843 CUPS_GET_DEFAULT, 844 CUPS_GET_PRINTERS, 845 CUPS_ADD_PRINTER, 846 CUPS_DELETE_PRINTER, 847 CUPS_GET_CLASSES, 848 CUPS_ADD_CLASS, 849 CUPS_DELETE_CLASS, 850 CUPS_ACCEPT_JOBS, 851 CUPS_REJECT_JOBS, 852 CUPS_SET_DEFAULT, 853 CUPS_GET_DEVICES, 854 CUPS_GET_PPDS, 855 CUPS_MOVE_JOB, 856 CUPS_ADD_DEVICE, 857 CUPS_DELETE_DEVICE 858 ); 859 860 Pipp_uchar_t=^ipp_uchar_t; 861 ipp_uchar_t = byte; //Unsigned 8-bit integer/character 862 863 //Request Header 864 ipp_request_t = record 865 case longint of 866 0 : (any : record //Any Header 867 version : array[0..1] of ipp_uchar_t; //Protocol version number 868 op_status : longint; //Operation ID or status code 869 request_id : longint; //Request ID 870 end); 871 1 : (op : record //Operation ID 872 version : array[0..1] of ipp_uchar_t; //Protocol version number 873 operation_id : ipp_op_t; //Operation ID 874 request_id : longint; //Request ID 875 end); 876 2 : (status : record //Status Header 877 version:array[0..1] of ipp_uchar_t;//Protocol version number 878 status_code : ipp_status_t; //Status code 879 request_id : longint; //Request ID 880 end); 881 end; 882 883 884 //Attribute Value 885 ipp_value_t = record 886 case longint of 887 0 : ( aInteger : longint ); //Integer/enumerated value 888 1 : ( aBoolean : char ); //Boolean value 889 2 : ( aDate : array[0..10] of ipp_uchar_t ); //Date/time value 890 3 : ( resolution : record //Resolution value 891 xres : longint; //Horizontal resolution 892 yres : longint; //Vertical resolution 893 units : ipp_res_t; //Resolution units 894 end ); 895 4 : ( range : record //Range of integers value 896 lower : longint; //Lower value 897 upper : longint; //Upper value 898 end ); 899 5 : ( _string : record //String with language value 900 charset: Pchar; //Character set 901 text : Pchar; //String 902 end ); 903 6 : ( unknown : record //Unknown attribute type 904 length : longint; //Length of attribute 905 data : pointer; //Data in attribute 906 end ); 907 end; 908 Pipp_value_t = ^ipp_value_t; 909 910 911 //Attribute 912 Pipp_attribute_s=^ipp_attribute_s; 913 ipp_attribute_s = record 914 next : Pipp_attribute_s; //Next attribute in list 915 group_tag : ipp_tag_t; //Job/Printer/Operation group tag 916 value_tag : ipp_tag_t; //What type of value is it? 917 name : Pchar; //Name of attribute 918 num_values: longint; //Number of values 919 values : array[0..0] of ipp_value_t; //Values 920 end; 921 ipp_attribute_t = ipp_attribute_s; 922 Pipp_attribute_t=^ipp_attribute_t; 923 924 //Request State 925 Pipp_t=^ipp_t; 926 ipp_t = record 927 state : ipp_state_t; //State of request 928 request : ipp_request_t; //Request header 929 attrs : Pipp_attribute_t; //Attributes 930 last : Pipp_attribute_t; //Last attribute in list 931 current : Pipp_attribute_t; //Current attribute (for read/write) 932 curtag : ipp_tag_t; //Current attribute group tag 933 end; 934 935// 936// 937// 938// 939const 940 MaxcupsLibs=2; 941 cupsLibs :Array[0..MaxcupsLibs] of string = ('libcups.so', 942 'libcups.so.2', 943 '/usr/lib/libcups.dylib'); 944 945const 946 CUPS_VERSION = 1.0119; 947 CUPS_VERSION_MAJOR = 1; 948 CUPS_VERSION_MINOR = 1; 949 CUPS_VERSION_PATCH = 19; 950 CUPS_DATE_ANY = -(1); 951 952 //**** Printer Type/Capability Bits ******** 953 //not a typedef'd enum so we can OR 954 CUPS_PRINTER_LOCAL = $0000; // Local printer or class 955 CUPS_PRINTER_CLASS = $0001; // Printer class 956 CUPS_PRINTER_REMOTE = $0002; // Remote printer or class 957 CUPS_PRINTER_BW = $0004; // Can do B&W printing 958 CUPS_PRINTER_COLOR = $0008; // Can do color printing 959 CUPS_PRINTER_DUPLEX = $0010; // Can do duplexing 960 CUPS_PRINTER_STAPLE = $0020; // Can staple output 961 CUPS_PRINTER_COPIES = $0040; // Can do copies 962 CUPS_PRINTER_COLLATE = $0080; // Can collage copies 963 CUPS_PRINTER_PUNCH = $0100; // Can punch output 964 CUPS_PRINTER_COVER = $0200; // Can cover output 965 CUPS_PRINTER_BIND = $0400; // Can bind output 966 CUPS_PRINTER_SORT = $0800; // Can sort output 967 CUPS_PRINTER_SMALL = $1000; // Can do Letter/Legal/A4 968 CUPS_PRINTER_MEDIUM = $2000; // Can do Tabloid/B/C/A3/A2 969 CUPS_PRINTER_LARGE = $4000; // Can do D/E/A1/A0 970 CUPS_PRINTER_VARIABLE = $8000; // Can do variable sizes 971 CUPS_PRINTER_IMPLICIT = $10000; // Implicit class 972 CUPS_PRINTER_DEFAULT = $20000; // Default printer on network 973 CUPS_PRINTER_OPTIONS = $FFFC; // ~(CLASS | REMOTE | IMPLICIT) 974 975type 976 PPPChar = ^PPChar; 977 cups_ptype_t = dword; //See bit flags consts 978 TFunctionWithParam1 = function (_para1:Pchar):Pchar; 979 980 //Printer Options 981 Pcups_option_t= ^cups_option_t; 982 PPcups_option_t=^Pcups_option_t; 983 cups_option_t = record 984 name : PChar; //Name of option 985 value : PChar; //Value of option 986 end; 987 988 //Destination 989 Pcups_dest_t=^cups_dest_t; 990 PPcups_dest_t=^Pcups_dest_t; 991 cups_dest_t = record 992 name : PChar; //Printer or class name 993 instance : PChar; //Local instance name or NULL 994 is_default : Longint; //Is this printer the default? 995 num_options: Longint; //Number of options 996 options : Pcups_option_t; //Options 997 end; 998 //Job 999 Pcups_job_t=^cups_job_t; 1000 PPcups_job_t=^Pcups_job_t; 1001 cups_job_t = record 1002 id : longint; //The job ID 1003 dest : Pchar; //Printer or class name 1004 title : Pchar; //Title/job name 1005 user : Pchar; //User the submitted the job 1006 format : Pchar; //Document format 1007 state : ipp_jstate_t; //Job state 1008 size : longint; //Size in kilobytes 1009 priority : longint; //Priority (1-100) 1010 completed_time : time_t; //Time the job was completed 1011 creation_time : time_t; //Time the job was created 1012 processing_time : time_t; //Time the job was processed 1013 end; 1014 1015 1016var 1017 // 1018 //cups_language.pp 1019 // 1020 cupsLangEncoding: function (lang:Pcups_lang_t):Pchar;cdecl; 1021 cupsLangFlush: procedure; cdecl; 1022 cupsLangFree: procedure (lang:Pcups_lang_t);cdecl; 1023 cupsLangGet: function (language:Pchar):Pcups_lang_t;cdecl; 1024 // 1025 //cups_http.pp 1026 // 1027 httpCheck: function (http:Phttp_t):longint;cdecl; 1028 httpClose: procedure (http_t :Phttp_t); cdecl; 1029 httpConnect: function (host:Pchar; port:longint):Phttp_t;cdecl; 1030 httpConnectEncrypt: function (host:Pchar; port:longint; encrypt:http_encryption_t):Phttp_t;cdecl; 1031 httpDelete: function (http:Phttp_t; uri:Pchar):longint;cdecl; 1032 httpEncryption: function (http:Phttp_t; e:http_encryption_t):longint;cdecl; 1033 httpError: function (http : longint) : longint; cdecl; 1034 httpFlush: procedure (http:Phttp_t);cdecl; 1035 httpGet: function (http:Phttp_t; uri:Pchar):longint;cdecl; 1036 httpGets: function (line:Pchar; length:longint; http:Phttp_t):Pchar;cdecl; 1037 httpGetDateString: function (t:time_t):Pchar;cdecl; 1038 httpGetDateTime: function (s:Pchar):time_t;cdecl; 1039 httpGetField: function (http,field : longint) : longint; cdecl; 1040 //httpGetHostByName: function (name:Pchar):^hostent;cdecl; 1041 httpGetSubField: function (http:Phttp_t; field:http_field_t; name:Pchar; value:Pchar):Pchar;cdecl; 1042 httpHead: function (http:Phttp_t; uri:Pchar):longint;cdecl; 1043 httpInitialize: procedure ;cdecl; 1044 httpOptions: function (http:Phttp_t; uri:Pchar):longint;cdecl; 1045 httpPost: function (http:Phttp_t; uri:Pchar):longint;cdecl; 1046 httpPut: function (http:Phttp_t; uri:Pchar):longint;cdecl; 1047 httpRead: function (http:Phttp_t; buffer:Pchar; length:longint):longint;cdecl; 1048 httpReconnect: function (http:Phttp_t):longint;cdecl; 1049 httpSeparate: procedure (uri:Pchar; method:Pchar; username:Pchar; host:Pchar; port:Plongint; resource:Pchar);cdecl; 1050 httpSetField: procedure (http:Phttp_t; field:http_field_t; value:Pchar);cdecl; 1051 httpStatus: function (status:http_status_t):Pchar;cdecl; 1052 httpTrace: function (http:Phttp_t; uri:Pchar):longint;cdecl; 1053 httpUpdate: function (http:Phttp_t):http_status_t;cdecl; 1054 httpWait: function (http:Phttp_t; msec:longint):longint;cdecl; 1055 httpWrite: function (http:Phttp_t; buffer:Pchar; length:longint):longint;cdecl; 1056 //httpEncode64: function (out:Pchar; in:Pchar):Pchar;cdecl; 1057 //httpDecode64: function (out:Pchar; in:Pchar):Pchar;cdecl; 1058 httpGetLength: function (http:Phttp_t):longint;cdecl; 1059 httpMD5: function (_para1:Pchar; _para2:Pchar; _para3:Pchar; {%H-}_para4:TArrayChar32):Pchar;cdecl; 1060 httpMD5Final: function (_para1:Pchar; _para2:Pchar; _para3:Pchar; {%H-}_para4:TArrayChar32):Pchar;cdecl; 1061 httpMD5String: function (_para1:Pmd5_byte_t; {%H-}_para2:TArrayChar32):Pchar;cdecl; 1062 1063 // 1064 // cups_ppd 1065 // 1066 ppdClose: procedure (ppd:Pppd_file_t);cdecl; 1067 ppdCollect: function (ppd:Pppd_file_t; section:ppd_section_t; choices:PPPppd_choice_t):longint;cdecl; 1068 ppdConflicts: function (ppd:Pppd_file_t):longint;cdecl; 1069 ppdEmit: function (ppd:Pppd_file_t; fp:PFILE; section:ppd_section_t):longint;cdecl; 1070 ppdEmitFd: function (ppd:Pppd_file_t; fd:longint; section:ppd_section_t):longint;cdecl; 1071 ppdEmitJCL: function (ppd:Pppd_file_t; fp:PFILE; job_id:longint; user:Pchar; title:Pchar):longint;cdecl; 1072 ppdFindChoice: function (o:Pppd_option_t; option:Pchar):Pppd_choice_t;cdecl; 1073 ppdFindMarkedChoice: function (ppd:Pppd_file_t; keyword:Pchar):Pppd_choice_t;cdecl; 1074 ppdFindOption: function (ppd:Pppd_file_t; keyword:Pchar):Pppd_option_t;cdecl; 1075 ppdIsMarked: function (ppd:Pppd_file_t; keyword:Pchar; option:Pchar):longint;cdecl; 1076 ppdMarkDefaults: procedure (ppd:Pppd_file_t);cdecl; 1077 ppdMarkOption: function (ppd:Pppd_file_t; keyword:Pchar; option:Pchar):longint;cdecl; 1078 ppdOpen: function (fp:PFILE):Pppd_file_t;cdecl; 1079 ppdOpenFd: function (fd:longint):Pppd_file_t;cdecl; 1080 ppdOpenFile: function (filename:Pchar):Pppd_file_t;cdecl; 1081 ppdPageLength: function (ppd:Pppd_file_t; name:Pchar):single;cdecl; 1082 ppdPageSize: function (ppd:Pppd_file_t; name:Pchar):Pppd_size_t;cdecl; 1083 ppdPageWidth: function (ppd:Pppd_file_t; name:Pchar):single;cdecl; 1084 {New in CUPS 1.1.19} 1085 ppdErrorString: function (status:ppd_status_t):Pchar;cdecl; 1086 ppdFindAttr: function (ppd:Pppd_file_t; name:Pchar; spec:Pchar):Pchar;cdecl; 1087 ppdFindNextAttr: function (ppd:Pppd_file_t; name:Pchar; spec:Pchar):Pchar;cdecl; 1088 ppdLastError: function (line:Plongint):ppd_status_t;cdecl; 1089 1090 // 1091 // cups_ipp 1092 // 1093 ippAddBoolean: function (ipp:Pipp_t; group:ipp_tag_t; name:Pchar; value:char):Pipp_attribute_t;cdecl; 1094 ippAddBooleans: function (ipp:Pipp_t; group:ipp_tag_t; name:Pchar; num_values:longint; values:Pchar):Pipp_attribute_t;cdecl; 1095 ippAddDate: function (ipp:Pipp_t; group:ipp_tag_t; name:Pchar; value:Pipp_uchar_t):Pipp_attribute_t;cdecl; 1096 ippAddInteger: function (ipp:Pipp_t; group:ipp_tag_t; _type:ipp_tag_t; name:Pchar; value:longint):Pipp_attribute_t;cdecl; 1097 ippAddIntegers: function (ipp:Pipp_t; group:ipp_tag_t; _type:ipp_tag_t; name:Pchar; num_values:longint; 1098 values:Plongint):Pipp_attribute_t;cdecl; 1099 ippAddRange: function (ipp:Pipp_t; group:ipp_tag_t; name:Pchar; lower:longint; upper:longint):Pipp_attribute_t;cdecl; 1100 ippAddRanges: function (ipp:Pipp_t; group:ipp_tag_t; name:Pchar; num_values:longint; lower:Plongint; 1101 upper:Plongint):Pipp_attribute_t;cdecl; 1102 ippAddResolution: function (ipp:Pipp_t; group:ipp_tag_t; name:Pchar; units:ipp_res_t; xres:longint; 1103 yres:longint):Pipp_attribute_t;cdecl; 1104 ippAddResolutions: function (ipp:Pipp_t; group:ipp_tag_t; name:Pchar; num_values:longint; units:ipp_res_t; 1105 xres:Plongint; yres:Plongint):Pipp_attribute_t;cdecl; 1106 ippAddSeparator: function (ipp:Pipp_t):Pipp_attribute_t;cdecl; 1107 ippAddString: function (ipp:Pipp_t; group:ipp_tag_t; _type:ipp_tag_t; name:Pchar; charset:Pchar; 1108 value:Pchar):Pipp_attribute_t;cdecl; 1109 ippAddStrings: function (ipp:Pipp_t; group:ipp_tag_t; _type:ipp_tag_t; name:Pchar; num_values:longint; 1110 charset:Pchar; values:PPchar):Pipp_attribute_t;cdecl; 1111 ippDateToTime: function (date:Pipp_uchar_t):time_t;cdecl; 1112 ippDelete: procedure (ipp:Pipp_t);cdecl; 1113 ippErrorString: function (error:ipp_status_t):Pchar;cdecl; 1114 ippFindAttribute: function (ipp:Pipp_t; name:Pchar; _type:ipp_tag_t):Pipp_attribute_t;cdecl; 1115 ippFindNextAttribute: function (ipp:Pipp_t; name:Pchar; _type:ipp_tag_t):Pipp_attribute_t;cdecl; 1116 ippLength: function (ipp:Pipp_t):size_t;cdecl; 1117 ippNew: function :Pipp_t;cdecl; 1118 ippRead: function (http:Phttp_t; ipp:Pipp_t):ipp_state_t;cdecl; 1119 ippTimeToDate: function (t:time_t):Pipp_uchar_t;cdecl; 1120 ippWrite: function (http:Phttp_t; ipp:Pipp_t):ipp_state_t;cdecl; 1121 ippPort: function :longint;cdecl; 1122 ippSetPort: procedure (p:longint);cdecl; 1123 _ipp_add_attr: function (_para1:Pipp_t; _para2:longint):Pipp_attribute_t;cdecl; 1124 _ipp_free_attr: procedure (_para1:Pipp_attribute_t);cdecl; 1125 1126 // 1127 //cups.pp 1128 // 1129 cupsServer: function :Pchar;cdecl; 1130 cupsGetDefault:function :PChar; cdecl; 1131 cupsGetPPD:function (printer :Pchar): PChar;cdecl; 1132 cupsLastError:function : ipp_status_t; cdecl; 1133 cupsGetPrinters:function (printers :PPPchar):longint;cdecl; 1134 cupsDoFileRequest:function (http:Phttp_t; request:Pipp_t; const resource:Pchar; const filename:Pchar):Pipp_t;cdecl; 1135 cupsCancelJob:function (printer:Pchar; job:longint):longint;cdecl; 1136 cupsEncryption:function :http_encryption_t;cdecl; 1137 cupsFreeJobs:procedure (num_jobs:longint; jobs:Pcups_job_t);cdecl; 1138 cupsGetClasses:function (classes:PPPchar):longint;cdecl; 1139 cupsGetJobs:function (jobs:PPcups_job_t; dest:Pchar; myjobs:longint; completed:longint):longint;cdecl; 1140 cupsPrintFile:function (printer:Pchar; filename:Pchar; title:Pchar; 1141 num_options:longint; options:Pcups_option_t):longint;cdecl; 1142 cupsPrintFiles:function (printer:Pchar; num_files:longint; files:PPchar; 1143 title:Pchar; num_options:longint; options:Pcups_option_t):longint;cdecl; 1144 cupsTempFile:function (filename:Pchar; len:longint):Pchar;cdecl; 1145 cupsTempFd:function (filename:Pchar; len:longint):longint;cdecl; 1146 cupsAddDest:function (name:Pchar; instance:Pchar; num_dests:longint; 1147 dests:PPcups_dest_t):longint;cdecl; 1148 cupsFreeDests:procedure (num_dests:longint; dests:Pcups_dest_t);cdecl; 1149 cupsGetDest:function (name:Pchar; instance:Pchar; 1150 num_dests:longint; dests:Pcups_dest_t):Pcups_dest_t;cdecl; 1151 cupsGetDests:function (dests:PPcups_dest_t):longint;cdecl; 1152 cupsSetDests:procedure (num_dests:longint; dests:Pcups_dest_t);cdecl; 1153 cupsAddOption:function (name:Pchar; value:Pchar; num_options:longint; options:PPcups_option_t):longint;cdecl; 1154 cupsEncodeOptions:procedure (ipp:Pipp_t; num_options:longint; options:Pcups_option_t);cdecl; 1155 cupsFreeOptions:procedure (num_options:longint; options:Pcups_option_t);cdecl; 1156 cupsGetOption:function (name:Pchar; num_options:longint; options:Pcups_option_t):Pchar;cdecl; 1157 cupsParseOptions:function (arg:Pchar; num_options:longint; options:PPcups_option_t):longint;cdecl; 1158 cupsMarkOptions:function (ppd:Pppd_file_t; num_options:longint; options:Pcups_option_t):longint;cdecl; 1159 cupsGetPassword:function (prompt:Pchar):Pchar;cdecl; 1160 cupsSetEncryption:procedure (e:http_encryption_t);cdecl; 1161 cupsSetPasswordCB:procedure (cb: TFunctionWithParam1);cdecl; 1162 cupsSetServer:procedure (server:Pchar);cdecl; 1163 cupsSetUser:procedure (user:Pchar);cdecl; 1164 cupsUser:function :Pchar;cdecl; 1165 1166function cupsDoRequest(ahttp :Phttp_t; aRequest :Pipp_t; aResource :PChar) : Pipp_t; 1167function cupsLangDefault : Pcups_lang_t; 1168 1169procedure InitializeCups; 1170procedure FinalizeCups; 1171 1172function CUPSLibInstalled : Boolean; 1173 1174var 1175 CupsLibHandle: TLibHandle; 1176 1177implementation 1178 1179var RefCount : integer; 1180 1181procedure InitializeCups; 1182var i : integer; 1183begin 1184 inc(RefCount); 1185 //debugln('InitializeCups RefCount=',dbgs(RefCount)); 1186 if RefCount = 1 then 1187 begin 1188 for i:=0 to MaxcupsLibs do 1189 begin 1190 CupsLibHandle := loadlibrary(cupslibs[i]); 1191 if CupsLibHandle <> nilhandle then 1192 Break; 1193 end; 1194 1195 if CupsLibHandle = nilhandle then 1196 begin 1197 //debugln('InitializeCups load cups lib failed'); 1198 RefCount := 0; 1199 raise EInOutError.Create('Can not load cups library'); 1200 end; 1201 end; 1202 1203 //WriteLn('CupsLibHandle=', CupsLibHandle); 1204 1205 // 1206 //cups_language.pp 1207 // 1208 pointer(cupsLangEncoding) := GetProcedureAddress(CupsLibHandle, 'cupsLangEncoding'); 1209 pointer(cupsLangFlush) := GetProcedureAddress(CupsLibHandle, 'cupsLangFlush'); 1210 pointer(cupsLangFree) := GetProcedureAddress(CupsLibHandle, 'cupsLangFree'); 1211 pointer(cupsLangGet) := GetProcedureAddress(CupsLibHandle, 'cupsLangGet'); 1212 1213 // 1214 // cups_http.pp 1215 // 1216 pointer(httpCheck) := GetProcedureAddress(CupsLibHandle, 'httpCheck'); 1217 pointer(httpClose) := GetProcedureAddress(CupsLibHandle, 'httpClose'); 1218 pointer(httpConnect) := GetProcedureAddress(CupsLibHandle, 'httpConnect'); 1219 pointer(httpConnectEncrypt) := GetProcedureAddress(CupsLibHandle, 'httpConnectEncrypt'); 1220 pointer(httpDelete) := GetProcedureAddress(CupsLibHandle, 'httpDelete'); 1221 pointer(httpEncryption) := GetProcedureAddress(CupsLibHandle, 'httpEncryption'); 1222 pointer(httpError) := GetProcedureAddress(CupsLibHandle, 'httpError'); 1223 pointer(httpFlush) := GetProcedureAddress(CupsLibHandle, 'httpFlush'); 1224 pointer(httpGet) := GetProcedureAddress(CupsLibHandle, 'httpGet'); 1225 pointer(httpGets) := GetProcedureAddress(CupsLibHandle, 'httpGets'); 1226 pointer(httpGetDateString) := GetProcedureAddress(CupsLibHandle, 'httpGetDateString'); 1227 pointer(httpGetDateTime) := GetProcedureAddress(CupsLibHandle, 'httpGetDateTime'); 1228 pointer(httpGetField) := GetProcedureAddress(CupsLibHandle, 'httpGetField'); 1229 //pointer(httpGetHostByName) := GetProcedureAddress(CupsLibHandle, 'httpGetHostByName'); 1230 pointer(httpGetSubField) := GetProcedureAddress(CupsLibHandle, 'httpGetSubField'); 1231 pointer(httpHead) := GetProcedureAddress(CupsLibHandle, 'httpHead'); 1232 pointer(httpInitialize) := GetProcedureAddress(CupsLibHandle, 'httpInitialize'); 1233 pointer(httpOptions) := GetProcedureAddress(CupsLibHandle, 'httpOptions'); 1234 pointer(httpPost) := GetProcedureAddress(CupsLibHandle, 'httpPost'); 1235 pointer(httpPut) := GetProcedureAddress(CupsLibHandle, 'httpPut'); 1236 pointer(httpRead) := GetProcedureAddress(CupsLibHandle, 'httpRead'); 1237 pointer(httpReconnect) := GetProcedureAddress(CupsLibHandle, 'httpReconnect'); 1238 pointer(httpSeparate) := GetProcedureAddress(CupsLibHandle, 'httpSeparate'); 1239 pointer(httpSetField) := GetProcedureAddress(CupsLibHandle, 'httpSetField'); 1240 pointer(httpStatus) := GetProcedureAddress(CupsLibHandle, 'httpStatus'); 1241 pointer(httpTrace) := GetProcedureAddress(CupsLibHandle, 'httpTrace'); 1242 pointer(httpUpdate) := GetProcedureAddress(CupsLibHandle, 'httpUpdate'); 1243 pointer(httpWait) := GetProcedureAddress(CupsLibHandle, 'httpWait'); 1244 pointer(httpWrite) := GetProcedureAddress(CupsLibHandle, 'httpWrite'); 1245 //pointer(httpEncode64) := GetProcedureAddress(CupsLibHandle, 'httpEncode64'); 1246 //pointer(httpDecode64) := GetProcedureAddress(CupsLibHandle, 'httpDecode64'); 1247 pointer(httpGetLength) := GetProcedureAddress(CupsLibHandle, 'httpGetLength'); 1248 pointer(httpMD5) := GetProcedureAddress(CupsLibHandle, 'httpMD5'); 1249 pointer(httpMD5Final) := GetProcedureAddress(CupsLibHandle, 'httpMD5Final'); 1250 pointer(httpMD5String) := GetProcedureAddress(CupsLibHandle, 'httpMD5String'); 1251 1252 // 1253 // cups_ppd 1254 // 1255 pointer(ppdClose) := GetProcedureAddress(CupsLibHandle, 'ppdClose'); 1256 pointer(ppdCollect) := GetProcedureAddress(CupsLibHandle, 'ppdCollect'); 1257 pointer(ppdConflicts) := GetProcedureAddress(CupsLibHandle, 'ppdConflicts'); 1258 pointer(ppdEmit) := GetProcedureAddress(CupsLibHandle, 'ppdEmit'); 1259 pointer(ppdEmitFd) := GetProcedureAddress(CupsLibHandle, 'ppdEmitFd'); 1260 pointer(ppdEmitJCL) := GetProcedureAddress(CupsLibHandle, 'ppdEmitJCL'); 1261 pointer(ppdFindChoice) := GetProcedureAddress(CupsLibHandle, 'ppdFindChoice'); 1262 pointer(ppdFindMarkedChoice) := GetProcedureAddress(CupsLibHandle, 'ppdFindMarkedChoice'); 1263 pointer(ppdFindOption) := GetProcedureAddress(CupsLibHandle, 'ppdFindOption'); 1264 pointer(ppdIsMarked) := GetProcedureAddress(CupsLibHandle, 'ppdIsMarked'); 1265 pointer(ppdMarkDefaults) := GetProcedureAddress(CupsLibHandle, 'ppdMarkDefaults'); 1266 pointer(ppdMarkOption) := GetProcedureAddress(CupsLibHandle, 'ppdMarkOption'); 1267 pointer(ppdOpen) := GetProcedureAddress(CupsLibHandle, 'ppdOpen'); 1268 pointer(ppdOpenFd) := GetProcedureAddress(CupsLibHandle, 'ppdOpenFd'); 1269 pointer(ppdOpenFile) := GetProcedureAddress(CupsLibHandle, 'ppdOpenFile'); 1270 pointer(ppdPageLength) := GetProcedureAddress(CupsLibHandle, 'ppdPageLength'); 1271 pointer(ppdPageSize) := GetProcedureAddress(CupsLibHandle, 'ppdPageSize'); 1272 pointer(ppdPageWidth) := GetProcedureAddress(CupsLibHandle, 'ppdPageWidth'); 1273 {New in CUPS 1.1.19} 1274 pointer(ppdErrorString) := GetProcedureAddress(CupsLibHandle, 'ppdErrorString'); 1275 pointer(ppdFindAttr) := GetProcedureAddress(CupsLibHandle, 'ppdFindAttr'); 1276 pointer(ppdFindNextAttr) := GetProcedureAddress(CupsLibHandle, 'ppdFindNextAttr'); 1277 pointer(ppdLastError) := GetProcedureAddress(CupsLibHandle, 'ppdLastError'); 1278 1279 // 1280 // cups_ipp 1281 // 1282 pointer(ippAddBoolean) := GetProcedureAddress(CupsLibHandle, 'ippAddBoolean'); 1283 pointer(ippAddBooleans) := GetProcedureAddress(CupsLibHandle, 'ippAddBooleans'); 1284 pointer(ippAddDate) := GetProcedureAddress(CupsLibHandle, 'ippAddDate'); 1285 pointer(ippAddInteger) := GetProcedureAddress(CupsLibHandle, 'ippAddInteger'); 1286 pointer(ippAddIntegers) := GetProcedureAddress(CupsLibHandle, 'ippAddIntegers'); 1287 pointer(ippAddRange) := GetProcedureAddress(CupsLibHandle, 'ippAddRange'); 1288 pointer(ippAddRanges) := GetProcedureAddress(CupsLibHandle, 'ippAddRanges'); 1289 pointer(ippAddResolution) := GetProcedureAddress(CupsLibHandle, 'ippAddResolution'); 1290 pointer(ippAddResolutions) := GetProcedureAddress(CupsLibHandle, 'ippAddResolutions'); 1291 pointer(ippAddSeparator) := GetProcedureAddress(CupsLibHandle, 'ippAddSeparator'); 1292 pointer(ippAddString) := GetProcedureAddress(CupsLibHandle, 'ippAddString'); 1293 pointer(ippAddStrings) := GetProcedureAddress(CupsLibHandle, 'ippAddStrings'); 1294 pointer(ippDateToTime) := GetProcedureAddress(CupsLibHandle, 'ippDateToTime'); 1295 pointer(ippDelete) := GetProcedureAddress(CupsLibHandle, 'ippDelete'); 1296 pointer(ippErrorString) := GetProcedureAddress(CupsLibHandle, 'ippErrorString'); 1297 pointer(ippFindAttribute) := GetProcedureAddress(CupsLibHandle, 'ippFindAttribute'); 1298 pointer(ippFindNextAttribute) := GetProcedureAddress(CupsLibHandle, 'ippFindNextAttribute'); 1299 pointer(ippLength) := GetProcedureAddress(CupsLibHandle, 'ippLength'); 1300 pointer(ippNew) := GetProcedureAddress(CupsLibHandle, 'ippNew'); 1301 pointer(ippRead) := GetProcedureAddress(CupsLibHandle, 'ippRead'); 1302 pointer(ippTimeToDate) := GetProcedureAddress(CupsLibHandle, 'ippTimeToDate'); 1303 pointer(ippWrite) := GetProcedureAddress(CupsLibHandle, 'ippWrite'); 1304 pointer(ippPort) := GetProcedureAddress(CupsLibHandle, 'ippPort'); 1305 pointer(ippSetPort) := GetProcedureAddress(CupsLibHandle, 'ippSetPort'); 1306 pointer(_ipp_add_attr) := GetProcedureAddress(CupsLibHandle, '_ipp_add_attr'); 1307 pointer(_ipp_free_attr) := GetProcedureAddress(CupsLibHandle, '_ipp_free_attr'); 1308 1309 // 1310 // cups.pp 1311 // 1312 pointer(cupsServer) := GetProcedureAddress(CupsLibHandle, 'cupsServer'); 1313 pointer(cupsGetDefault) := GetProcedureAddress(CupsLibHandle, 'cupsGetDefault'); 1314 pointer(cupsGetPPD) := GetProcedureAddress(CupsLibHandle, 'cupsGetPPD'); 1315 pointer(cupsLastError) := GetProcedureAddress(CupsLibHandle, 'cupsLastError'); 1316 pointer(cupsGetPrinters) := GetProcedureAddress(CupsLibHandle, 'cupsGetPrinters'); 1317 pointer(cupsDoFileRequest) := GetProcedureAddress(CupsLibHandle, 'cupsDoFileRequest'); 1318 pointer(cupsCancelJob) := GetProcedureAddress(CupsLibHandle, 'cupsCancelJob'); 1319 pointer(cupsEncryption) := GetProcedureAddress(CupsLibHandle, 'cupsEncryption'); 1320 pointer(cupsFreeJobs) := GetProcedureAddress(CupsLibHandle, 'cupsFreeJobs'); 1321 pointer(cupsGetClasses) := GetProcedureAddress(CupsLibHandle, 'cupsGetClasses'); 1322 pointer(cupsGetJobs) := GetProcedureAddress(CupsLibHandle, 'cupsGetJobs'); 1323 pointer(cupsPrintFile) := GetProcedureAddress(CupsLibHandle, 'cupsPrintFile'); 1324 pointer(cupsPrintFiles) := GetProcedureAddress(CupsLibHandle, 'cupsPrintFiles'); 1325 pointer(cupsTempFile) := GetProcedureAddress(CupsLibHandle, 'cupsTempFile'); 1326 pointer(cupsTempFd) := GetProcedureAddress(CupsLibHandle, 'cupsTempFd'); 1327 pointer(cupsAddDest) := GetProcedureAddress(CupsLibHandle, 'cupsAddDest'); 1328 pointer(cupsFreeDests) := GetProcedureAddress(CupsLibHandle, 'cupsFreeDests'); 1329 pointer(cupsGetDest) := GetProcedureAddress(CupsLibHandle, 'cupsGetDest'); 1330 pointer(cupsGetDests) := GetProcedureAddress(CupsLibHandle, 'cupsGetDests'); 1331 pointer(cupsSetDests) := GetProcedureAddress(CupsLibHandle, 'cupsSetDests'); 1332 pointer(cupsAddOption) := GetProcedureAddress(CupsLibHandle, 'cupsAddOption'); 1333 pointer(cupsEncodeOptions) := GetProcedureAddress(CupsLibHandle, 'cupsEncodeOptions'); 1334 pointer(cupsFreeOptions) := GetProcedureAddress(CupsLibHandle, 'cupsFreeOptions'); 1335 pointer(cupsGetOption) := GetProcedureAddress(CupsLibHandle, 'cupsGetOption'); 1336 pointer(cupsParseOptions) := GetProcedureAddress(CupsLibHandle, 'cupsParseOptions'); 1337 pointer(cupsMarkOptions) := GetProcedureAddress(CupsLibHandle, 'cupsMarkOptions'); 1338 pointer(cupsGetPassword) := GetProcedureAddress(CupsLibHandle, 'cupsGetPassword'); 1339 pointer(cupsSetEncryption) := GetProcedureAddress(CupsLibHandle, 'cupsSetEncryption'); 1340 pointer(cupsSetPasswordCB) := GetProcedureAddress(CupsLibHandle, 'cupsSetPasswordCB'); 1341 pointer(cupsSetServer) := GetProcedureAddress(CupsLibHandle, 'cupsSetServer'); 1342 pointer(cupsSetUser) := GetProcedureAddress(CupsLibHandle, 'cupsSetUser'); 1343 pointer(cupsUser) := GetProcedureAddress(CupsLibHandle, 'cupsUser'); 1344 1345end; 1346 1347//Return true if CUPS lib can be loaded and 1348//initilized. 1349function CUPSLibInstalled : Boolean; 1350begin 1351 Result:=False; 1352 if RefCount=0 then begin 1353 Try 1354 //debugln('CUPSLibInstalled A'); 1355 InitializeCups; 1356 Except 1357 exit; 1358 end; 1359 end; 1360 Result:=(RefCount>0); 1361end; 1362 1363procedure FinalizeCups; 1364begin 1365 //debugln('* FinalizeCups'); 1366 if RefCount>0 then 1367 Dec(RefCount); 1368 1369 if RefCount=0 then 1370 begin 1371 if (CupsLibHandle<>NilHandle) and not UnloadLibrary(CupsLibHandle) then 1372 Inc(RefCount) 1373 else 1374 CupsLibHandle := NilHandle; 1375 end; 1376end; 1377 1378function cupsLangDefault : Pcups_lang_t; 1379begin 1380 Result:=cupsLangGet(''); 1381end; 1382 1383function cupsDoRequest(ahttp :Phttp_t; aRequest :Pipp_t; 1384 aResource :PChar):Pipp_t; 1385begin 1386 Result:=cupsDoFileRequest(aHttp,aRequest,aResource,nil); 1387end; 1388 1389INITIALIZATION 1390 CupsLibHandle:= NilHandle; 1391 1392end. 1393 1394