Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk_1/ftpquit.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 15 - (show annotations) (download) (as text)
Wed Feb 25 13:29:32 2009 UTC (15 years, 1 month ago) by hirohitohigashi
File MIME type: text/x-csrc
File size: 1970 byte(s)
renewal all sources.

1 /*
2
3 libftp 1.0 (stable): this is an FTP library to simplify the work to a Developer
4 who want to work with FTP servers (RFC 959).
5 Copyright (C) 2007/2008 omnipresent - omnipresent[at]email.it
6
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>
19
20 */
21
22 #include <stdio.h>
23 #include <string.h>
24 #include <errno.h>
25 #include <stdlib.h>
26 #include <unistd.h>
27 #include <sys/types.h>
28 #include <sys/time.h>
29 #include <sys/socket.h>
30 #include <sys/stat.h>
31 #include <netinet/in.h>
32 #include <netdb.h>
33 #include <fcntl.h>
34
35 #include "ftp_main.h"
36
37 /***
38 ftp_quit:
39 - int sck => Socket Descriptor
40 - int verbose => Print Inforations:
41 . 0 Do not Print
42 . 1 Print
43 ***/
44
45
46 int ftp_quit(int sck, int verbose) {
47
48
49 if (write(sck, "QUIT\n", strlen("QUIT\n")-1) == -1) {
50
51 if (verbose) {
52 if (errno == EBADF) {
53 fprintf(stderr, "Socket Descriptor Not Valid!\n");
54
55 return -1;
56
57 } else if (errno == EIO) {
58
59 fprintf(stderr, "I/O Error!\n");
60
61 return -1;
62
63 } else if (errno == EINTR) {
64
65 fprintf(stderr, "Signal Interrupted The write() Function\n");
66
67 return -1;
68 }
69
70 } else {
71
72 if (errno == EBADF) {
73
74 return -1;
75
76 } else if (errno == EIO) {
77
78 return -1;
79
80 } else if (errno == EINTR) {
81
82 return -1;
83 }
84
85 }
86
87
88 return -1;
89
90 }
91
92 if (close(sck) != 0)
93 return -1;
94 else
95 return 0; //0 returned; operation sucessfull!
96
97 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26