Mercurial > illumos > illumos-gate
comparison usr/src/cmd/fs.d/smbclnt/smbutil/print.c @ 13394:96340372b72d
1120 Use real file descriptors for smbfs named pipes.
Reviewed by: Eric Schrock <eric.schrock@delphix.com>
Reviewed by: Albert Lee <trisk@nexenta.com>
Approved by: Garrett D'Amore <garrett@nexenta.com>
author | Gordon Ross <gwr@nexenta.com> |
---|---|
date | Thu, 30 Jun 2011 17:58:05 -0400 |
parents | 71bf38dba3d6 |
children |
comparison
equal
deleted
inserted
replaced
13393:a055831123f1 | 13394:96340372b72d |
---|---|
31 * | 31 * |
32 * from: Id: print.c,v 1.4 2001/01/28 07:35:01 bp Exp | 32 * from: Id: print.c,v 1.4 2001/01/28 07:35:01 bp Exp |
33 */ | 33 */ |
34 | 34 |
35 /* | 35 /* |
36 * Copyright 2011 Nexenta Systems, Inc. All rights reserved. | |
36 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. | 37 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. |
37 * Use is subject to license terms. | 38 * Use is subject to license terms. |
38 */ | 39 */ |
39 | 40 |
40 #include <sys/types.h> | 41 #include <sys/types.h> |
148 | 149 |
149 /* | 150 /* |
150 * Have the printer share connection. | 151 * Have the printer share connection. |
151 * Print the file. | 152 * Print the file. |
152 */ | 153 */ |
153 snprintf(titlebuf, sizeof (titlebuf), "%s_%s", | 154 snprintf(titlebuf, sizeof (titlebuf), "%s %s", |
154 ctx->ct_user, filename); | 155 ctx->ct_user, filename); |
155 | 156 |
156 error = print_file(ctx, titlebuf, file); | 157 error = print_file(ctx, titlebuf, file); |
157 | 158 |
158 | 159 |
183 | 184 |
184 static int | 185 static int |
185 print_file(smb_ctx_t *ctx, char *title, int file) | 186 print_file(smb_ctx_t *ctx, char *title, int file) |
186 { | 187 { |
187 off_t offset; | 188 off_t offset; |
188 int error, rcnt, wcnt; | 189 int rcnt, wcnt; |
189 int setup_len = 0; /* No printer setup data */ | 190 int setup_len = 0; /* No printer setup data */ |
190 int mode = MODE_GRAPHICS; /* treat as raw data */ | 191 int mode = MODE_GRAPHICS; /* treat as raw data */ |
191 int fh = -1; | 192 int error = 0; |
192 | 193 int pfd = -1; |
193 error = smb_printer_open(ctx, setup_len, mode, title, &fh); | 194 |
194 if (error) { | 195 pfd = smb_open_printer(ctx, title, setup_len, mode); |
196 if (pfd < 0) { | |
197 error = errno; | |
195 smb_error("could not open print job", error); | 198 smb_error("could not open print job", error); |
196 return (error); | 199 return (error); |
197 } | 200 } |
198 | 201 |
199 offset = 0; | 202 offset = 0; |
205 break; | 208 break; |
206 } | 209 } |
207 if (rcnt == 0) | 210 if (rcnt == 0) |
208 break; | 211 break; |
209 | 212 |
210 wcnt = smb_fh_write(ctx, fh, offset, rcnt, databuf); | 213 wcnt = smb_fh_write(pfd, offset, rcnt, databuf); |
211 if (wcnt < 0) { | 214 if (wcnt < 0) { |
212 error = errno; | 215 error = errno; |
213 smb_error("error writing spool file\n", error); | 216 smb_error("error writing spool file\n", error); |
214 break; | 217 break; |
215 } | 218 } |
219 break; | 222 break; |
220 } | 223 } |
221 offset += wcnt; | 224 offset += wcnt; |
222 } | 225 } |
223 | 226 |
224 (void) smb_printer_close(ctx, fh); | 227 (void) smb_fh_close(pfd); |
225 return (error); | 228 return (error); |
226 } | 229 } |