8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libpkg / common / ppkgmap.c
blobe84255202b767b62bad471039eb23f52d840cc4f
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
32 #include <stdio.h>
33 #include <string.h>
34 #include <limits.h>
35 #include <stdlib.h>
36 #include <unistd.h>
37 #include <sys/types.h>
38 #include "pkgstrct.h"
40 int holdcinfo = 0;
42 int
43 ppkgmap(struct cfent *ept, FILE *fp)
45 if (ept->path == NULL)
46 return (-1);
48 if (ept->volno) {
49 if (fprintf(fp, "%d ", ept->volno) < 0)
50 return (-1);
53 if (ept->ftype == 'i') {
54 if (fprintf(fp, "%c %s", ept->ftype, ept->path) < 0)
55 return (-1);
56 } else {
57 if (fprintf(fp, "%c %s %s", ept->ftype, ept->pkg_class,
58 ept->path) < 0)
59 return (-1);
62 if (ept->ainfo.local) {
63 if (fprintf(fp, "=%s", ept->ainfo.local) < 0)
64 return (-1);
67 if (strchr("cb", ept->ftype)) {
68 if (ept->ainfo.major == BADMAJOR) {
69 if (fprintf(fp, " ?") < 0)
70 return (-1);
71 } else {
72 if (fprintf(fp, " %ld", ept->ainfo.major) < 0)
73 return (-1);
75 if (ept->ainfo.minor == BADMINOR) {
76 if (fprintf(fp, " ?") < 0)
77 return (-1);
78 } else {
79 if (fprintf(fp, " %ld", ept->ainfo.minor) < 0)
80 return (-1);
84 if (strchr("dxcbpfve", ept->ftype)) {
85 if (fprintf(fp, ((ept->ainfo.mode == BADMODE) ? " ?" : " %04o"),
86 ept->ainfo.mode) < 0)
87 return (-1);
88 if (fprintf(fp, " %s %s", ept->ainfo.owner, ept->ainfo.group) <
90 return (-1);
92 if (holdcinfo) {
93 if (fputc('\n', fp) == EOF)
94 return (-1);
95 return (0);
98 if (strchr("ifve", ept->ftype)) {
99 if (fprintf(fp, ((ept->cinfo.size == BADCONT) ? " ?" : " %llu"),
100 ept->cinfo.size) < 0)
101 return (-1);
102 if (fprintf(fp, ((ept->cinfo.cksum == BADCONT) ? " ?" : " %ld"),
103 ept->cinfo.cksum) < 0)
104 return (-1);
105 if (fprintf(fp,
106 ((ept->cinfo.modtime == BADCONT) ? " ?" : " %ld"),
107 ept->cinfo.modtime) < 0)
108 return (-1);
111 if (ept->ftype == 'i') {
112 if (fputc('\n', fp) == EOF)
113 return (-1);
114 return (0);
116 if (fprintf(fp, "\n") < 0)
117 return (-1);
118 return (0);