3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 *
26 */
27
28 /* $Id: attribute.c 157 2006-04-26 15:07:55Z ktou $ */
29
30 #pragma ident "%Z%%M% %I% %E% SMI"
31
32 /*LINTLIBRARY*/
33
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <stdarg.h>
37 #include <string.h>
38 #include <ctype.h>
39 #include <alloca.h>
40 #include <papi.h>
41 #include <regex.h>
42
43 #define MAX_PAGES 32767
44 /*
45 * Assuming the maximum number of pages in
46 * a document to be 32767
47 */
48
49 static void papiAttributeFree(papi_attribute_t *attribute);
50
51 static void
940 rc = strlcat(buffer, string, buflen);
941 }
942 break;
943 case PAPI_RESOLUTION: {
944 char string[24];
945
946 snprintf(string, sizeof (string), "%dx%ddp%c",
947 values[i]->resolution.xres,
948 values[i]->resolution.yres,
949 (values[i]->resolution.units == PAPI_RES_PER_CM
950 ? 'c' : 'i'));
951 rc = strlcat(buffer, string, buflen);
952 }
953 break;
954 case PAPI_DATETIME: {
955 struct tm *tm = localtime(&values[i]->datetime);
956
957 if (tm != NULL) {
958 char string[64];
959
960 strftime(string, sizeof (string), "%C", tm);
961 rc = strlcat(buffer, string, buflen);
962 }}
963 break;
964 case PAPI_COLLECTION: {
965 char *string = alloca(buflen);
966
967 papiAttributeListToString(values[i]->collection,
968 delim, string, buflen);
969 rc = strlcat(buffer, string, buflen);
970 }
971 break;
972 default: {
973 char string[32];
974
975 snprintf(string, sizeof (string), "unknown-type-0x%x",
976 attribute->type);
977 rc = strlcat(buffer, string, buflen);
978 }
979 }
980 if (values[i+1] != NULL)
|
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2014 Gary Mills
24 *
25 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
27 *
28 */
29
30 /* $Id: attribute.c 157 2006-04-26 15:07:55Z ktou $ */
31
32 /*LINTLIBRARY*/
33
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <stdarg.h>
37 #include <string.h>
38 #include <ctype.h>
39 #include <alloca.h>
40 #include <papi.h>
41 #include <regex.h>
42
43 #define MAX_PAGES 32767
44 /*
45 * Assuming the maximum number of pages in
46 * a document to be 32767
47 */
48
49 static void papiAttributeFree(papi_attribute_t *attribute);
50
51 static void
940 rc = strlcat(buffer, string, buflen);
941 }
942 break;
943 case PAPI_RESOLUTION: {
944 char string[24];
945
946 snprintf(string, sizeof (string), "%dx%ddp%c",
947 values[i]->resolution.xres,
948 values[i]->resolution.yres,
949 (values[i]->resolution.units == PAPI_RES_PER_CM
950 ? 'c' : 'i'));
951 rc = strlcat(buffer, string, buflen);
952 }
953 break;
954 case PAPI_DATETIME: {
955 struct tm *tm = localtime(&values[i]->datetime);
956
957 if (tm != NULL) {
958 char string[64];
959
960 strftime(string, sizeof (string), "%c", tm);
961 rc = strlcat(buffer, string, buflen);
962 }}
963 break;
964 case PAPI_COLLECTION: {
965 char *string = alloca(buflen);
966
967 papiAttributeListToString(values[i]->collection,
968 delim, string, buflen);
969 rc = strlcat(buffer, string, buflen);
970 }
971 break;
972 default: {
973 char string[32];
974
975 snprintf(string, sizeof (string), "unknown-type-0x%x",
976 attribute->type);
977 rc = strlcat(buffer, string, buflen);
978 }
979 }
980 if (values[i+1] != NULL)
|