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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 98 - (hide annotations) (download)
Sun Dec 18 00:57:31 2016 UTC (7 years, 6 months ago) by dashley
Original Path: projs/dtats/trunk/shared_source/c_tclxtens_7_5/extninit.c
File MIME type: text/plain
File size: 3957 byte(s)
Reorganization.
1 dashley 71 //$Header$
2     //-------------------------------------------------------------------------------------------------
3     //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.
5     //-------------------------------------------------------------------------------------------------
6     //This source code and any program in which it is compiled/used is provided under the MIT License,
7     //reproduced below.
8     //-------------------------------------------------------------------------------------------------
9     //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
11     //Software without restriction, including without limitation the rights to use,
12     //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,
14     //subject to the following conditions :
15     //
16     //The above copyright notice and this permission notice shall be included in all
17     //copies or substantial portions of the Software.
18     //
19     //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20     //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21     //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
23     //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
25     //SOFTWARE.
26     //-------------------------------------------------------------------------------------------------
27     #define MODULE_EXTNINIT
28    
29     #include <assert.h>
30     #include <string.h>
31    
32     #include "tcl.h"
33     #include "tcldecls.h"
34    
35     #include "extninit.h"
36    
37     #include "msgstrs.h"
38    
39     #include "arblenints.h"
40     #include "crchashextns.h"
41     #include "credits.h"
42     #include "pr_randa.h"
43     #include "vcinfo.h"
44    
45    
46     //Initializes all extensions. Will go to tabulated mechanism and checking
47     //return codes as soon as prototyping complaints by compiler resolved.
48    
49     void ExtninitInit(Tcl_Interp *interp)
50     {
51     //Initialize the MSGSTRS module. This will calculate the CRC32
52     //of all version control information and include it in the
53     //embedded message strings for that module.
54     MsgstrsInit();
55    
56     //Initialize the arbitrary length integer extension.
57     ARBLENINTS_arbint_extn_init(interp);
58    
59     //Initialize the "crc32" extension.
60     CRCHASHEXTNS_Crc32extnInit(interp);
61    
62     //Initialize the "credits" extension.
63     CreditsInit(interp);
64    
65     //Initialize the random number generation functions.
66     PrRandAInit(interp);
67    
68     //Initialize the version control information function
69     //"vcinfo".
70     VcinfoInit(interp);
71     }
72    
73     //07/28/01: Visually inspected. Seems OK. That plus using
74     //it should be enough.
75     int EXTNINIT_subextension_bsearch(
76     struct EXTNINIT_subextn_bsearch_record_struct *tbl,
77     int nelem,
78     const char *key)
79     {
80     int l, u, midpoint;
81     int compare_result;
82    
83     //Eyeball the input parameters.
84     assert(tbl != NULL);
85     assert(nelem >= 0);
86     assert(key != NULL);
87    
88     //Implement the standard bsearch algorithm.
89     l = 0;
90     u = nelem - 1;
91    
92     while(1)
93     {
94     if (l > u)
95     {
96     return(-1);
97     }
98     else
99     {
100     midpoint = (l + u) / 2;
101    
102     assert((midpoint >= 0) && (midpoint < nelem));
103    
104     compare_result = strcmp(key, tbl[midpoint].name);
105    
106     if (!compare_result)
107     {
108     return(midpoint);
109     }
110     else if (compare_result < 0)
111     {
112     u = midpoint - 1;
113     }
114     else
115     {
116     l = midpoint + 1;
117     }
118     }
119     }
120     }
121    
122    
123     const char *ExtninitCversion(void)
124     {
125     return ("$Header$");
126     }
127    
128    
129     const char *ExtninitHversion(void)
130     {
131     return (EXTNINIT_H_VERSION);
132     }
133    
134     //End of extninit.c.

Properties

Name Value
svn:eol-style native
svn:keywords Header

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25