5772782 [rkeene@sledge /home/rkeene/projects/libssh-win32/v0.11/src/libssh-0.11-win32/libssh]$ cat -n error.c
 1 /* error.c */
 2 /* it does contain error processing functions */
 3 /*
 4 Copyright 2003,04 Aris Adamantiadis
 5 
 6 This file is part of the SSH Library
 7 
 8 The SSH Library is free software; you can redistribute it and/or modify
 9 it under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or (at your
11 option) any later version.
12 
13 The SSH Library is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16 License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public License
19 along with the SSH Library; see the file COPYING.  If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21 MA 02111-1307, USA. */
22 
23 #include <stdio.h>
24 #include <stdarg.h>
25 #include "libssh/priv.h"
26 
27 static char error_buffer[ERROR_BUFFERLEN];
28 static int error_code;
29 static int verbosity;
30 
31 /* ssh_set_error registers an error with a description. the error code is the class of error, and description is
	obvious.*/
32 void ssh_set_error(SSH_SESSION *session,enum ssh_error code,char *descr,...){
33   va_list va;
34   va_start(va,descr);
35   vsnprintf(session?session->error_buffer : error_buffer,ERROR_BUFFERLEN,descr,va);
36   va_end(va);
37   if(session)
38       session->error_code=code;
39   else
40       error_code=code;
41 }
42 
43 char *ssh_get_error(SSH_SESSION *session){
44     if(session)
45         return session->error_buffer;
46     else
47         return error_buffer;
48 }
49 
50 enum ssh_error ssh_error_code(SSH_SESSION *session){
51     if(session)
52         return session->error_code;
53     else
54         return error_code;
55 }
56 
57 void ssh_say(int priority, char *format,...){
58     va_list va;
59     va_start(va,format);
60     if(priority <= verbosity)
61         vfprintf(stderr,format,va);
62     va_end(va);
63 }
64 
65 void ssh_set_verbosity(int num){
66     verbosity=num;
67 }
5772783 [rkeene@sledge /home/rkeene/projects/libssh-win32/v0.11/src/libssh-0.11-win32/libssh]$

Click here to go back to the directory listing.
Click here to download this file.
last modified: 2005-03-04 19:54:59