Changeset 745 for trunk/server/source3/libsmb/libsmb_printjob.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/libsmb/libsmb_printjob.c
r414 r745 8 8 Copyright (C) Derrell Lipman 2003-2008 9 9 Copyright (C) Jeremy Allison 2007, 2008 10 10 11 11 This program is free software; you can redistribute it and/or modify 12 12 it under the terms of the GNU General Public License as published by 13 13 the Free Software Foundation; either version 3 of the License, or 14 14 (at your option) any later version. 15 15 16 16 This program is distributed in the hope that it will be useful, 17 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 19 GNU General Public License for more details. 20 20 21 21 You should have received a copy of the GNU General Public License 22 22 along with this program. If not, see <http://www.gnu.org/licenses/>. … … 24 24 25 25 #include "includes.h" 26 #include "libsmb/libsmb.h" 26 27 #include "libsmbclient.h" 27 28 #include "libsmb_internal.h" … … 42 43 char *path = NULL; 43 44 TALLOC_CTX *frame = talloc_stackframe(); 44 45 45 46 if (!context || !context->internal->initialized) { 46 47 47 errno = EINVAL; 48 48 TALLOC_FREE(frame); 49 49 return NULL; 50 50 } 51 51 52 52 if (!fname) { 53 53 errno = EINVAL; … … 55 55 return NULL; 56 56 } 57 57 58 58 DEBUG(4, ("SMBC_open_print_job_ctx(%s)\n", fname)); 59 59 60 60 if (SMBC_parse_path(frame, 61 61 context, … … 72 72 return NULL; 73 73 } 74 74 75 75 /* What if the path is empty, or the file exists? */ 76 76 77 77 TALLOC_FREE(frame); 78 78 return smbc_getFunctionOpen(context)(context, fname, O_WRONLY, 666); … … 99 99 char buf[4096]; 100 100 TALLOC_CTX *frame = talloc_stackframe(); 101 101 102 102 if (!c_file || !c_file->internal->initialized || 103 103 !c_print || !c_print->internal->initialized) { 104 105 errno = EINVAL; 106 TALLOC_FREE(frame); 107 return -1; 108 109 } 110 104 errno = EINVAL; 105 TALLOC_FREE(frame); 106 return -1; 107 } 108 111 109 if (!fname && !printq) { 112 113 errno = EINVAL; 114 TALLOC_FREE(frame); 115 return -1; 116 117 } 118 110 errno = EINVAL; 111 TALLOC_FREE(frame); 112 return -1; 113 } 114 119 115 /* Try to open the file for reading ... */ 120 116 121 117 if ((long)(fid1 = smbc_getFunctionOpen(c_file)(c_file, fname, 122 118 O_RDONLY, 0666)) < 0) { … … 125 121 return -1; /* smbc_open sets errno */ 126 122 } 127 123 128 124 /* Now, try to open the printer file for writing */ 129 125 130 126 if ((long)(fid2 = smbc_getFunctionOpenPrintJob(c_print)(c_print, 131 127 printq)) < 0) { 132 133 128 saverr = errno; /* Save errno */ 134 129 smbc_getFunctionClose(c_file)(c_file, fid1); … … 136 131 TALLOC_FREE(frame); 137 132 return -1; 138 139 } 140 133 } 134 141 135 while ((bytes = smbc_getFunctionRead(c_file)(c_file, fid1, 142 136 buf, sizeof(buf))) > 0) { 143 144 137 tot_bytes += bytes; 145 138 146 139 if ((smbc_getFunctionWrite(c_print)(c_print, fid2, 147 140 buf, bytes)) < 0) { 148 149 141 saverr = errno; 150 142 smbc_getFunctionClose(c_file)(c_file, fid1); 151 143 smbc_getFunctionClose(c_print)(c_print, fid2); 152 144 errno = saverr; 153 154 145 } 155 156 } 157 146 } 147 158 148 saverr = errno; 159 149 160 150 smbc_getFunctionClose(c_file)(c_file, fid1); 161 151 smbc_getFunctionClose(c_print)(c_print, fid2); 162 152 163 153 if (bytes < 0) { 164 165 154 errno = saverr; 166 155 TALLOC_FREE(frame); 167 156 return -1; 168 169 } 170 157 } 158 171 159 TALLOC_FREE(frame); 172 160 return tot_bytes; 173 174 161 } 175 162 … … 191 178 char *path = NULL; 192 179 TALLOC_CTX *frame = talloc_stackframe(); 193 180 194 181 if (!context || !context->internal->initialized) { 195 196 errno = EINVAL; 197 TALLOC_FREE(frame); 198 return -1; 199 } 200 182 errno = EINVAL; 183 TALLOC_FREE(frame); 184 return -1; 185 } 186 201 187 if (!fname) { 202 188 errno = EINVAL; … … 204 190 return -1; 205 191 } 206 192 207 193 DEBUG(4, ("smbc_list_print_jobs(%s)\n", fname)); 208 194 209 195 if (SMBC_parse_path(frame, 210 196 context, … … 221 207 return -1; 222 208 } 223 209 224 210 if (!user || user[0] == (char)0) { 225 211 user = talloc_strdup(frame, smbc_getUser(context)); … … 230 216 } 231 217 } 232 218 233 219 srv = SMBC_server(frame, context, True, 234 220 server, share, &workgroup, &user, &password); 235 221 236 222 if (!srv) { 237 223 TALLOC_FREE(frame); 238 224 return -1; /* errno set by SMBC_server */ 239 225 } 240 226 241 227 if (cli_print_queue(srv->cli, 242 228 (void (*)(struct print_job_info *))fn) < 0) { … … 245 231 return -1; 246 232 } 247 233 248 234 TALLOC_FREE(frame); 249 235 return 0; 250 251 236 } 252 237 … … 269 254 int err; 270 255 TALLOC_CTX *frame = talloc_stackframe(); 271 256 272 257 if (!context || !context->internal->initialized) { 273 274 errno = EINVAL; 275 TALLOC_FREE(frame); 276 return -1; 277 } 278 258 errno = EINVAL; 259 TALLOC_FREE(frame); 260 return -1; 261 } 262 279 263 if (!fname) { 280 264 errno = EINVAL; … … 282 266 return -1; 283 267 } 284 268 285 269 DEBUG(4, ("smbc_unlink_print_job(%s)\n", fname)); 286 270 287 271 if (SMBC_parse_path(frame, 288 272 context, … … 299 283 return -1; 300 284 } 301 285 302 286 if (!user || user[0] == (char)0) { 303 287 user = talloc_strdup(frame, smbc_getUser(context)); … … 308 292 } 309 293 } 310 294 311 295 srv = SMBC_server(frame, context, True, 312 296 server, share, &workgroup, &user, &password); 313 297 314 298 if (!srv) { 315 316 299 TALLOC_FREE(frame); 317 300 return -1; /* errno set by SMBC_server */ 318 319 } 320 301 } 302 321 303 if ((err = cli_printjob_del(srv->cli, id)) != 0) { 322 323 304 if (err < 0) 324 305 errno = SMBC_errno(context, srv->cli); … … 327 308 TALLOC_FREE(frame); 328 309 return -1; 329 330 } 331 310 } 311 332 312 TALLOC_FREE(frame); 333 313 return 0; 334 335 314 } 336 315
Note:
See TracChangeset
for help on using the changeset viewer.