MCPcopy Create free account
hub / github.com/OpenPrinting/cups / cupsSetServer

Function cupsSetServer

cups/usersys.c:425–484  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

423 */
424
425void
426cupsSetServer(const char *server) /* I - Server name */
427{
428 char *options, /* Options */
429 *port; /* Pointer to port */
430 _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
431
432
433 if (server)
434 {
435 strlcpy(cg->server, server, sizeof(cg->server));
436
437 if (cg->server[0] != '/' && (options = strrchr(cg->server, '/')) != NULL)
438 {
439 *options++ = '\0';
440
441 if (!strcmp(options, "version=1.0"))
442 cg->server_version = 10;
443 else if (!strcmp(options, "version=1.1"))
444 cg->server_version = 11;
445 else if (!strcmp(options, "version=2.0"))
446 cg->server_version = 20;
447 else if (!strcmp(options, "version=2.1"))
448 cg->server_version = 21;
449 else if (!strcmp(options, "version=2.2"))
450 cg->server_version = 22;
451 }
452 else
453 cg->server_version = 20;
454
455 if (cg->server[0] != '/' && (port = strrchr(cg->server, ':')) != NULL &&
456 !strchr(port, ']') && isdigit(port[1] & 255))
457 {
458 *port++ = '\0';
459
460 cg->ipp_port = atoi(port);
461 }
462
463 if (!cg->ipp_port)
464 cups_set_default_ipp_port(cg);
465
466 if (cg->server[0] == '/')
467 strlcpy(cg->servername, "localhost", sizeof(cg->servername));
468 else
469 strlcpy(cg->servername, cg->server, sizeof(cg->servername));
470 }
471 else
472 {
473 cg->server[0] = '\0';
474 cg->servername[0] = '\0';
475 cg->server_version = 20;
476 cg->ipp_port = 0;
477 }
478
479 if (cg->http)
480 {
481 httpClose(cg->http);
482 cg->http = NULL;

Callers 15

mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 3

_cupsGlobalsFunction · 0.85
httpCloseFunction · 0.85

Tested by 1

mainFunction · 0.68