1
/*___INFO__MARK_BEGIN__*/
2
/*************************************************************************
4
* The Contents of this file are made available subject to the terms of
5
* the Sun Industry Standards Source License Version 1.2
7
* Sun Microsystems Inc., March, 2001
10
* Sun Industry Standards Source License Version 1.2
11
* =================================================
12
* The contents of this file are subject to the Sun Industry Standards
13
* Source License Version 1.2 (the "License"); You may not use this file
14
* except in compliance with the License. You may obtain a copy of the
15
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
17
* Software provided under this License is provided on an "AS IS" basis,
18
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
19
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
20
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
21
* See the License for the specific provisions governing your rights and
22
* obligations concerning the Software.
24
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
26
* Copyright: 2001 by Sun Microsystems, Inc.
28
* All Rights Reserved.
30
************************************************************************/
31
/*___INFO__MARK_END__*/
36
/* do not compile in monitoring code */
37
#ifndef NO_SGE_COMPILE_DEBUG
38
#define NO_SGE_COMPILE_DEBUG
42
#include "cull_listP.h"
43
#include "cull_parse.h"
44
#include "cull_lerrnoP.h"
46
/* ---------- static funcs --------------------------------- */
47
static const char *eatws(const char *s);
48
/* ---------- global variable --------------------------------- */
50
/* =========== implementation ================================= */
52
/* ------------------------------------------------------------
54
sets pointer s to next character after
57
returns NULL if there is '\0'
60
static const char *eatws(
63
while (*s && isspace((int) *s))
68
/* ------------------------------------------------------------
70
eat_token() informs parsing system that the current token
74
void eat_token(cull_parse_state *state) {
75
state->token_is_valid = 0;
78
/* ------------------------------------------------------------
80
scan() scans a string s for valid tokens
82
for getting the first token call scan with s = &string
83
s != �NULL initializes scan()
84
s == NULL uses the previous string for scanning
85
if scan is called once again it gets the same token as before if there
86
was no call to eat_token() otherwise a new token is delivered
91
cull_parse_state *state
95
"%T", /* DESCRIPTOR TYPE OF LIST */
112
"ALL", /* CULL_ALL */
113
"NONE", /* CULL_NONE */
115
"!=", /* NOT_EQUAL */
116
"<=", /* LOWER_EQUAL */
118
">=", /* GREATER_EQUAL */
121
"c=", /* STRCASECMP */
122
"p=", /* PATTERNCMP */
123
"h=", /* HOSTNAMECMP */
133
int n = sizeof(opv) / sizeof(char *);
136
DENTER(CULL_LAYER, "scan");
138
if (s) { /* initialize scan() with a new string to parse */
140
state->token_is_valid = 0;
143
if (state->token_is_valid) { /* no need for a new token to parse */
148
state->t = eatws(state->t);
149
if (state->t == NULL) { /* end of the string to parse */
150
state->token_is_valid = 1;
151
state->token = NO_TOKEN;
156
/* try every possible token */
157
for (i = 0; i < n; i++) {
159
len = strlen(opv[i]);
160
for (j = 0; j < len; j++)
161
if (state->t[j] == '\0' || state->t[j] != opv[i][j]) {
167
state->token_is_valid = 1;
168
state->token = i + 1;
171
return (state->token);
175
state->token_is_valid = 1;
176
state->token = NO_TOKEN;