Annotation of coherent/d/bin/uucheck/checkperms/checkperms.lex, revision 1.1

1.1     ! root        1: %{
        !             2: #include "y.tab.h"
        !             3: #include "checkperms.h"
        !             4: #include "monitor.h"
        !             5: 
        !             6: #undef input
        !             7: 
        !             8: /*
        !             9:  * input routine takes care of tab counting.
        !            10:  */
        !            11: input()
        !            12: {
        !            13:        int c;
        !            14:        static int here = 0, atstart = 1, atpos = 0, level = 0, stops[20];
        !            15: 
        !            16:        while (atstart) {
        !            17:                switch (c = my_getchar()) {
        !            18:                case '\t':
        !            19:                        atpos |= 7;
        !            20:                case ' ':
        !            21:                        atpos++;
        !            22:                        break;
        !            23:                case '\n':
        !            24:                        atpos = 0;
        !            25:                        lineno++;
        !            26: #if 0
        !            27: /* DEBUG */            fprintf(stderr, "lineno: %d\n", lineno);
        !            28: #endif /* 0 */
        !            29:                        break;
        !            30:                default:
        !            31:                        my_ungetchar(c);
        !            32:                        atstart = 0;            
        !            33:                        if (atpos > here) {
        !            34:                                here = stops[++level] = atpos;
        !            35:                                return(2);
        !            36:                        }
        !            37:                } /* switch (c = my_getchar()) */
        !            38: 
        !            39:        }
        !            40: 
        !            41:        if (atpos < here) {
        !            42:                here = stops[--level];
        !            43:                return(1);
        !            44:        }
        !            45: 
        !            46:        switch (c = my_getchar()) {     
        !            47:        case '\n':
        !            48:                atstart = 1;
        !            49:                atpos = 0;
        !            50:                lineno++;
        !            51: #if 0
        !            52: /* DEBUG */            fprintf(stderr, "lineno: %d\n", lineno);
        !            53: #endif /* 0 */
        !            54:        }
        !            55: 
        !            56:        return(c);
        !            57: }
        !            58: 
        !            59: lookup(s)
        !            60:        char *s;
        !            61: {
        !            62:        int i;
        !            63:        int retval;
        !            64: 
        !            65:        retval = 0;
        !            66:        for (i = 0; i < NUM_TOKENS; ++i){
        !            67:                if(strcmp(s, token_table[i].string) == 0) {
        !            68:                        retval = token_table[i].value;
        !            69: #ifdef DEBUG
        !            70:                        fprintf(stderr,
        !            71:                                "Token: %s, Line: %d\n",
        !            72:                                token_table[i].string, lineno);
        !            73: #endif DEBUG
        !            74:                } /* if s matches token_table[i].string */
        !            75:        } /* for i = 0 to NUM_TOKENS - walk through the table.  */
        !            76: 
        !            77:        return(retval);
        !            78: } /* lookup() */
        !            79: %}
        !            80: 
        !            81: %%
        !            82: "\001"                 {
        !            83:                            /* If we are at the bottom of a foreach */
        !            84:                            if (host_looping && (current_path == NULL)) {
        !            85:                                /* We probably want to rewind to the foreach.  */
        !            86:                                if (handle_foreach_unindent() == UNINDENT) {
        !            87:                                        /* No, we really are done with the
        !            88:                                         * foreach loop.
        !            89:                                         */
        !            90:                                        return(UNINDENT);
        !            91:                                }
        !            92:                            } else { /* Otherwise, just an ordinary unindent.  */
        !            93:                                return(UNINDENT);
        !            94:                            } /* if we are at the bottom of a foreach */
        !            95:                        } /* UNINDENT */
        !            96: 
        !            97: "\002"                 {
        !            98:                            if (!ignore_next_indent) {
        !            99:                                return(INDENT);
        !           100:                            } else {
        !           101:                                ignore_next_indent = FALSE;
        !           102:                            } /* if !ignore_next_indent */
        !           103:                        } /* INDENT */
        !           104: #.*\n                  { /* Ignore everything after a "#" to end of line.  */ }
        !           105: [ \t,]+                        { /* Internal blanks and commas are white space.  */ }
        !           106: [ugo]+[+-][strwx]+     { copy_str(&chmod_string, yytext);
        !           107:                          return(CHMOD_PERMISSION);
        !           108:                        } /* Chmod pattern.  */
        !           109: \"((\\\")|.)*\"                { copy_str(&ret_string, yytext);
        !           110:                          /* Strip off the leading and trailing quotes.  */
        !           111:                          ret_string[strlen(ret_string) - 1] = (char) NULL;
        !           112:                          ++ret_string;
        !           113:                          return(STRING);
        !           114:                        } /* String pattern.  */
        !           115: [a-zA-Z][a-zA-Z0-9]*   { int retval;
        !           116:                          if ((retval = lookup(yytext)) == 0) {
        !           117:                                fprintf(stderr,
        !           118:                                        "Invalid token %s ",
        !           119:                                        yytext);
        !           120:                                FATAL("in line %d.\n", lineno);
        !           121:                          } /* if retval invalid */
        !           122:                          return(retval); }
        !           123: "\n"                   { return(NL); }
        !           124: %%
        !           125: int
        !           126: handle_foreach_unindent()
        !           127: {
        !           128: #if 0
        !           129: /* DEBUG */    printf("%d: finished a declarator block.\n", lineno);
        !           130: #endif /* 0 */
        !           131:                if((current_host = next_host()) != NULL){
        !           132: #if 0
        !           133: /* DEBUG */        printf("%d: There is another host.\n", lineno);
        !           134: #endif /* 0 */
        !           135:                    saving_to_monitor_file = FALSE;
        !           136:                    reading_from_monitor_file = TRUE;
        !           137:                    rewind_monitor_file();
        !           138:                    ignore_next_indent = TRUE;
        !           139:                } else {
        !           140: #if 0
        !           141: /* DEBUG */        printf("%d: No more hosts.\n", lineno);
        !           142: #endif /* 0 */
        !           143:                    close_monitor_file();       /* Throw away old input.  */
        !           144:                    saving_to_monitor_file = FALSE;
        !           145:                    reading_from_monitor_file = FALSE;
        !           146:                    host_looping = FALSE;       /* We're done looping.  */
        !           147:                    return(UNINDENT);
        !           148:                }
        !           149:        return(0);
        !           150: } /* handle_foreach_unindent() */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.