ClientCommon.c revision 5ffb0c9b03b5149ff4f5821a62be4a52408ada2a
486N/A/* -*- Mode: C; tab-width: 4 -*- 486N/A * Copyright (c) 2008 Apple Inc. All rights reserved. 1068N/A * Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 486N/A * ("Apple") in consideration of your agreement to the following terms, and your 486N/A * use, installation, modification or redistribution of this Apple software 919N/A * constitutes acceptance of these terms. If you do not agree with these terms, 919N/A * please do not use, install, modify or redistribute this Apple software. 919N/A * In consideration of your agreement to abide by the following terms, and subject 919N/A * to these terms, Apple grants you a personal, non-exclusive license, under Apple's 919N/A * copyrights in this original Apple software (the "Apple Software"), to use, 919N/A * reproduce, modify and redistribute the Apple Software, with or without 919N/A * modifications, in source and/or binary forms; provided that if you redistribute 919N/A * the Apple Software in its entirety and without modifications, you must retain 919N/A * this notice and the following text and disclaimers in all such redistributions of 919N/A * the Apple Software. Neither the name, trademarks, service marks or logos of 919N/A * Apple Computer, Inc. may be used to endorse or promote products derived from the 919N/A * Apple Software without specific prior written permission from Apple. Except as 919N/A * expressly stated in this notice, no other rights or licenses, express or implied, 919N/A * are granted by Apple herein, including but not limited to any patent rights that 919N/A * may be infringed by your derivative works or by other works in which the Apple 919N/A * Software may be incorporated. 486N/A * The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 486N/A * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 486N/A * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 493N/A * PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 486N/A * COMBINATION WITH YOUR PRODUCTS. 970N/A * IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 970N/A * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 970N/A * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 486N/A * ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 1068N/A * OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 486N/A * (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 911N/A * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 970N/A while (*
cstr && *
cstr !=
'.')
// While we have characters in the label... 486N/A if (c ==
'\\' && *
cstr)
// If we have a backslash, and it's not the last character of the string int v0 =
cstr[-
1] -
'0';
// then interpret as three-digit decimal // If valid three-digit decimal value, use it // Note that although ascii nuls are possible in DNS labels // we're building a C string here so we have no way to represent that if (
ptr >=
label+
64) {
label[
63] = 0;
return(
NULL); }
// Illegal label more than 63 bytes *
ptr = 0;
// Null-terminate label text if (*
cstr)
cstr++;
// Skip over the trailing dot (if present)