]>
git.saurik.com Git - apple/security.git/blob - cdsa/cdsa_utilities/inetreply.h
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
20 // inetreply - manage Internet-standard reply strings
22 // The InetReply class represents an Internet-standard reply line of the form
28 #include <Security/utilities.h>
33 namespace IPPlusPlus
{
37 // An InetReply object represents a broken-up reply line of the form
39 // Note that this will take a *writable* input line buffer and munge it
40 // into shape. This means that
41 // (a) You have to keep the input line buffer alive until the InetReply dies, and
42 // (b) You can't use the input line buffer after the InetReply is constructed.
46 InetReply(const char *buffer
);
48 bool valid() const { return mCode
>= 0; }
49 unsigned int code() const { return mCode
; }
50 operator unsigned int () const { return code(); }
51 unsigned int type() const { return mCode
/ 100; }
52 const char *message() const { return mMessage
; }
53 bool isContinued() const { return mSeparator
== '-'; }
56 const char *mBuffer
; // base buffer
57 int mCode
; // integer code (usually nnn)
58 char mSeparator
; // character after code (usually space; '-' for continued lines)
59 const char *mMessage
; // rest of message
65 // Handle FTP-style continuations: nnn- ... nnn<sp>Message
66 // Instructions for use:
67 // Continuation myCont; // in some persistent place
68 // ... get a line of reply -> const char *input ...
69 // if (myCont(input)) /* in (old) continuation */;
70 // InetReply reply(input);
71 // if (myCont(reply)) /* in (newly started) continuation */;
72 // /* not (any more) in continuation; reply has last message line
76 Continuation() : mActive(false) { }
78 bool operator () (const char *input
);
79 bool operator () (const InetReply
&reply
);
81 bool active() const { return mActive
; }
90 } // end namespace IPPlusPlus
91 } // end namespace Security