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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2