(file) Return to VMS_Crtl_Init.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Platforms / Vms

  1 karl  1.5 //%2006////////////////////////////////////////////////////////////////////////
  2 karl  1.2 //
  3           // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
  4           // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
  5           // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  6           // IBM Corp.; EMC Corporation, The Open Group.
  7           // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8           // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9           // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10           // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl  1.5 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12           // EMC Corporation; Symantec Corporation; The Open Group.
 13 karl  1.2 //
 14           // Permission is hereby granted, free of charge, to any person obtaining a copy
 15           // of this software and associated documentation files (the "Software"), to
 16           // deal in the Software without restriction, including without limitation the
 17           // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 18           // sell copies of the Software, and to permit persons to whom the Software is
 19           // furnished to do so, subject to the following conditions:
 20 carson.hovey 1.6 //
 21 karl         1.2 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22                  // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 23                  // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 24                  // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 25                  // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 26                  // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 27                  // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 28                  // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 29                  //
 30                  //==============================================================================
 31 carson.hovey 1.6 // 
 32                  // This example of how to call lib$initialize from C++ was taken 
 33                  // from the internal notes file: cxxc_bugs 11466.4
 34                  //
 35                  #include <unixlib.h>      // decc$feature_get_index(), set_value()
 36 john.eisenbraun 1.8 
 37                     #if defined __USE_STD_IOSTREAM
 38                     #include <iostream>       // cout.sync_with_stdio(false), etc.
 39                     #endif
 40                     
 41 carson.hovey    1.6 #include <stdio.h>        // perror()
 42                     #include <errno.h>        // errno
 43                     
 44                     #ifdef __cplusplus
 45                     extern "C" {
 46                     #endif
 47 gs.keenan       1.1 
 48                     
 49 carson.hovey    1.6 typedef void (*fptr_t)(void);
 50 gs.keenan       1.1 
 51                     //
 52                     // Sets current value for a feature
 53                     //
 54                     static void set(char *name, int value)
 55                     {
 56                       int index;
 57                       errno = 0;
 58                     
 59                       index = decc$feature_get_index(name);
 60                     
 61                       if (index == -1 || 
 62                           (decc$feature_set_value(index, 1, value) == -1 && 
 63                            errno != 0))
 64                       {
 65                         perror(name);
 66                       }
 67                     }
 68                     
 69                     static void set_coe(void)
 70                     {
 71 john.eisenbraun 1.7   int logname_cache = 60; // 60 seconds = 1 min. cache.
 72                      
 73 gs.keenan       1.1   set ("DECC$ARGV_PARSE_STYLE", TRUE);
 74 john.eisenbraun 1.7   set ("DECC$ENABLE_GETENV_CACHE", TRUE); 
 75                       set ("DECC$ENABLE_TO_VMS_LOGNAME_CACHE", logname_cache); 
 76 gs.keenan       1.1   set ("DECC$FILE_SHARING", TRUE);
 77                       set ("DECC$DISABLE_TO_VMS_LOGNAME_TRANSLATION", TRUE);
 78                       set ("DECC$EFS_CASE_PRESERVE", TRUE);
 79                       set ("DECC$EFS_CHARSET", TRUE);
 80                       set ("DECC$EFS_FILE_TIMESTAMPS", TRUE);
 81                       set ("DECC$FILENAME_UNIX_NO_VERSION", TRUE);
 82 john.eisenbraun 1.7   set ("DECC$STDIO_CTX_EOL", TRUE);
 83 carson.hovey    1.6 #if !defined FILENAME_UNIX_REPORT_FALSE
 84 gs.keenan       1.1   set ("DECC$FILENAME_UNIX_REPORT", TRUE);
 85 carson.hovey    1.6 #else
 86                       set ("DECC$FILENAME_UNIX_REPORT", FALSE);
 87                     #endif
 88 gs.keenan       1.1   set ("DECC$FILE_OWNER_UNIX", TRUE);
 89                       set ("DECC$FILE_PERMISSION_UNIX", TRUE);
 90                       set ("DECC$READDIR_DROPDOTNOTYPE", TRUE);
 91 gs.keenan       1.4   set ("DECC$FILENAME_UNIX_ONLY", FALSE);
 92 gs.keenan       1.1   set ("DECC$UMASK", 027);
 93 john.eisenbraun 1.7   set ("DECC$RENAME_NO_INHERIT", TRUE);
 94                     //  set ("DECC$PIPE_BUFFER_QUOTA", 4096);
 95                       set ("DECC$PIPE_BUFFER_SIZE", 4096);
 96                     
 97                     // 11JAN07 [cbh] With _USE_STD_STAT defined, POSIX_STYLE_UID can be enabled.
 98                     //               false (the default) is required because getpwnam_r()
 99                     //               always returns the UIC style group name which will not
100                     //               be found by getgrgid_r in POSIX (not UIC) mode
101                     //               when POSIX_STYLE_UID is enabled.
102                       set ("DECC$POSIX_STYLE_UID", FALSE);
103                     
104                     // PTR 75-109-857: Set DECC$SETVBUF_BUFFERRED
105                     // crtl_internal note 2232.
106                     // for one-char-per-line problem where lines are greater than 256.
107                     //
108                     // Note: SETVBUF_BUFFERED requires OpenVMS 8.3 or you get a message
109                     //       like this at run-time:
110                     // $ TestXmlPrint x.xml
111                     // DECC$SETVBUF_BUFFERED: no such file or directory
112                     //
113                     // 1-Feb-08 [cbh] Enable since only 8.3 or later is now supported.
114 john.eisenbraun 1.7 // 9-Aug-06 [cbh] Comment out SETVBUF_BUFFERED until we see a case
115                     //                where we fail without it since it causes problems on
116                     //                pre-OpenVMS 8.3 and I don't know if it will go in any
117                     //                tima kits and don't know what happens on Alpha.
118                       set ("DECC$SETVBUF_BUFFERED", TRUE);
119 gs.keenan       1.1 }
120                     
121 john.eisenbraun 1.8 //
122                     // unsync_streams_from_stdout
123                     //
124                     // When applications are run with the output directed to a file,
125                     // the output can be broken up across multiple lines.
126                     //
127                     // On Unix, output files are streams, not record oriented. On OpenVMS
128                     // you will see this problem when under circumstances such as:
129                     //
130                     // - A batch job (all output goes to the .log file)
131                     // - spawn/out=a.log
132                     // - A subprocess
133                     // - set host/log=a.log
134                     //
135                     // This code fixes that problem.
136                     //
137                     // Note: This fix only works for __USE_STD_IOSTREAM.
138                     // Note: See also: 75-109-857
139                     // 
140                     #if defined __USE_STD_IOSTREAM
141                     
142 john.eisenbraun 1.8 static void unsync_streams_from_stdout(void)
143                     {
144                     
145                       cout.sync_with_stdio(false);
146                       cerr.sync_with_stdio(false);
147                       cerr.unsetf(ios::unitbuf);
148                     
149                       wcout.sync_with_stdio(false);
150                       wcerr.sync_with_stdio(false);
151                       wcerr.unsetf(ios::unitbuf);
152                     
153                     }
154                     #endif
155 gs.keenan       1.1 
156 john.eisenbraun 1.9 static void init_lib(void)
157                     {
158                       set_coe();
159                     #if defined __USE_STD_IOSTREAM
160                       unsync_streams_from_stdout();
161                     #endif
162                     }
163 gs.keenan       1.1 
164                     #pragma extern_model save
165                     
166 john.eisenbraun 1.9 #pragma extern_model strict_refdef "LIB$INITIALIZE" gbl,noexe,nowrt,noshr,long
167                       extern const fptr_t y = init_lib;
168 john.eisenbraun 1.8 
169 gs.keenan       1.1 #pragma extern_model restore
170                     
171 carson.hovey    1.6 #ifdef __cplusplus
172                     } // extern "C"
173                     #endif
174                     

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2