
/*
 * $Id: sorting.h,v 1.1.1.1 2003/11/04 23:34:57 mjames Exp $
 *
 * $Log: sorting.h,v $
 * Revision 1.1.1.1  2003/11/04 23:34:57  mjames
 * Imported into local repositrory
 *
 * Revision 1.12  2002/09/16 14:41:43  mjames
 * Merge back pin indexing bug that meant
 * pin AZ12 was indistinguishable from pin Z12 in
 * rename ident/name commands
 *
 * Revision 1.11  2002/09/09 10:10:21  mjames
 * Moved pin remapping function to pin ident editing function from
 * sorting pin name routine.
 *
 * Revision 1.10  2002/08/23 14:13:55  mjames
 * Added legal/illegal pin identifying letters to the header file.
 * Upgraded sort to determine row/column locations of pins identified like
 * 'a1' and '1a' etc or '1' , '2'
 *
 * Revision 1.9  2002/08/23 14:04:12  mjames
 * Added legal/illegal pin identifying letters to the header file.
 *
 * Revision 1.8  2002/01/21 09:35:57  mjames
 * Increased number of regular expression sub expressions that can be
 * matched from 4 to 10
 *
 * Revision 1.7  2001/12/11 21:27:12  mjames
 * Allowed for a variable number of sub-expressions to be matched by
 * regexp expressions.
 *
 * Revision 1.6  2001/10/31 22:20:17  mjames
 * Tidying up problematical comments caused by CVS
 * 'intelligent' comment guessing
 *
 * Revision 1.5  2001/10/31 16:15:36  mjames
 * Added a datastructure to hide regular expression information from programs.
 *
 * Revision 1.4  2001/10/22 10:53:40  mjames
 * Added a declaration of the Vertical regular expression compiler
 * which validates and complains about older 'regular expressions'
 * used by Vertical prior to using regexp in the C library
 *
 * Revision 1.3  2001/10/10 20:17:59  mjames
 * Added a vert_regcomp function to compile regular expressions
 * with '^' (match start string) and  '$' (match end string) bracketing
 * this => wildcard must match entire string not just a part of it.
 *
 * Revision 1.2  2001/06/06 12:10:17  mjames
 * Move from HPUX
 *
 * Revision 1.1.1.1  2000/10/19 21:58:40  mjames
 * Mike put it here
 *
 *
 * Revision 1.21  2000/10/04  10:37:14  10:37:14  mjames (Mike James)
 * Modified for Vertical2 : support COMPONENTS and SIGNALS
 *
 * Revision 1.21  2000/10/04  10:37:14  10:37:14  mjames (Mike James)
 * Part of Release PSAVAT01
 *
 * Revision 1.20  2000/10/02  11:04:21  11:04:21  mjames (Mike James)
 * new_vhdl
 *
 * Revision 1.19  2000/09/27  14:42:29  14:42:29  mjames (Mike James)
 * Part of Release Sep_27_ST_2000
 *
 * Revision 1.18  2000/09/21  10:15:58  10:15:58  mjames (Mike James)
 * Part of Release Sep21Alpha
 *
 * Revision 1.17  2000/08/25  09:57:23  09:57:23  mjames (Mike James)
 * Part of Release Aug25_alpha
 *
 * Revision 1.16  2000/08/16  08:57:39  08:57:39  mjames (Mike James)
 * Part of Release CD01_Aug2000
 *
 * Revision 1.15  2000/08/14  14:45:18  14:45:18  mjames (Mike James)
 * Part of Release Aug_14_2000
 *
 * Revision 1.14  2000/08/11  08:30:39  08:30:39  mjames (Mike James)
 * Part of Release Aug_11_2000
 *
 * Revision 1.13  2000/08/09  10:31:56  10:31:56  mjames (Mike James)
 * Part of Release Aug__9_2000
 *
 * Revision 1.12  2000/05/31  11:43:09  11:43:09  mjames (Mike James)
 * Part of Release May_31_2000
 *
 * Revision 1.11  2000/05/08  17:01:45  17:01:45  mjames (Mike James)
 * Part of Release May__8_2000
 *
 * Revision 1.10  2000/05/08  16:59:39  16:59:39  mjames (Mike James)
 * Part of Release May__8_2000
 *
 * Revision 1.9  2000/05/08  16:57:15  16:57:15  mjames (Mike James)
 * Part of Release May__8_2000
 *
 * Revision 1.8  2000/03/08  16:19:32  16:19:32  mjames (Mike James)
 * New version including PC
 *
 * Revision 1.5  2000/01/20  15:58:57  15:58:57  mjames (Mike James)
 * Part of Release R22
 *
 * Revision 1.4  99/12/22  11:15:37  11:15:37  mjames (Mike James)
 * Part of Release Dec_22_1999
 *
 * Revision 1.3  98/02/11  11:27:21  11:27:21  mjames (Mike James)
 * Checked in for version 6.2a
 *
 * Revision 1.2  97/04/23  08:44:46  08:44:46  mjames (Mike James)
 * CHecked in for release rel23041997
 *
 * Revision 1.1  96/12/23  10:24:34  10:24:34  mjames (Mike James)
 * Initial revision
 *  */
 
#pragma once

#include <regex.h> 
/* pin identifying letters that are permitted in IC pin identifiers */
#define PIN_MAP_LEGAL_CHARS "ABCDEFGHJKLMNPQRSTUVWXYZ"
/* the number of characters in the legal character set */
#define PIN_MAP_LEGAL_CHAR_COUNT 24

/* pin identifying letters that are not permitted in IC pin identifiers */
#define PIN_MAP_ILLEGAL_CHARS "IO";
/* the number of characters in the illegal character set */
#define PIN_MAP_ILLEGAL_CHAR_COUNT 2

/* maximum alphabetic characters before we decide pin identifier should not be
   assigned a column number in sort_nodes */
#define MAX_ID_ALPHA_SORT 5

/* this function also determines the 'row' and 'columns' of each chip sorted,
   as well as the minimum and maximum row and column numbers */

/* this now made conditional on mode being EXTRACT_XY */
typedef enum
{
        NO_EXTRACT_XY,
        EXTRACT_XY
} extract_xy_t;

extern void sort_nodes (socket_t *chip, extract_xy_t mode);
extern socket_t *sort_sockets (socket_t **s);
/* regular expression compiler according to Vertical rules */

#define MAX_REGEXP_SUBEXPR 10

typedef struct vrt
{
        regex_t preg[1];
        regmatch_t regpatt[MAX_REGEXP_SUBEXPR];
        char *buff;
} vert_regex_t;

extern int vert_regcomp (vert_regex_t **preg, char *expr);

extern int vert_regfree (vert_regex_t **preg);
