X-Git-Url: https://git.saurik.com/apple/mdnsresponder.git/blobdiff_plain/7f0064bd55e3fa98568d2c359429ff8a38b23a6c..95d7a4a31d5b4557b29fba1e0cdd09f1216ada8c:/mDNSShared/Java/TXTRecord.java diff --git a/mDNSShared/Java/TXTRecord.java b/mDNSShared/Java/TXTRecord.java index 5eed93e..8d9df7a 100644 --- a/mDNSShared/Java/TXTRecord.java +++ b/mDNSShared/Java/TXTRecord.java @@ -1,42 +1,18 @@ -/* +/* -*- Mode: Java; tab-width: 4 -*- + * * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * http://www.apache.org/licenses/LICENSE-2.0 * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - - Change History (most recent first): - -$Log: TXTRecord.java,v $ -Revision 1.5 2004/08/25 21:54:36 rpantos - Fix getValue() for values containing '='. - -Revision 1.4 2004/08/04 01:04:50 rpantos - Fix set(); add remove() & toString(). - -Revision 1.3 2004/07/13 21:24:25 rpantos -Fix for . - -Revision 1.2 2004/04/30 21:48:27 rpantos -Change line endings for CVS. - -Revision 1.1 2004/04/30 16:29:35 rpantos -First checked in. To do: - implement remove() @@ -127,20 +103,20 @@ public class TXTRecord byte[] oldBytes = fBytes; int valLen = (value != null) ? value.length : 0; int insertion = 0; - byte newLen, avLen; + int newLen, avLen; // locate the insertion point for ( int i=0; i < index && insertion < fBytes.length; i++) - insertion += fBytes[ insertion] + 1; + insertion += (0xFF & (fBytes[ insertion] + 1)); - avLen = (byte) ( keyBytes.length + valLen + (value != null ? 1 : 0)); - newLen = (byte) ( avLen + oldBytes.length + 1); + avLen = keyBytes.length + valLen + (value != null ? 1 : 0); + newLen = avLen + oldBytes.length + 1; fBytes = new byte[ newLen]; System.arraycopy( oldBytes, 0, fBytes, 0, insertion); int secondHalfLen = oldBytes.length - insertion; System.arraycopy( oldBytes, insertion, fBytes, newLen - secondHalfLen, secondHalfLen); - fBytes[ insertion] = avLen; + fBytes[ insertion] = ( byte) avLen; System.arraycopy( keyBytes, 0, fBytes, insertion + 1, keyBytes.length); if ( value != null) { @@ -170,7 +146,7 @@ public class TXTRecord return i; } } - avStart += avLen + 1; + avStart += (0xFF & (avLen + 1)); } return -1; } @@ -181,7 +157,7 @@ public class TXTRecord int i, avStart; for ( i=0, avStart=0; avStart < fBytes.length; i++) - avStart += fBytes[ avStart] + 1; + avStart += (0xFF & (fBytes[ avStart] + 1)); return i; }