Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/libsmb/libsmb_printjob.c

    r414 r745  
    88   Copyright (C) Derrell Lipman 2003-2008
    99   Copyright (C) Jeremy Allison 2007, 2008
    10    
     10
    1111   This program is free software; you can redistribute it and/or modify
    1212   it under the terms of the GNU General Public License as published by
    1313   the Free Software Foundation; either version 3 of the License, or
    1414   (at your option) any later version.
    15    
     15
    1616   This program is distributed in the hope that it will be useful,
    1717   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1919   GNU General Public License for more details.
    20    
     20
    2121   You should have received a copy of the GNU General Public License
    2222   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    2424
    2525#include "includes.h"
     26#include "libsmb/libsmb.h"
    2627#include "libsmbclient.h"
    2728#include "libsmb_internal.h"
     
    4243        char *path = NULL;
    4344        TALLOC_CTX *frame = talloc_stackframe();
    44        
     45
    4546        if (!context || !context->internal->initialized) {
    46                
    4747                errno = EINVAL;
    4848                TALLOC_FREE(frame);
    4949                return NULL;
    5050        }
    51        
     51
    5252        if (!fname) {
    5353                errno = EINVAL;
     
    5555                return NULL;
    5656        }
    57        
     57
    5858        DEBUG(4, ("SMBC_open_print_job_ctx(%s)\n", fname));
    59        
     59
    6060        if (SMBC_parse_path(frame,
    6161                            context,
     
    7272                return NULL;
    7373        }
    74        
     74
    7575        /* What if the path is empty, or the file exists? */
    76        
     76
    7777        TALLOC_FREE(frame);
    7878        return smbc_getFunctionOpen(context)(context, fname, O_WRONLY, 666);
     
    9999        char buf[4096];
    100100        TALLOC_CTX *frame = talloc_stackframe();
    101        
     101
    102102        if (!c_file || !c_file->internal->initialized ||
    103103            !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
    111109        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
    119115        /* Try to open the file for reading ... */
    120        
     116
    121117        if ((long)(fid1 = smbc_getFunctionOpen(c_file)(c_file, fname,
    122118                                                       O_RDONLY, 0666)) < 0) {
     
    125121                return -1;  /* smbc_open sets errno */
    126122        }
    127        
     123
    128124        /* Now, try to open the printer file for writing */
    129        
     125
    130126        if ((long)(fid2 = smbc_getFunctionOpenPrintJob(c_print)(c_print,
    131127                                                                printq)) < 0) {
    132                
    133128                saverr = errno;  /* Save errno */
    134129                smbc_getFunctionClose(c_file)(c_file, fid1);
     
    136131                TALLOC_FREE(frame);
    137132                return -1;
    138                
    139         }
    140        
     133        }
     134
    141135        while ((bytes = smbc_getFunctionRead(c_file)(c_file, fid1,
    142136                                                     buf, sizeof(buf))) > 0) {
    143                
    144137                tot_bytes += bytes;
    145                
     138
    146139                if ((smbc_getFunctionWrite(c_print)(c_print, fid2,
    147140                                                    buf, bytes)) < 0) {
    148                        
    149141                        saverr = errno;
    150142                        smbc_getFunctionClose(c_file)(c_file, fid1);
    151143                        smbc_getFunctionClose(c_print)(c_print, fid2);
    152144                        errno = saverr;
    153                        
    154145                }
    155                
    156         }
    157        
     146        }
     147
    158148        saverr = errno;
    159        
     149
    160150        smbc_getFunctionClose(c_file)(c_file, fid1);
    161151        smbc_getFunctionClose(c_print)(c_print, fid2);
    162        
     152
    163153        if (bytes < 0) {
    164                
    165154                errno = saverr;
    166155                TALLOC_FREE(frame);
    167156                return -1;
    168                
    169         }
    170        
     157        }
     158
    171159        TALLOC_FREE(frame);
    172160        return tot_bytes;
    173        
    174161}
    175162
     
    191178        char *path = NULL;
    192179        TALLOC_CTX *frame = talloc_stackframe();
    193        
     180
    194181        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
    201187        if (!fname) {
    202188                errno = EINVAL;
     
    204190                return -1;
    205191        }
    206        
     192
    207193        DEBUG(4, ("smbc_list_print_jobs(%s)\n", fname));
    208        
     194
    209195        if (SMBC_parse_path(frame,
    210196                            context,
     
    221207                return -1;
    222208        }
    223        
     209
    224210        if (!user || user[0] == (char)0) {
    225211                user = talloc_strdup(frame, smbc_getUser(context));
     
    230216                }
    231217        }
    232        
     218
    233219        srv = SMBC_server(frame, context, True,
    234220                          server, share, &workgroup, &user, &password);
    235        
     221
    236222        if (!srv) {
    237223                TALLOC_FREE(frame);
    238224                return -1;  /* errno set by SMBC_server */
    239225        }
    240        
     226
    241227        if (cli_print_queue(srv->cli,
    242228                            (void (*)(struct print_job_info *))fn) < 0) {
     
    245231                return -1;
    246232        }
    247        
     233
    248234        TALLOC_FREE(frame);
    249235        return 0;
    250        
    251236}
    252237
     
    269254        int err;
    270255        TALLOC_CTX *frame = talloc_stackframe();
    271        
     256
    272257        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
    279263        if (!fname) {
    280264                errno = EINVAL;
     
    282266                return -1;
    283267        }
    284        
     268
    285269        DEBUG(4, ("smbc_unlink_print_job(%s)\n", fname));
    286        
     270
    287271        if (SMBC_parse_path(frame,
    288272                            context,
     
    299283                return -1;
    300284        }
    301        
     285
    302286        if (!user || user[0] == (char)0) {
    303287                user = talloc_strdup(frame, smbc_getUser(context));
     
    308292                }
    309293        }
    310        
     294
    311295        srv = SMBC_server(frame, context, True,
    312296                          server, share, &workgroup, &user, &password);
    313        
     297
    314298        if (!srv) {
    315                
    316299                TALLOC_FREE(frame);
    317300                return -1;  /* errno set by SMBC_server */
    318                
    319         }
    320        
     301        }
     302
    321303        if ((err = cli_printjob_del(srv->cli, id)) != 0) {
    322                
    323304                if (err < 0)
    324305                        errno = SMBC_errno(context, srv->cli);
     
    327308                TALLOC_FREE(frame);
    328309                return -1;
    329                
    330         }
    331        
     310        }
     311
    332312        TALLOC_FREE(frame);
    333313        return 0;
    334        
    335314}
    336315
Note: See TracChangeset for help on using the changeset viewer.