(c) M.Liberi
6 Dicembre 2001
Michele Liberi
Questo documento descrive un modulo CATIA che permette di controllare l'accesso agli archivi introducendo una serie di regole che i nomi dei modelli devono rispettare per poter essere memorizzati.
Il nome di un modello CATIA è normalmente costituito da una stringa di 70 caratteri sulla quale non viene effettuato alcun controllo. Questo programma permette di considerare il nome del modello come una sequenza di campi indipendenti per i quali è definita la lunghezza, il tipo, il nome ed eventuali altre informazioni ausiliare che dipendono dal tipo.
Sul nome così definito il programma attua una serie di controlli e permette di immettere separatamente le componenti del nome.
Analogamente a quanto avviene per le righe di una tabella in un database è possibile indicare che alcuni campi sono da considerarsi campi chiave. Il programma controlla che in un dato archivio non esistano due modelli con il campo chiave duplicato.
E' anche possibile disabilitare la possibilità di REPLACE dei modelli su specifici archivi.
Il programma intercetta la chiamata alle sottofunzioni WRITE, COPY, MOVE e RENAME della funzione FILE del CATIA INTERATTIVO ed interviene in modo diverso in funzione della modalità di lavoro definita per quell'archivio. Non viene eseguito alcun controllo in modalità batch.
Il programma può lavorare in tre modalità distinte:
nncnn invalid .....................
Il pacchetto è composto da due moduli:
Il programma si configura impostando le seguenti variabili d'ambiente:
Il file di configurazione deve contenere una sequenza di istruzioni che definiscono le regole che il nome del modello deve rispettare per poter essere scritto su un dato archivio. Le istruzioni vengono lette per token per cui possono essere posizionate liberamente, anche su più linee di testo. I token sono separati da un numero arbitrario di caratteri di separazione (spazio, tab, CR, LF ... (cfr. isspace())) e non possono essere più lunghi di 256 caratteri. Sono riconosciuti i seguenti casi particolari:
Il file di configurazione è composto da una lista di direttive:
File DEFINITIVI MOTORE* ''E' importante osservare che il nome dell'archivio CATIA che il programma usa per determinare l'insieme di regole da utilizzare è il cosiddetto DSNAME ovvero la seconda colonna dell'output del comando
catpath -l -d catia.modelSe il DSNAME non è impostato verrà usato il pathname, ovvero la prima colonna dell'output del comando di cui sopra.
Default Help Text, may be customized for each set of rules each field is marked by a letter indicating the rule TYPE K indicates Key Fields A (Alfanumeric): no check N (Numeric) : the field must be a decimal number L (LBA_Numeric): the field must be a decimal number, leading spaces allowed C (Charset) : all chars in specified charset D (Date) : date with specified format S (String) : fixed string, can't be edited R (Reg.Exp) : Regular Expression with specified format T (Template) : Template with specified format O (Oneof) : choose one in a given set
Ogni regola, che identifica un campo nel nome del modello, identifica il controllo da effettuare ed è formata da almeno tre token seguiti da eventuali parametri che dipendono dal tipo:
Le istruzioni che seguono servono per spezzare il nome del modello, che in complesso non può essere più lungo di 70 caratteri in sottocampi di lunghezza fissa di tipo prefissato. Eventuali errori di sintassi vengono evidenziati da un messaggio di errore nella finestra alfanumerica del CATIA e nessuna istruzione successiva verrà processata. La sequenza dei campi è data dall'ordine di reperimento delle istruzioni di definizione ed ogni campo inizia dal carattere immediatamente successivo al termine del campo precedente. Ogni istruzione è seguita da un numero compreso tra 1 e 70 che ne identifica la lunghezza e da un token che ne identifica il nome. Alcune istruzioni hanno dei parametri aggiuntivi.
Tipi disponibili e parametri richiesti
SetDef A '[A-Z]' SetDef N '[0-9]' KeyField Template 4 nome_campo AANN ''è equivalente, ma sicuramente più intuitivo, di
KeyField RegExp 4 nome_campo [A-Z][A-Z][0-9][0-9] ''
La funzione metastr, applicata alle definizioni di insiemi di caratteri e a tutte le Espressioni Regolari, riconosce come speciali le seguenti sequenze di caratteri, e lascia invariati tutti gli altri caratteri:
#ddd il carattere con codice ascii ddd (dec) $hh il carattere con codice ascii hh (hex) \# il carattere '#' \$ il carattere '$' \ooo il carattere con codice ascii ooo (oct) \0xhh il carattere con codice ascii hh (hex) \a ASCII 7 BELL \b ASCII 8 BACKSPACE \t ASCII 9 TAB \n ASCII 10 NL \v ASCII 11 VT \f ASCII 12 FF \r ASCII 13 CR \\ il carattere '\' (se seguito da spec)
Nella definizione di un 'charset' sono speciali i seguenti caratteri:
, (virgola) separatore di 'item' distinti ! (punto esclamativo) operatore di negazione (solo a inizio item) - (meno) operatore di differenza (solo a inizio item) - (meno) mediatore tra due caratteri ad indicare un range \ (barra retroversa) tratta il successivo carattere speciale come carattere normale
Nella definizione di una espressione regolare sono speciali i seguenti caratteri:
* (asterisco) sequenza arbitraria di zero o più caratteri ? (punto interrogativo)un qualunque carattere singolo [charset] un carattere nell'insieme specificato \ (barra retroversa) tratta il successivo carattere speciale come carattere normale
Esempio di file di configurazione
# ------------------------------------------------------------
# catexi configuration file
# set environment var CATEXICFG to activate
# set environment var CATEXIEZW to set default mode
# set environment var CATEXILOG to generate a LOG file
# total length must be less or equal than 70
# all lists must be closed by an empty token ''
# ------------------------------------------------------------
# ------------------------------------------------------------
# Directives: parameters
# ............................................................
# F (File) list of RE
# H (HelpFileName) pathname of a text file
# M (Mode) N (Never), A (Always), S (smart)
# R (Replace) Y (Yes), N (No)
# S (Set Definition) CHAR charset-definition
# P (PadChar) char
# W (WriteMask) 3-digit octal number
# K (KeyField) type len name [parameters]
# N (Normal Field) type len name [parameters]
# type parameters
# ............................................................
# A (Alfanum) NONE
# N (Numeric) NONE
# L (numeric Leading blank allowed) NONE
# C (Charset) charset definition
# D (Date) format (must contain dd mm yyyy or yy)
# E (EnvVar) Environment variable name
# S (String) fixed string
# R (RegExp) list of RE
# T (Template) list of templates
# O (Oneof) list of values
# ------------------------------------------------------------
SetDef H '[0-9A-F]'
SetDef A '[A-Z]'
SetDef B '[01]'
SetDef C '[abc]'
SetDef N '[0-9]'
# ------------------------------------------------------------
# TYPE LEN NAME [PARAM]
# ------------------------------------------------------------
# NO RULE FOR
File /* ''
K L 8 codice
N S 1 blank1 ' '
K N 2 esponente
N S 1 blank2 ' '
K A 47 commento
N S 1 blank3 ' '
K O 3 sigla ' ' ' a' ' a ' 'a ' ' aa' 'a a' ' aa'
'aaa' ''
N S 1 blank4 ' '
K D 6 data DDMMYY
Mode s
Replace N
HelpFileName /export/catiacfg/catexi.cfg
PadChar _
WriteMask 644
File TMP ''
N N 8 codice
N S 1 blank1 ' '
N N 2 esponente
N S 1 blank2 ' '
N T 5 template BCzzz CBwww ''
N R 4 re A* *A B*B ''
N C 8 binary 01
N C 4 HEX 0-9A-F
N A 31 filler
N D 6 data ddmmyy
Mode A
File TMP1 ''
# Default Rule Set
K N 10 Numeric
N A 5 Alfanum
N L 5 LBA
N C 10 charset a-z
N D 6 Date DDMMYY
N S 10 String 'I am Mic'
N R 10 Re A*Z ''
N O 10 Oneof pippo pluto paperino ''
Mode A
# ------------------------------------------------------------
Software Products: Michele Liberi programs and accompanying documentation "Freeware".
Licensor: Michele Liberi, Viale Roma 6, Battaglia Terme (PD), Italy.
This is a legal agreement between you, an end user, and licensor.
By downloading and installing the freeware, you are agreeing to be bound by the terms of this agreement. If you do not agree to the terms of this agreement, do not install this freeware and delete any copies of the freeware that you have downloaded.
This freeware is provided to you free of charge for both commercial and non-commercial purposes. Obtaining a license to this freeware from any party other than licensor and/or paying a fee for such license is strictly forbidden. If you are aware of any unauthorized third party distributing this freeware and/or charging a fee for this freeware, please report such violations to your consumer protection authorities.
This Agreement permits you to use one copy of the Freeware acquired with this license on any single computer ("License") for both commercial and non-commercial purposes, provided the Freeware is in use on only one computer at any given time. The Freeware is "in use" on a computer when it is loaded into the temporary memory or installed into the permanent memory (e.g. hard disk, CD ROM, or other storage device) of that computer, except that a copy installed on a network server for the sole purpose of distribution to other computers is not considered "in use".
The Freeware is owned by Licensor and is protected by copyright laws, international treaty provisions, and other national laws. You agree that you have no right, title or interest in the Freeware, except as set forth in Subsection I.
You may not rent, lease, sell or transfer the Freeware to any third party. You may not reverse engineer, decompile or disassemble the Freeware.
You acknowledge that you have licensed this freeware free of charge and that licensor makes no warranties to you in connection with this license, including but not limited to implied warranties of merchantability, fitness for a particular purpose, title, non-infringement and legality in your country. You agree to defend, indemnify and hold harmless licensor from any and all claims of infringement (including those made by third parties) resulting in whole or in part from your use of the freeware.
In no event shall Licensor be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the Freeware, even if Licensor has been advised of the possibility of such damages.
This Agreement shall be governed by and interpreted in accordance with the laws of Italy. If any dispute shall arise pursuant to any provision of this Agreement, said dispute shall be settled by binding arbitration in accordance with the rules and regulations of the courts, located in Italy. If any term or provision of this Agreement shall be declared invalid in arbitration or by a court of competent jurisdiction, such invalidity shall be limited solely to the specific term or provision invalidated, and the remainder of this Agreement shall remain in full force and effect, according to its terms. Any provision declared invalid shall be modified to the fullest extent possible to reflect the parties intent as of the Effective Date.
Copyright © M.Liberi. All rights reserved.