本文整理汇总了C++中cupsFileClose函数的典型用法代码示例。如果您正苦于以下问题:C++ cupsFileClose函数的具体用法?C++ cupsFileClose怎么用?C++ cupsFileClose使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cupsFileClose函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: cupsdStopServer
void
cupsdStopServer(void)
{
if (!started)
return;
/*
* Stop color management (as needed)...
*/
cupsdStopColor();
/*
* Close all network clients...
*/
cupsdCloseAllClients();
cupsdStopListening();
cupsdStopBrowsing();
cupsdStopAllNotifiers();
cupsdDeleteAllCerts();
if (Clients)
{
cupsArrayDelete(Clients);
Clients = NULL;
}
/*
* Close the pipe for CGI processes...
*/
if (CGIPipes[0] >= 0)
{
cupsdRemoveSelect(CGIPipes[0]);
cupsdStatBufDelete(CGIStatusBuffer);
close(CGIPipes[1]);
CGIPipes[0] = -1;
CGIPipes[1] = -1;
}
/*
* Close all log files...
*/
if (AccessFile != NULL)
{
cupsFileClose(AccessFile);
AccessFile = NULL;
}
if (ErrorFile != NULL)
{
cupsFileClose(ErrorFile);
ErrorFile = NULL;
}
if (PageFile != NULL)
{
cupsFileClose(PageFile);
PageFile = NULL;
}
/*
* Delete the default security profile...
*/
cupsdDestroyProfile(DefaultProfile);
DefaultProfile = NULL;
/*
* Write out any dirty files...
*/
if (DirtyFiles)
cupsdCleanDirty();
started = 0;
}
开发者ID:ezeep,项目名称:cups,代码行数:84,代码来源:server.c
示例2: read_snmp_conf
static void
read_snmp_conf(const char *address) /* I - Single address to probe */
{
cups_file_t *fp; /* File pointer */
char filename[1024], /* Filename */
line[1024], /* Line from file */
*value; /* Value on line */
int linenum; /* Line number */
const char *cups_serverroot; /* CUPS_SERVERROOT env var */
const char *debug; /* CUPS_DEBUG_LEVEL env var */
const char *runtime; /* CUPS_MAX_RUN_TIME env var */
/*
* Initialize the global address and community lists...
*/
Addresses = cupsArrayNew(NULL, NULL);
Communities = cupsArrayNew(NULL, NULL);
if (address)
add_array(Addresses, address);
if ((debug = getenv("CUPS_DEBUG_LEVEL")) != NULL)
DebugLevel = atoi(debug);
if ((runtime = getenv("CUPS_MAX_RUN_TIME")) != NULL)
MaxRunTime = atoi(runtime);
/*
* Find the snmp.conf file...
*/
if ((cups_serverroot = getenv("CUPS_SERVERROOT")) == NULL)
cups_serverroot = CUPS_SERVERROOT;
snprintf(filename, sizeof(filename), "%s/snmp.conf", cups_serverroot);
if ((fp = cupsFileOpen(filename, "r")) != NULL)
{
/*
* Read the snmp.conf file...
*/
linenum = 0;
while (cupsFileGetConf(fp, line, sizeof(line), &value, &linenum))
{
if (!value)
fprintf(stderr, "ERROR: Missing value on line %d of %s!\n", linenum,
filename);
else if (!_cups_strcasecmp(line, "Address"))
{
if (!address)
add_array(Addresses, value);
}
else if (!_cups_strcasecmp(line, "Community"))
add_array(Communities, value);
else if (!_cups_strcasecmp(line, "DebugLevel"))
DebugLevel = atoi(value);
else if (!_cups_strcasecmp(line, "DeviceURI"))
{
if (*value != '\"')
fprintf(stderr,
"ERROR: Missing double quote for regular expression on "
"line %d of %s!\n", linenum, filename);
else
add_device_uri(value);
}
else if (!_cups_strcasecmp(line, "HostNameLookups"))
HostNameLookups = !_cups_strcasecmp(value, "on") ||
!_cups_strcasecmp(value, "yes") ||
!_cups_strcasecmp(value, "true") ||
!_cups_strcasecmp(value, "double");
else if (!_cups_strcasecmp(line, "MaxRunTime"))
MaxRunTime = atoi(value);
else
fprintf(stderr, "ERROR: Unknown directive %s on line %d of %s!\n",
line, linenum, filename);
}
cupsFileClose(fp);
}
/*
* Use defaults if parameters are undefined...
*/
if (cupsArrayCount(Addresses) == 0)
{
/*
* If we have no addresses, exit immediately...
*/
fprintf(stderr,
"DEBUG: No address specified and no Address line in %s...\n",
filename);
exit(0);
}
//.........这里部分代码省略.........
开发者ID:jianglei12138,项目名称:cups,代码行数:101,代码来源:snmp.c
示例3: update_smb
static void
update_smb(int onoff) /* I - 1 = turn on, 0 = turn off */
{
if (!SMBConfigFile)
return;
if (!strncmp(SMBConfigFile, "samba:///", 9))
{
/*
* Enable/disable SMB via the specified smb.conf config file...
*/
char newfile[1024]; /* New smb.conf.N file */
cups_file_t *ofp, /* Original file pointer */
*nfp; /* New file pointer */
char line[1024]; /* Line from file */
int in_printers; /* In [printers] section? */
snprintf(newfile, sizeof(newfile), "%s.N", SMBConfigFile + 8);
if ((ofp = cupsFileOpen(SMBConfigFile + 8, "r")) == NULL)
{
cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to open \"%s\" - %s",
SMBConfigFile + 8, strerror(errno));
return;
}
if ((nfp = cupsFileOpen(newfile, "w")) == NULL)
{
cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to create \"%s\" - %s",
newfile, strerror(errno));
cupsFileClose(ofp);
return;
}
/*
* Copy all of the lines from the smb.conf file...
*/
in_printers = 0;
while (cupsFileGets(ofp, line, sizeof(line)))
{
if (in_printers && strstr(line, "printable ="))
snprintf(line, sizeof(line), " printable = %s",
onoff ? "yes" : "no");
cupsFilePrintf(nfp, "%s\n", line);
if (line[0] == '[')
in_printers = !strcmp(line, "[printers]");
}
cupsFileClose(nfp);
cupsFileClose(ofp);
rename(newfile, SMBConfigFile + 8);
}
else
cupsdLogMessage(CUPSD_LOG_INFO, "Unknown SMBConfigFile scheme!");
}
开发者ID:AndychenCL,项目名称:cups,代码行数:61,代码来源:dirsvc.c
示例4: read_write_tests
//.........这里部分代码省略.........
/*
* cupsFilePuts() with partial line...
*/
fputs("cupsFilePuts(\"partial line\"): ", stdout);
if (cupsFilePuts(fp, partial_line) > 0)
puts("PASS");
else
{
printf("FAIL (%s)\n", strerror(errno));
status ++;
}
/*
* cupsFileTell()
*/
fputs("cupsFileTell(): ", stdout);
if ((length = cupsFileTell(fp)) == 81933283)
puts("PASS");
else
{
printf("FAIL (" CUPS_LLFMT " instead of 81933283)\n", CUPS_LLCAST length);
status ++;
}
/*
* cupsFileClose()
*/
fputs("cupsFileClose(): ", stdout);
if (!cupsFileClose(fp))
puts("PASS");
else
{
printf("FAIL (%s)\n", strerror(errno));
status ++;
}
}
else
{
printf("FAIL (%s)\n", strerror(errno));
status ++;
}
/*
* cupsFileOpen(read)
*/
fputs("\ncupsFileOpen(read): ", stdout);
fp = cupsFileOpen(compression ? "testfile.dat.gz" : "testfile.dat", "r");
if (fp)
{
puts("PASS");
/*
* cupsFileGets()
*/
fputs("cupsFileGets(): ", stdout);
开发者ID:MasterPlexus,项目名称:vendor_goldenve,代码行数:66,代码来源:testfile.c
示例5: main
//.........这里部分代码省略.........
if ((job_id = cupsCreateJob(CUPS_HTTP_DEFAULT, argv[2], "testcups", 0,
NULL)) <= 0)
{
printf("Unable to create print job on %s: %s\n", argv[1],
cupsLastErrorString());
return (1);
}
interval = atoi(argv[4]);
if (cupsStartDocument(CUPS_HTTP_DEFAULT, argv[1], job_id, argv[2],
CUPS_FORMAT_AUTO, 1) != HTTP_STATUS_CONTINUE)
{
puts("Unable to start document!");
return (1);
}
while ((bytes = cupsFileRead(fp, buffer, sizeof(buffer))) > 0)
{
printf("Writing %d bytes...\n", (int)bytes);
if (cupsWriteRequestData(CUPS_HTTP_DEFAULT, buffer,
bytes) != HTTP_STATUS_CONTINUE)
{
puts("Unable to write bytes!");
return (1);
}
if (interval > 0)
sleep(interval);
}
cupsFileClose(fp);
if (cupsFinishDocument(CUPS_HTTP_DEFAULT,
argv[1]) > IPP_STATUS_OK_IGNORED_OR_SUBSTITUTED)
{
puts("Unable to finish document!");
return (1);
}
}
else
{
puts("Usage:");
puts("");
puts("Run basic unit tests:");
puts("");
puts(" ./testcups");
puts("");
puts("Enumerate printers (for N seconds, -1 for indefinitely):");
puts("");
puts(" ./testcups enum [seconds]");
puts("");
puts("Ask for a password:");
puts("");
puts(" ./testcups password");
puts("");
puts("Get the PPD file:");
puts("");
puts(" ./testcups ppd printer");
puts("");
puts("Print a file (interval controls delay between buffers in seconds):");
puts("");
puts(" ./testcups print printer file interval");
return (1);
开发者ID:jelmer,项目名称:cups,代码行数:67,代码来源:testcups.c
示例6: helpLoadIndex
//.........这里部分代码省略.........
if (!anchor)
{
/*
* Get section...
*/
if (*ptr != '\"')
break;
ptr ++;
sectptr = ptr;
while (*ptr && *ptr != '\"')
ptr ++;
if (*ptr != '\"')
break;
*ptr++ = '\0';
strlcpy(section, sectptr, sizeof(section));
while (isspace(*ptr & 255))
ptr ++;
}
if (*ptr != '\"')
break;
ptr ++;
text = ptr;
while (*ptr && *ptr != '\"')
ptr ++;
if (*ptr != '\"')
break;
*ptr++ = '\0';
if ((node = help_new_node(filename, anchor, section, text,
mtime, offset, length)) == NULL)
break;
node->score = -1;
cupsArrayAdd(hi->nodes, node);
}
}
}
cupsFileClose(fp);
}
/*
* Scan for new/updated files...
*/
update = help_load_directory(hi, directory, NULL);
/*
* Remove any files that are no longer installed...
*/
for (node = (help_node_t *)cupsArrayFirst(hi->nodes);
node;
node = (help_node_t *)cupsArrayNext(hi->nodes))
if (node->score < 0)
{
/*
* Delete this node...
*/
cupsArrayRemove(hi->nodes, node);
help_delete_node(node);
}
/*
* Add nodes to the sorted array...
*/
for (node = (help_node_t *)cupsArrayFirst(hi->nodes);
node;
node = (help_node_t *)cupsArrayNext(hi->nodes))
cupsArrayAdd(hi->sorted, node);
/*
* Save the index if we updated it...
*/
if (update)
helpSaveIndex(hi, hifile);
/*
* Return the index...
*/
return (hi);
}
开发者ID:thangap,项目名称:tizen-release,代码行数:101,代码来源:help-index.c
示例7: help_load_file
//.........这里部分代码省略.........
{
/*
* Scan this line for words...
*/
for (ptr = line; *ptr; ptr ++)
{
/*
* Skip HTML stuff...
*/
if (*ptr == '<')
{
if (!strncmp(ptr, "<!--", 4))
{
/*
* Skip HTML comment...
*/
if ((text = strstr(ptr + 4, "-->")) == NULL)
ptr += strlen(ptr) - 1;
else
ptr = text + 2;
}
else
{
/*
* Skip HTML element...
*/
for (ptr ++; *ptr && *ptr != '>'; ptr ++)
{
if (*ptr == '\"' || *ptr == '\'')
{
for (quote = *ptr++; *ptr && *ptr != quote; ptr ++);
if (!*ptr)
ptr --;
}
}
if (!*ptr)
ptr --;
}
continue;
}
else if (*ptr == '&')
{
/*
* Skip HTML entity...
*/
for (ptr ++; *ptr && *ptr != ';'; ptr ++);
if (!*ptr)
ptr --;
continue;
}
else if (!isalnum(*ptr & 255))
continue;
/*
* Found the start of a word, search until we find the end...
*/
for (text = ptr, ptr ++; *ptr && isalnum(*ptr & 255); ptr ++);
wordlen = ptr - text;
memcpy(temp, text, wordlen);
temp[wordlen] = '\0';
ptr --;
if (wordlen > 1 && !bsearch(temp, help_common_words,
(sizeof(help_common_words) /
sizeof(help_common_words[0])),
sizeof(help_common_words[0]),
(int (*)(const void *, const void *))
_cups_strcasecmp))
help_add_word(node, temp);
}
}
/*
* Get the offset of the next line...
*/
offset = cupsFileTell(fp);
}
cupsFileClose(fp);
if (node)
node->length = offset - node->offset;
return (0);
}
开发者ID:thangap,项目名称:tizen-release,代码行数:101,代码来源:help-index.c
示例8: print_file
static void
print_file(http_t *http, /* I - Connection to destination */
cups_dest_t *dest, /* I - Destination */
cups_dinfo_t *dinfo, /* I - Destination information */
const char *filename, /* I - File to print */
int num_options, /* I - Number of options */
cups_option_t *options) /* I - Options */
{
cups_file_t *fp; /* File to print */
int job_id; /* Job ID */
ipp_status_t status; /* Submission status */
const char *title; /* Title of job */
char buffer[32768]; /* File buffer */
ssize_t bytes; /* Bytes read/to write */
if ((fp = cupsFileOpen(filename, "r")) == NULL)
{
printf("Unable to open \"%s\": %s\n", filename, strerror(errno));
return;
}
if ((title = strrchr(filename, '/')) != NULL)
title ++;
else
title = filename;
if ((status = cupsCreateDestJob(http, dest, dinfo, &job_id, title, num_options, options)) > IPP_STATUS_OK_IGNORED_OR_SUBSTITUTED)
{
printf("Unable to create job: %s\n", cupsLastErrorString());
cupsFileClose(fp);
return;
}
printf("Created job ID: %d\n", job_id);
if (cupsStartDestDocument(http, dest, dinfo, job_id, title, CUPS_FORMAT_AUTO, 0, NULL, 1) != HTTP_STATUS_CONTINUE)
{
printf("Unable to send document: %s\n", cupsLastErrorString());
cupsFileClose(fp);
return;
}
while ((bytes = cupsFileRead(fp, buffer, sizeof(buffer))) > 0)
{
if (cupsWriteRequestData(http, buffer, (size_t)bytes) != HTTP_STATUS_CONTINUE)
{
printf("Unable to write document data: %s\n", cupsLastErrorString());
break;
}
}
cupsFileClose(fp);
if ((status = cupsFinishDestDocument(http, dest, dinfo)) > IPP_STATUS_OK_IGNORED_OR_SUBSTITUTED)
{
printf("Unable to send document: %s\n", cupsLastErrorString());
return;
}
puts("Job queued.");
}
开发者ID:lanceit,项目名称:cups,代码行数:62,代码来源:testdest.c
示例9: main
int /* O - Exit code */
main(int argc, /* I - Number of command-line args */
char *argv[]) /* I - Command-line arguments */
{
int i; /* Looping var */
const char *pofile, /* .po filename */
*stringsfile; /* .strings filename */
cups_file_t *po, /* .po file */
*strings; /* .strings file */
char s[4096], /* String buffer */
*ptr, /* Pointer into buffer */
*temp, /* New string */
*msgid, /* msgid string */
*msgstr, /* msgstr string */
normalized[8192];/* Normalized msgid string */
size_t length; /* Length of combined strings */
int use_msgid; /* Use msgid strings for msgstr? */
/*
* Process command-line arguments...
*/
pofile = NULL;
stringsfile = NULL;
use_msgid = 0;
for (i = 1; i < argc; i ++)
{
if (!strcmp(argv[i], "-m"))
use_msgid = 1;
else if (argv[i][0] == '-')
{
puts("Usage: po2strings [-m] filename.po filename.strings");
return (1);
}
else if (!pofile)
pofile = argv[i];
else if (!stringsfile)
stringsfile = argv[i];
else
{
puts("Usage: po2strings [-m] filename.po filename.strings");
return (1);
}
}
if (!pofile || !stringsfile)
{
puts("Usage: po2strings [-m] filename.po filename.strings");
return (1);
}
/*
* Read strings from the .po file and write to the .strings file...
*/
if ((po = cupsFileOpen(pofile, "r")) == NULL)
{
perror(pofile);
return (1);
}
if ((strings = cupsFileOpen(stringsfile, "w")) == NULL)
{
perror(stringsfile);
cupsFileClose(po);
return (1);
}
msgid = msgstr = NULL;
while (cupsFileGets(po, s, sizeof(s)) != NULL)
{
if (s[0] == '#' && s[1] == '.')
{
/*
* Copy comment string...
*/
if (msgid && msgstr)
{
/*
* First output the last localization string...
*/
if (*msgid)
cupsFilePrintf(strings, "\"%s\" = \"%s\";\n", msgid,
(use_msgid || !*msgstr) ? msgid : msgstr);
free(msgid);
free(msgstr);
msgid = msgstr = NULL;
}
cupsFilePrintf(strings, "//%s\n", s + 2);
}
else if (s[0] == '#' || !s[0])
{
/*
//.........这里部分代码省略.........
开发者ID:krichter722,项目名称:cups,代码行数:101,代码来源:po2strings.c
示例10: main
//.........这里部分代码省略.........
i ++;
if (helpfile && !strcmp(helpfile, n->filename))
{
help_node_t *nn; /* Pointer to sub-node */
cupsArraySave(hi->sorted);
for (nn = (help_node_t *)cupsArrayFirst(hi->sorted);
nn;
nn = (help_node_t *)cupsArrayNext(hi->sorted))
if (nn->anchor && !strcmp(helpfile, nn->filename))
{
/*
* Add a link for this node...
*/
snprintf(line, sizeof(line), "#%s", nn->anchor);
cgiSetArray("BMLINK", i, line);
cgiSetArray("BMTEXT", i, nn->text);
cgiSetArray("BMINDENT", i, "2");
i ++;
}
cupsArrayRestore(hi->sorted);
}
}
/*
* Show the search and bookmark content...
*/
if (!helpfile || !printable)
cgiCopyTemplateLang("help-header.tmpl");
else
cgiCopyTemplateLang("help-printable.tmpl");
/*
* If we are viewing a file, copy it in now...
*/
if (helpfile)
{
if ((fp = cupsFileOpen(filename, "r")) != NULL)
{
int inbody; /* Are we inside the body? */
inbody = 0;
while (cupsFileGets(fp, line, sizeof(line)))
{
if (inbody)
{
if (!_cups_strncasecmp(line, "</BODY>", 7))
break;
printf("%s\n", line);
}
else if (!_cups_strncasecmp(line, "<BODY", 5))
inbody = 1;
}
cupsFileClose(fp);
}
else
{
perror(filename);
cgiSetVariable("ERROR", cgiText(_("Unable to open help file.")));
cgiCopyTemplateLang("error.tmpl");
}
}
/*
* Send a standard trailer...
*/
if (!printable)
{
cgiCopyTemplateLang("help-trailer.tmpl");
cgiEndHTML();
}
else
puts("</BODY>\n</HTML>");
/*
* Delete the index...
*/
helpDeleteIndex(hi);
/*
* Return with no errors...
*/
return (0);
}
开发者ID:AnotherView,项目名称:cups,代码行数:101,代码来源:help.c
示例11: make_certificate
static int /* O - 1 on success, 0 on failure */
make_certificate(cupsd_client_t *con) /* I - Client connection */
{
gnutls_x509_crt crt; /* Self-signed certificate */
gnutls_x509_privkey key; /* Encryption key */
cups_lang_t *language; /* Default language info */
cups_file_t *fp; /* Key/cert file */
unsigned char buffer[8192]; /* Buffer for x509 data */
size_t bytes; /* Number of bytes of data */
unsigned char serial[4]; /* Serial number buffer */
time_t curtime; /* Current time */
int result; /* Result of GNU TLS calls */
/*
* Create the encryption key...
*/
cupsdLogMessage(CUPSD_LOG_INFO, "Generating SSL server key...");
gnutls_x509_privkey_init(&key);
gnutls_x509_privkey_generate(key, GNUTLS_PK_RSA, 2048, 0);
/*
* Save it...
*/
bytes = sizeof(buffer);
if ((result = gnutls_x509_privkey_export(key, GNUTLS_X509_FMT_PEM,
buffer, &bytes)) < 0)
{
cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to export SSL server key - %s",
gnutls_strerror(result));
gnutls_x509_privkey_deinit(key);
return (0);
}
else if ((fp = cupsFileOpen(ServerKey, "w")) != NULL)
{
cupsFileWrite(fp, (char *)buffer, bytes);
cupsFileClose(fp);
cupsdLogMessage(CUPSD_LOG_INFO, "Created SSL server key file \"%s\"...",
ServerKey);
}
else
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"Unable to create SSL server key file \"%s\" - %s",
ServerKey, strerror(errno));
gnutls_x509_privkey_deinit(key);
return (0);
}
/*
* Create the self-signed certificate...
*/
cupsdLogMessage(CUPSD_LOG_INFO, "Generating self-signed SSL certificate...");
language = cupsLangDefault();
curtime = time(NULL);
serial[0] = curtime >> 24;
serial[1] = curtime >> 16;
serial[2] = curtime >> 8;
serial[3] = curtime;
gnutls_x509_crt_init(&crt);
if (strlen(language->language) == 5)
gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_COUNTRY_NAME, 0,
language->language + 3, 2);
else
gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_COUNTRY_NAME, 0,
"US", 2);
gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_COMMON_NAME, 0,
ServerName, strlen(ServerName));
gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_ORGANIZATION_NAME, 0,
ServerName, strlen(ServerName));
gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_ORGANIZATIONAL_UNIT_NAME,
0, "Unknown", 7);
gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_STATE_OR_PROVINCE_NAME, 0,
"Unknown", 7);
gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_X520_LOCALITY_NAME, 0,
"Unknown", 7);
gnutls_x509_crt_set_dn_by_oid(crt, GNUTLS_OID_PKCS9_EMAIL, 0,
ServerAdmin, strlen(ServerAdmin));
gnutls_x509_crt_set_key(crt, key);
gnutls_x509_crt_set_serial(crt, serial, sizeof(serial));
gnutls_x509_crt_set_activation_time(crt, curtime);
gnutls_x509_crt_set_expiration_time(crt, curtime + 10 * 365 * 86400);
gnutls_x509_crt_set_ca_status(crt, 0);
gnutls_x509_crt_set_subject_alternative_name(crt, GNUTLS_SAN_DNSNAME,
ServerName);
gnutls_x509_crt_set_key_purpose_oid(crt, GNUTLS_KP_TLS_WWW_SERVER, 0);
gnutls_x509_crt_set_key_usage(crt, GNUTLS_KEY_KEY_ENCIPHERMENT);
gnutls_x509_crt_set_version(crt, 3);
bytes = sizeof(buffer);
if (gnutls_x509_crt_get_key_id(crt, 0, buffer, &bytes) >= 0)
gnutls_x509_crt_set_subject_key_id(crt, buffer, bytes);
//.........这里部分代码省略.........
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:101,代码来源:tls-gnutls.c
示例12: get_device
//.........这里部分代码省略.........
}
if (*ptr != '\"')
goto error;
for (*ptr++ = '\0'; isspace(*ptr & 255); *ptr++ = '\0');
/*
* device-info
*/
if (*ptr != '\"')
goto error;
for (ptr ++, info = ptr; *ptr && *ptr != '\"'; ptr ++)
{
if (*ptr == '\\' && ptr[1])
_cups_strcpy(ptr, ptr + 1);
}
if (*ptr != '\"')
goto error;
for (*ptr++ = '\0'; isspace(*ptr & 255); *ptr++ = '\0');
/*
* device-id
*/
if (*ptr == '\"')
{
for (ptr ++, device_id = ptr; *ptr && *ptr != '\"'; ptr ++)
{
if (*ptr == '\\' && ptr[1])
_cups_strcpy(ptr, ptr + 1);
}
if (*ptr != '\"')
goto error;
for (*ptr++ = '\0'; isspace(*ptr & 255); *ptr++ = '\0');
/*
* device-location
*/
if (*ptr == '\"')
{
for (ptr ++, location = ptr; *ptr && *ptr != '\"'; ptr ++)
{
if (*ptr == '\\' && ptr[1])
_cups_strcpy(ptr, ptr + 1);
}
if (*ptr != '\"')
goto error;
*ptr = '\0';
}
else
location = NULL;
}
else
{
device_id = NULL;
location = NULL;
}
/*
* Add the device to the array of available devices...
*/
if (!add_device(dclass, make_model, info, uri, device_id, location))
fprintf(stderr, "DEBUG: [cups-deviced] Found device \"%s\"...\n", uri);
return (0);
}
/*
* End of file...
*/
cupsFileClose(backend->pipe);
backend->pipe = NULL;
return (-1);
/*
* Bad format; strip trailing newline and write an error message.
*/
error:
if (line[strlen(line) - 1] == '\n')
line[strlen(line) - 1] = '\0';
fprintf(stderr, "ERROR: [cups-deviced] Bad line from \"%s\": %s\n",
backend->name, line);
return (0);
}
开发者ID:josephgbr,项目名称:cups-pt_BR,代码行数:101,代码来源:cups-deviced.c
示例13: set_printer_options
//.........这里部分代码省略.........
ppdfile = file;
else if (request->request.op.operation_id == CUPS_ADD_MODIFY_PRINTER)
ppdfile = cupsGetPPD(printer);
else
ppdfile = NULL;
if (ppdfile != NULL)
{
/*
* Set default options in the PPD file...
*/
ppd = ppdOpenFile(ppdfile);
ppdMarkDefaults(ppd);
cupsMarkOptions(ppd, num_options, options);
if ((out = cupsTempFile2(tempfile, sizeof(tempfile))) == NULL)
{
_cupsLangPrintError(NULL, _("lpadmin: Unable to create temporary file"));
ippDelete(request);
if (ppdfile != file)
unlink(ppdfile);
return (1);
}
if ((in = cupsFileOpen(ppdfile, "r")) == NULL)
{
_cupsLangPrintf(stderr,
_("lpadmin: Unable to open PPD file \"%s\" - %s"),
ppdfile, strerror(errno));
ippDelete(request);
if (ppdfile != file)
unlink(ppdfile);
cupsFileClose(out);
unlink(tempfile);
return (1);
}
ppdchanged = 0;
while (cupsFileGets(in, line, sizeof(line)))
{
if (!strncmp(line, "*cupsIPPSupplies:", 17) &&
(boolval = cupsGetOption("cupsIPPSupplies", num_options,
options)) != NULL)
{
wrote_ipp_supplies = 1;
cupsFilePrintf(out, "*cupsIPPSupplies: %s\n",
(!_cups_strcasecmp(boolval, "true") ||
!_cups_strcasecmp(boolval, "yes") ||
!_cups_strcasecmp(boolval, "on")) ? "True" : "False");
}
else if (!strncmp(line, "*cupsSNMPSupplies:", 18) &&
(boolval = cupsGetOption("cupsSNMPSupplies", num_options,
options)) != NULL)
{
wrote_snmp_supplies = 1;
cupsFilePrintf(out, "*cupsSNMPSupplies: %s\n",
(!_cups_strcasecmp(boolval, "true") ||
!_cups_strcasecmp(boolval, "yes") ||
!_cups_strcasecmp(boolval, "on")) ? "True" : "False");
}
else if (strncmp(line, "*Default", 8))
cupsFilePrintf(out, "%s\n", line);
else
{
开发者ID:thangap,项目名称:tizen-release,代码行数:67,代码来源:lpadmin.c
示例14: main
//.........这里部分代码省略.........
status = 1;
}
else if (attr->num_values != 2)
{
printf("FAIL (wrong count - %d)\n", attr->num_values);
status = 1;
}
else if (attr->values[0].range.lower != 1 ||
attr->values[0].range.upper != 1 ||
attr->values[1].range.lower != 16 ||
attr->values[1].range.upper != 32)
{
printf("FAIL (wrong values - %d,%d and %d,%d)\n",
attr->values[0].range.lower,
attr->values[0].range.upper,
attr->values[1].range.lower,
attr->values[1].range.upper);
status = 1;
}
else
puts("PASS");
ippDelete(request);
#ifdef DEBUG
/*
* Test that private option array is sorted...
*/
fputs("_ippCheckOptions: ", stdout);
if ((name = _ippCheckOptions()) == NULL)
puts("PASS");
else
{
printf("FAIL (\"%s\" out of order)\n", name);
status = 1;
}
#endif /* DEBUG */
/*
* Test _ippFindOption() private API...
*/
fputs("_ippFindOption(\"printer-type\"): ", stdout);
if (_ippFindOption("printer-type"))
puts("PASS");
else
{
puts("FAIL");
status = 1;
}
/*
* Summarize...
*/
putchar('\n');
if (status)
puts("Core IPP tests failed.");
else
puts("Core IPP tests passed.");
}
else
{
/*
* Read IPP files...
*/
for (i = 1; i < (size_t)argc; i ++)
{
if ((fp = cupsFileOpen(argv[i], "r")) == NULL)
{
printf("Unable to open \"%s\" - %s\n", argv[i], strerror(errno));
status = 1;
continue;
}
request = ippNew();
while ((state = ippReadIO(fp, (ipp_iocb_t)cupsFileRead, 1, NULL,
request)) == IPP_STATE_ATTRIBUTE);
if (state != IPP_STATE_DATA)
{
printf("Error reading IPP message from \"%s\"!\n", argv[i]);
status = 1;
}
else
{
printf("\n%s:\n", argv[i]);
print_attributes(request, 4);
}
ippDelete(request);
cupsFileClose(fp);
}
}
return (status);
}
开发者ID:lanceit,项目名称:cups,代码行数:101,代码来源:testipp.c
示例15: make_certificate
static int /* O - 1 on success, 0 on failure */
make_certificate(cupsd_client_t *con) /* I - Client connection */
{
int pid, /* Process ID of command */
status; /* Status of command */
char command[1024], /* Command */
*argv[4], /* Command-line arguments */
*envp[MAX_ENV + 1], /* Environment variables */
keychain[1024], /* Keychain argument */
infofile[1024], /* Type-in information for cert */
# if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
localname[1024], /* Local hostname */
# endif /* HAVE_DNSSD || HAVE_AVAHI */
*servername; /* Name of server in cert */
cups_file_t *fp; /* Seed/info file */
int infofd; /* Info file descriptor */
# if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
if (con->servername && isdigit(con->servername[0] & 255) && DNSSDHostName)
{
snprintf(localname, sizeof(localname), "%s.local", DNSSDHostName);
servername = localname;
}
else
# endif /* HAVE_DNSSD || HAVE_AVAHI */
servername = con->servername;
/*
* Run the "certtool" command to generate a self-signed certificate...
*/
if (!cupsFileFind("certtool", getenv("PATH"), 1, command, sizeof(command)))
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"No SSL certificate and certtool command not found!");
return (0);
}
/*
* Create a file with the certificate information fields...
*
* Note: This assumes that the default questions are asked by the certtool
* command...
*/
if ((fp = cupsTempFile2(infofile, sizeof(infofile))) == NULL)
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"Unable to create certificate information file %s - %s",
infofile, strerror(errno));
return (0);
}
cupsFilePrintf(fp,
"%s\n" /* Enter key and certificate label */
"r\n" /* Generate RSA key pair */
"2048\n" /* Key size in bits */
"y\n" /* OK (y = yes) */
"b\n" /* Usage (b=signing/encryption) */
"s\n" /* Sign with SHA1 */
"y\n" /* OK (y = yes) */
"%s\n" /* Common name */
"\n" /* Country (default) */
"\n" /* Organization (default) */
"\n" /* Organizational unit (default) */
"\n" /* State/Province (default) */
"%s\n" /* Email address */
"y\n", /* OK (y = yes) */
servername, servername, ServerAdmin);
cupsFileClose(fp);
cupsdLogMessage(CUPSD_LOG_INFO,
"Generating SSL server key and certificate...");
snprintf(keychain, sizeof(keychain), "k=%s", ServerCertificate);
argv[0] = "certtool";
argv[1] = "c";
argv[2] = keychain;
argv[3] = NULL;
cupsdLoadEnv(envp, MAX_ENV);
infofd = open(infofile, O_RDONLY);
if (!cupsdStartProcess(command, argv, envp, infofd, -1, -1, -1, -1, 1, NULL,
NULL, &pid))
{
close(infofd);
unlink(infofile);
return (0);
}
close(infofd);
unlink(infofile);
while (waitpid(pid, &status, 0) < 0)
if (errno != EINTR)
{
//.........这里部分代码省略.........
开发者ID:josephgbr,项目名称:cups-pt_BR,代码行数:101,代码来源:tls-darwin.c
示例16: cupsdCreateProfile
//.........这里部分代码省略.........
" #\"^/Library/Printers/PPDs$\""
" #\"^/Library/Printers/PPDs/\""
" #\"^/Library/Printers/PPD Plugins$\""
" #\"^/Library/Printers/PPD Plugins/\""
")%s)\n", nodebug);
}
/* Allow execution of child processes as long as the programs are not in a user directory */
cupsFilePuts(fp, "(allow process*)\n");
cupsFilePuts(fp, "(deny process-exec (regex #\"^/Users/\"))\n");
if (RunUser && getenv("CUPS_TESTROOT"))
{
/* Allow source directory access in "make test" environment */
char testroot[1024]; /* Root directory of test files */
cupsd_requote(testroot, getenv("CUPS_TESTROOT"), sizeof(testroot));
cupsFilePrintf(fp,
"(allow file-write* file-read-data file-read-metadata\n"
" (regex"
" #\"^%s$\"" /* CUPS_TESTROOT */
" #\"^%s/\"" /* CUPS_TESTROOT/... */
"))\n",
testroot, testroot);
cupsFilePrintf(fp,
"(allow process-exec\n"
" (regex"
" #\"^%s/\"" /* CUPS_TESTROOT/... */
"))\n",
testroot);
cupsFilePrintf(fp, "(allow sysctl*)\n");
}
if (job_id)
{
/* Allow job filters to read the current job files... */
cupsFilePrintf(fp,
"(allow file-read-data file-read-metadata\n"
" (regex #\"^%s/([ac]%05d|d%05d-[0-9][0-9][0-9])$\"))\n",
request, job_id, job_id);
}
else
{
/* Allow email notifications from notifiers... */
cupsFilePuts(fp,
"(allow process-exec\n"
" (literal \"/usr/sbin/sendmail\")\n"
" (with no-sandbox))\n");
}
/* Allow access to Bluetooth, USB, and notify_post. */
cupsFilePuts(fp, "(allow iokit*)\n");
cupsFilePuts(fp, "(allow distributed-notification-post)\n");
/* Allow outbound networking to local services */
cupsFilePuts(fp, "(allow network-outbound"
"\n (regex #\"^/private/var/run/\" #\"^/private/tmp/\" #\"^/private/var/tmp/\")");
for (lis = (cupsd_listener_t *)cupsArrayFirst(Listeners);
lis;
lis = (cupsd_listener_t *)cupsArrayNext(Listeners))
{
if (httpAddrFamily(&(lis->address)) == AF_LOCAL)
{
httpAddrString(&(lis->address), domain, sizeof(domain));
cupsFilePrintf(fp, "\n (literal \"%s\")", domain);
}
}
if (allow_networking)
{
/* Allow TCP and UDP networking off the machine... */
cupsFilePuts(fp, "\n (remote tcp))\n");
cupsFilePuts(fp, "(allow network-bind)\n"); /* for LPD resvport */
cupsFilePuts(fp, "(allow network*\n"
" (local udp \"*:*\")\n"
" (remote udp \"*:*\"))\n");
/* Also allow access to device files... */
cupsFilePuts(fp, "(allow file-write* file-read-data file-read-metadata file-ioctl\n"
" (regex #\"^/dev/\"))\n");
/* And allow kernel extensions to be loaded, e.g., SMB */
cupsFilePuts(fp, "(allow system-kext-load)\n");
}
else
{
/* Only allow SNMP (UDP) and LPD (TCP) off the machine... */
cupsFilePuts(fp, ")\n");
cupsFilePuts(fp, "(allow network-outbound\n"
" (remote udp \"*:161\")\n"
" (remote tcp \"*:515\"))\n");
cupsFilePuts(fp, "(allow network-inbound\n"
" (local udp \"localhost:*\"))\n");
}
cupsFileClose(fp);
cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdCreateProfile(job_id=%d,allow_networking=%d) = \"%s\"", job_id, allow_networking, profile);
return ((void *)strdup(profile));
#else
cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdCreateProfile(job_id=%d, allow_networking=%d) = NULL", job_id, allow_networking);
return (NULL);
#endif /* HAVE_SANDBOX_H */
}
开发者ID:Cacauu,项目名称:cups,代码行数:101,代码来源:process.c
示例17: _cupsSetDefaults
void
_cupsSetDefaults(void)
{
cups_file_t *fp; /* File */
const char *home; /* Home directory of user */
char filename[1024]; /* Filename */
_cups_client_conf_t cc; /* client.conf values */
_cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
DEBUG_puts("_cupsSetDefaults()");
/*
* Load initial client.conf values...
*/
cups_init_client_conf(&cc);
/*
* Read the /etc/cups/client.conf and ~/.cups/client.conf files, if
* present.
*/
snprintf(filename, sizeof(filename), "%s/client.conf", cg->cups_serverroot);
if ((fp = cupsFileOpen(filename, "r")) != NULL)
{
cups_read_client_conf(fp, &cc);
cupsFileClose(fp);
}
# ifdef HAVE_GETEUID
if ((geteuid() == getuid() || !getuid()) && getegid() == getgid() && (home = getenv("HOME")) != NULL)
# elif !defined(WIN32)
if (getuid() && (home = getenv("HOME")) != NULL)
# else
if ((home = getenv("HOME")) != NULL)
# endif /* HAVE_GETEUID */
{
/*
* Look for ~/.cups/client.conf...
*/
snprintf(filename, sizeof(filename), "%s/.cups/client.conf", home);
if ((fp = cupsFileOpen(filename, "r")) != NULL)
{
cups_read_client_conf(fp, &cc);
cupsFileClose(fp);
}
}
/*
* Finalize things so every client.conf value is set...
*/
cups_finalize_client_conf(&cc);
if (cg->encryption == (http_encryption_t)-1)
cg->encryption = cc.encryption;
if (!cg->server[0] || !cg->ipp_port)
cupsSetServer(cc.server_name);
if (!cg->ipp_port)
cups_set_default_ipp_port(cg);
if (!cg->user[0])
strlcpy(cg->user, cc.user, sizeof(cg->user));
#ifdef HAVE_GSSAPI
if (!cg->gss_service_name[0])
strlcpy(cg->gss_service_name, cc.gss_service_name, sizeof(cg->gss_service_name));
#endif /* HAVE_GSSAPI */
if (cg->any_root < 0)
cg->any_root = cc.any_root;
if (cg->expired_certs < 0)
cg->expired_certs = cc.expired_certs;
if (cg->validate_certs < 0)
cg->validate_certs = cc.validate_certs;
#ifdef HAVE_SSL
_httpTLSSetOptions(cc.ssl_options);
#endif /* HAVE_SSL */
}
开发者ID:Cacauu,项目名称:cups,代码行数:86,代码来源:usersys.c
示例18: helpSaveIndex
int /* O - 0 on success, -1 on error */
helpSaveIndex(help_index_t *hi, /* I - Index */
|
请发表评论