]>
git.saurik.com Git - apple/security.git/blob - Security/libsecurity_utilities/lib/inetreply.h
2 * Copyright (c) 2000-2001,2003-2004,2011,2014 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
26 // inetreply - manage Internet-standard reply strings
28 // The InetReply class represents an Internet-standard reply line of the form
34 #include <security_utilities/utilities.h>
39 namespace IPPlusPlus
{
43 // An InetReply object represents a broken-up reply line of the form
45 // Note that this will take a *writable* input line buffer and munge it
46 // into shape. This means that
47 // (a) You have to keep the input line buffer alive until the InetReply dies, and
48 // (b) You can't use the input line buffer after the InetReply is constructed.
52 InetReply(const char *buffer
);
54 bool valid() const { return mCode
>= 0; }
55 unsigned int code() const { return mCode
; }
56 operator unsigned int () const { return code(); }
57 unsigned int type() const { return mCode
/ 100; }
58 const char *message() const { return mMessage
; }
59 bool isContinued() const { return mSeparator
== '-'; }
62 const char *mBuffer
; // base buffer
63 int mCode
; // integer code (usually nnn)
64 char mSeparator
; // character after code (usually space; '-' for continued lines)
65 const char *mMessage
; // rest of message
71 // Handle FTP-style continuations: nnn- ... nnn<sp>Message
72 // Instructions for use:
73 // Continuation myCont; // in some persistent place
74 // ... get a line of reply -> const char *input ...
75 // if (myCont(input)) /* in (old) continuation */;
76 // InetReply reply(input);
77 // if (myCont(reply)) /* in (newly started) continuation */;
78 // /* not (any more) in continuation; reply has last message line
82 Continuation() : mActive(false) { }
84 bool operator () (const char *input
);
85 bool operator () (const InetReply
&reply
);
87 bool active() const { return mActive
; }
96 } // end namespace IPPlusPlus
97 } // end namespace Security
100 #endif //_H_INETREPLY