8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / lp / lib / msgs / mcreate.c
blob445d9e24a79fdde9d2d65566bdfcbf24b1ee38be
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 1996 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 */
31 #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.7 */
33 # include <unistd.h>
34 # include <string.h>
35 # include <stropts.h>
36 # include <errno.h>
37 # include <stdlib.h>
39 # include "lp.h"
40 # include "msgs.h"
42 #if defined(__STDC__)
43 MESG * mcreate ( char * path )
44 #else
45 MESG * mcreate (path)
46 char *path;
47 #endif
49 int fds[2];
50 MESG *md;
52 if (pipe(fds) != 0)
53 return(NULL);
55 #if !defined(NOCONNLD)
56 if (ioctl(fds[1], I_PUSH, "connld") != 0)
57 return(NULL);
58 #endif
60 if (fattach(fds[1], path) != 0)
61 return(NULL);
63 if ((md = (MESG *)Malloc(MDSIZE)) == NULL)
64 return(NULL);
66 memset(md, 0, sizeof (MESG));
67 md->admin = 1;
68 md->file = Strdup(path);
69 md->gid = getgid();
70 md->readfd = fds[0];
71 md->state = MDS_IDLE;
72 md->type = MD_MASTER;
73 md->uid = getuid();
74 #if 1
75 md->writefd = fds[1];
76 #else
77 md->writefd = fds[0];
78 close(fds[1]);
79 #endif
81 return(md);