Skip to content
Snippets Groups Projects
Select Git revision
  • abfe5dca81d5419729b4f7db2269f8a866313f8e
  • master default
  • library-names
  • fix_script_header
  • fix_libdir
  • fix_cmake_hdf5
  • partition
  • cgnsUnstructured
  • partitioning
  • HighOrderBLCurving
  • gmsh_3_0_5
  • gmsh_3_0_4
  • gmsh_3_0_3
  • gmsh_3_0_2
  • gmsh_3_0_1
  • gmsh_3_0_0
  • gmsh_2_16_0
  • gmsh_2_15_0
  • gmsh_2_14_1
  • gmsh_2_14_0
  • gmsh_2_13_2
  • gmsh_2_13_1
  • gmsh_2_12_0
  • gmsh_2_11_0
  • gmsh_2_10_1
  • gmsh_2_10_0
  • gmsh_2_9_3
  • gmsh_2_9_2
  • gmsh_2_9_1
  • gmsh_2_9_0
30 results

OS.cpp

Blame
  • Forked from gmsh / gmsh
    Source project has a limited visibility.
    OS.cpp 14.14 KiB
    // Gmsh - Copyright (C) 1997-2014 C. Geuzaine, J.-F. Remacle
    //
    // See the LICENSE.txt file for license information. Please report all
    // bugs and problems to the public mailing list <gmsh@geuz.org>.
    
    // This file contains a bunch of functions that depend on OS-dependent
    // features and/or system calls
    
    // these are available on all OSes
    #include <stdlib.h>
    #include <stdio.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <signal.h>
    #include <time.h>
    #include <math.h>
    #include "GmshConfig.h"
    #include "StringUtils.h"
    #include "Context.h"
    
    #if defined(__APPLE__)
    #include <sys/sysctl.h>
    #endif
    
    #if defined(__linux__) && !defined(BUILD_ANDROID)
    #include <sys/sysinfo.h>
    #endif
    
    #if !defined(WIN32) || defined(__CYGWIN__)
    #include <unistd.h>
    #include <sys/time.h>
    #include <sys/resource.h>
    #endif
    
    #if defined(WIN32)
    #include <windows.h>
    #include <process.h>
    #include <psapi.h>
    #include <io.h>
    #include <direct.h>
    #include <fcntl.h>
    #include <iostream>
    #include <fstream>
    #endif
    
    #include "GmshMessage.h"
    
    #if defined(WIN32) && !defined(__CYGWIN__)
    
    // Unicode utility routines borrowed from FLTK
    
    static unsigned utf8decode(const char* p, const char* end, int* len)
    {
      static unsigned short cp1252[32] = {
        0x20ac, 0x0081, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021,
        0x02c6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008d, 0x017d, 0x008f,
        0x0090, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
        0x02dc, 0x2122, 0x0161, 0x203a, 0x0153, 0x009d, 0x017e, 0x0178
      };
      unsigned char c = *(unsigned char*)p;
      if (c < 0x80) {
        if (len) *len = 1;
        return c;
      } else if (c < 0xa0) {
        if (len) *len = 1;
        return cp1252[c-0x80];
      } else if (c < 0xc2) {
        goto FAIL;
      }
      if ( (end && p+1 >= end) || (p[1]&0xc0) != 0x80) goto FAIL;