2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 1999 by Sun Microsystems, Inc. 2N/A * All rights reserved. 2N/A// Author: James Kempf 2N/A// Created On: Thu Sep 10 15:33:58 1998 2N/A// Last Modified By: James Kempf 2N/A// Last Modified On: Fri Nov 6 14:03:00 1998 2N/A * The SLPV1SSrvMsg class models the SLP server side service request message. 2N/A * @author James Kempf 2N/A // For eating whitespace. 2N/A // Comma for list parsing. 2N/A // Logical operators. 2N/A // Logical operator corner case needs this. 2N/A // LDAP present operator 2N/A // Wildcard operator. 2N/A // Character code for parsing. 2N/A // For creating a null reply. 2N/A // Construct a SLPV1SSrvMsg from the input stream. 2N/A // Construct an empty SLPV1SSrvMsg, for monolingual off. 2N/A // Initialize the message from the input stream. 2N/A // First get the previous responder. 2N/A // Now get the raw query. 2N/A // Parse the raw query to pull out the service type, scope, 2N/A // Special case if scope is empty (meaning the next 2N/A // token will be a slash). 2N/A // Validate the scope name. 2N/A // Set up scopes vector. 2N/A // Substitute default scope here. 2N/A // Parsing the query is complicated by opaques having slashes. 2N/A // Drop off the final backslash, error if none. 2N/A // Save header char code for parsing. 2N/A // Convert the query into a V2 query. 2N/A // If the query is for "service:directory-agent", then we 2N/A // mark it as having been multicast, because that is the 2N/A // only kind of multicast that we accept for SLPv1. Anybody 2N/A // who unicasts this to us will time out. 2N/A // Construct description. 2N/A " service type=``" +
2N/A // Make a reply message. 2N/A // Edit out abstract types and nonService: URLs. 2N/A // Reject if abstract type or nonservice: URL. 2N/A // keep this info so SAs can drop 0 replies 2N/A // Write out the size of the list. 2N/A // Write out the size of the list. 2N/A // We ignore the signatures because we only do V1 compatibility 2N/A // for nonprotected scopes. 2N/A " service URLs=``" +
urls +
"''\n");
2N/A // Convert the query to a V2 query. 2N/A // Check for empty query. 2N/A // Check for query join. 2N/A // Rewrite to a standard query. 2N/A // Now rewrite the query into v2 format. 2N/A // Rewrite a query join as a conjunction. 2N/A // Turn infix expression into prefix. 2N/A // Rewrite a v1 query into v2 format. This includes character escaping. 2N/A // Parse a logical expression. 2N/A // Initialize parse tables in terminal. 2N/A // Parse through the expression. 2N/A // Do the actual parsing, using the passed-in stream tokenizer. 2N/A // We should be at the beginning a parenthesized 2N/A // Get the next token. Eat whitespace in the process. 2N/A // If it's a logOp, then process as a logical expression. 2N/A // This handles the following nasty case: 2N/A // (,-==the rest of it) 2N/A // Need to check for escape as first thing. 2N/A // cause we can't push back twice 2N/A // It's a terminal expression. Push back the last token 2N/A // and parse the terminal. 2N/A // Since terminals are allowed alone at the top level, 2N/A // we need to check here whether anything else is 2N/A // The line should have ended by now. 2N/A // Rewrite a logical expression. 2N/A // Append paren and operator to buffer. 2N/A // So parseInternal() sees a parenthesized list. 2N/A // Go back to parseInternal. 2N/A // Append the character to the buffer and return. 2N/A // Error if we've not caught ourselves before this. 2N/A // Parse a terminal. Opening paren has been got. 2N/A // Gather the tag and value. 2N/A // Now escape in v2 format, 2N/A // Parse the operator. 2N/A // If this was a keyword operator, then add present 2N/A // operator and closing paren and return. 2N/A // Parse value by reading up to the next close paren. 2N/A // Returned value will be in v2 format. 2N/A // Construct the comparision depending on the operator. 2N/A // If the value is an integer, we can construct a query 2N/A // that will exclude the number. 2N/A // Bump the integer up and down to catch numbers on both 2N/A // sides of the required number. Be careful not to 2N/A // It's not an integer. We can construct a query expression 2N/A // that will not always work. The query rules out advertisments 2N/A // where the attribute value doesn't match and there are 2N/A // no other attributes or values, and advertisements 2N/A // that don't contain the attribute, but it doesn't rule out 2N/A // a multivalued attribute with other values or if there 2N/A // are other attributes. The format of the query is: 2N/A // "(&(<tag>=*)(!(<tag>=<value>))). 2N/A // It's a parse error here. 2N/A // We don't attempt to handle something that would cause 2N/A // arithmetic overflow. 2N/A // Construct a query that includes everything 2N/A // to the correct side. 2N/A // Simple, single operator. Just add it with the 2N/A // Need to distinguish less and greater equal. 2N/A // Gather tokens with embedded whitespace and return. 2N/A // Take care of corner case here. 2N/A // If the token is a close paren, then this was a keyword 2N/A // (e.g. "(foo)". Return the present operator. 2N/A // Get the next token. 2N/A // Look for dual character operators. 2N/A // Here, we can have either "!=", "<=", ">=", or "==". 2N/A // Anything else is wrong. 2N/A // Assign the right dual operator. 2N/A // Error if the comparison operator was something other 2N/A // than ``<'' or ``>'' and there is no equal. This 2N/A // rules out ``!'' or ``='' alone. 2N/A // Push back the last token if it wasn't a two character operator. 2N/A // Eat leading whitespace. 2N/A // If the first value is a paren, then we've got an 2N/A // Collect all tokens up to the closing paren. 2N/A // It's a closing paren. break out of the loop. 2N/A // Eat whitespace until closing paren. 2N/A // Error if just a closed paren. 2N/A // Append the token if a WORD 2N/A // Otherwise, it's a token char, so append. 2N/A // If a wildcard, remove wildcard stars here for later re-insertion. 2N/A // Evaluate the value. 2N/A // Now convert to v2 format, and return. 2N/A // Add wildcards back in.