Chetan Gaonker | cb122cc | 2016-05-10 10:58:34 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
Chetan Gaonker | 7f4bf74 | 2016-05-04 15:56:08 -0700 | [diff] [blame] | 2 | # |
| 3 | # Definitions for RADIUS programs |
| 4 | # |
| 5 | # Copyright 2002 Miguel A.L. Paraz <mparaz@mparaz.com> |
| 6 | # |
| 7 | # This should only be used when testing modules. |
| 8 | # Inside freeradius, the 'radiusd' Python module is created by the C module |
| 9 | # and the definitions are automatically created. |
| 10 | # |
| 11 | # $Id: 02e9f237cc0df3d7be08413238e504b90bf59b1a $ |
| 12 | |
| 13 | # from modules.h |
| 14 | |
| 15 | RLM_MODULE_REJECT = 0 |
| 16 | RLM_MODULE_FAIL = 1 |
| 17 | RLM_MODULE_OK = 2 |
| 18 | RLM_MODULE_HANDLED = 3 |
| 19 | RLM_MODULE_INVALID = 4 |
| 20 | RLM_MODULE_USERLOCK = 5 |
| 21 | RLM_MODULE_NOTFOUND = 6 |
| 22 | RLM_MODULE_NOOP = 7 |
| 23 | RLM_MODULE_UPDATED = 8 |
| 24 | RLM_MODULE_NUMCODES = 9 |
| 25 | |
| 26 | |
| 27 | # from radiusd.h |
| 28 | L_DBG = 1 |
| 29 | L_AUTH = 2 |
| 30 | L_INFO = 3 |
| 31 | L_ERR = 4 |
| 32 | L_PROXY = 5 |
| 33 | L_CONS = 128 |
| 34 | |
| 35 | OP={ '{':2, '}':3, '(':4, ')':5, ',':6, ';':7, '+=':8, '-=':9, ':=':10, |
| 36 | '=':11, '!=':12, '>=':13, '>':14, '<=':15, '<':16, '=~':17, '!~':18, '=*':19, '!*':20, |
| 37 | '==':21 , '#':22 } |
| 38 | |
| 39 | OP_TRY = (':=', '+=', '-=', '=' ) |
| 40 | |
| 41 | def resolve(*lines): |
| 42 | tuples = [] |
| 43 | for line in lines: |
| 44 | for op in OP_TRY: |
| 45 | arr = line.rsplit(op) |
| 46 | if len(arr)==2: |
| 47 | tuples.append((str(arr[0].strip()),OP[op],str(arr[1].strip()))) |
| 48 | break |
| 49 | return tuple(tuples) |
| 50 | |
| 51 | # log function |
| 52 | def radlog(level, msg): |
| 53 | import sys |
| 54 | sys.stdout.write(msg + '\n') |
| 55 | |
| 56 | level = level |
| 57 | |
| 58 | |