/[dtapublic]/projs/ets/trunk/src/c_tclxtens_7_5/extninit.c
ViewVC logotype

Diff of /projs/ets/trunk/src/c_tclxtens_7_5/extninit.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 68 by dashley, Mon Oct 31 16:18:20 2016 UTC revision 71 by dashley, Sat Nov 5 11:07:06 2016 UTC
# Line 1  Line 1 
1  //$Header$  //$Header$
2  //-------------------------------------------------------------------------------------------------  //-------------------------------------------------------------------------------------------------
3  //This file is part of "David T. Ashley's Shared Source Code", a set of shared components  //This file is part of "David T. Ashley's Shared Source Code", a set of shared components
4  //integrated into many of David T. Ashley's projects.  //integrated into many of David T. Ashley's projects.
5  //-------------------------------------------------------------------------------------------------  //-------------------------------------------------------------------------------------------------
6  //This source code and any program in which it is compiled/used is provided under the MIT License,  //This source code and any program in which it is compiled/used is provided under the MIT License,
7  //reproduced below.  //reproduced below.
8  //-------------------------------------------------------------------------------------------------  //-------------------------------------------------------------------------------------------------
9  //Permission is hereby granted, free of charge, to any person obtaining a copy of  //Permission is hereby granted, free of charge, to any person obtaining a copy of
10  //this software and associated documentation files(the "Software"), to deal in the  //this software and associated documentation files(the "Software"), to deal in the
11  //Software without restriction, including without limitation the rights to use,  //Software without restriction, including without limitation the rights to use,
12  //copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the  //copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the
13  //Software, and to permit persons to whom the Software is furnished to do so,  //Software, and to permit persons to whom the Software is furnished to do so,
14  //subject to the following conditions :  //subject to the following conditions :
15  //  //
16  //The above copyright notice and this permission notice shall be included in all  //The above copyright notice and this permission notice shall be included in all
17  //copies or substantial portions of the Software.  //copies or substantial portions of the Software.
18  //  //
19  //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE  //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
22  //AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER  //AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,  //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24  //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE  //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25  //SOFTWARE.  //SOFTWARE.
26  //-------------------------------------------------------------------------------------------------  //-------------------------------------------------------------------------------------------------
27  #define MODULE_EXTNINIT  #define MODULE_EXTNINIT
28    
29  #include <assert.h>  #include <assert.h>
30  #include <string.h>  #include <string.h>
31    
32  #include "tcl.h"  #include "tcl.h"
33  #include "tcldecls.h"  #include "tcldecls.h"
34    
35  #include "extninit.h"  #include "extninit.h"
36    
37  #include "msgstrs.h"  #include "msgstrs.h"
38    
39  #include "arblenints.h"  #include "arblenints.h"
40  #include "crchashextns.h"  #include "crchashextns.h"
41  #include "credits.h"  #include "credits.h"
42  #include "pr_randa.h"  #include "pr_randa.h"
43  #include "vcinfo.h"  #include "vcinfo.h"
44    
45    
46  //Initializes all extensions.  Will go to tabulated mechanism and checking  //Initializes all extensions.  Will go to tabulated mechanism and checking
47  //return codes as soon as prototyping complaints by compiler resolved.  //return codes as soon as prototyping complaints by compiler resolved.
48    
49  void ExtninitInit(Tcl_Interp *interp)  void ExtninitInit(Tcl_Interp *interp)
50  {  {
51     //Initialize the MSGSTRS module.  This will calculate the CRC32     //Initialize the MSGSTRS module.  This will calculate the CRC32
52     //of all version control information and include it in the     //of all version control information and include it in the
53     //embedded message strings for that module.     //embedded message strings for that module.
54     MsgstrsInit();     MsgstrsInit();
55    
56     //Initialize the arbitrary length integer extension.     //Initialize the arbitrary length integer extension.
57     ARBLENINTS_arbint_extn_init(interp);     ARBLENINTS_arbint_extn_init(interp);
58    
59     //Initialize the "crc32" extension.     //Initialize the "crc32" extension.
60     CRCHASHEXTNS_Crc32extnInit(interp);     CRCHASHEXTNS_Crc32extnInit(interp);
61    
62     //Initialize the "credits" extension.     //Initialize the "credits" extension.
63     CreditsInit(interp);     CreditsInit(interp);
64    
65     //Initialize the random number generation functions.     //Initialize the random number generation functions.
66     PrRandAInit(interp);     PrRandAInit(interp);
67    
68     //Initialize the version control information function     //Initialize the version control information function
69     //"vcinfo".     //"vcinfo".
70     VcinfoInit(interp);     VcinfoInit(interp);
71  }  }
72    
73  //07/28/01:  Visually inspected.  Seems OK.  That plus using  //07/28/01:  Visually inspected.  Seems OK.  That plus using
74  //it should be enough.  //it should be enough.
75  int EXTNINIT_subextension_bsearch(  int EXTNINIT_subextension_bsearch(
76        struct EXTNINIT_subextn_bsearch_record_struct *tbl,        struct EXTNINIT_subextn_bsearch_record_struct *tbl,
77        int nelem,        int nelem,
78        const char *key)        const char *key)
79     {     {
80     int l, u, midpoint;     int l, u, midpoint;
81     int compare_result;     int compare_result;
82    
83     //Eyeball the input parameters.     //Eyeball the input parameters.
84     assert(tbl != NULL);     assert(tbl != NULL);
85     assert(nelem >= 0);     assert(nelem >= 0);
86     assert(key != NULL);     assert(key != NULL);
87    
88     //Implement the standard bsearch algorithm.       //Implement the standard bsearch algorithm.  
89     l = 0;     l = 0;
90     u = nelem - 1;     u = nelem - 1;
91    
92     while(1)     while(1)
93        {        {
94        if (l > u)        if (l > u)
95           {           {
96           return(-1);           return(-1);
97           }           }
98        else        else
99           {           {
100           midpoint = (l + u) / 2;           midpoint = (l + u) / 2;
101    
102           assert((midpoint >= 0) && (midpoint < nelem));           assert((midpoint >= 0) && (midpoint < nelem));
103    
104           compare_result = strcmp(key, tbl[midpoint].name);           compare_result = strcmp(key, tbl[midpoint].name);
105    
106           if (!compare_result)           if (!compare_result)
107              {              {
108              return(midpoint);              return(midpoint);
109              }              }
110           else if (compare_result < 0)           else if (compare_result < 0)
111              {              {
112              u = midpoint - 1;              u = midpoint - 1;
113              }              }
114           else           else
115              {              {
116              l = midpoint + 1;              l = midpoint + 1;
117              }              }
118           }           }
119        }        }
120     }     }
121    
122    
123  const char *ExtninitCversion(void)  const char *ExtninitCversion(void)
124  {    {  
125      return ("$Header$");      return ("$Header$");
126  }  }
127    
128    
129  const char *ExtninitHversion(void)  const char *ExtninitHversion(void)
130  {    {  
131      return (EXTNINIT_H_VERSION);      return (EXTNINIT_H_VERSION);
132  }  }
133    
134  //End of extninit.c.  //End of extninit.c.

Legend:
Removed from v.68  
changed lines
  Added in v.71

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25