当前位置: 首页>>代码示例>>C++>>正文


C++ Handle_val函数代码示例

本文整理汇总了C++中Handle_val函数的典型用法代码示例。如果您正苦于以下问题:C++ Handle_val函数的具体用法?C++ Handle_val怎么用?C++ Handle_val使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Handle_val函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: copy_file_times

// Copy file times
CAMLprim value copy_file_times(value in_h_val, value out_h_val) {
	CAMLparam2(in_h_val, out_h_val);
	int good;
#if defined(WIN32)
	HANDLE in_h = Handle_val(in_h_val);
	HANDLE out_h = Handle_val(out_h_val);
	FILETIME create;
	FILETIME access;
	FILETIME modify;
	good = GetFileTime(in_h, &create, &access, &modify);
	if(good) {
		good = SetFileTime(out_h, &create, &access, &modify);
	}
#else
	int in_h = Int_val(in_h_val);
	int out_h = Int_val(out_h_val);
	struct stat s;
	struct timeval set[2];
	good = !fstat(in_h, &s);
	if(good) {
		set[0].tv_sec = s.st_atime;
		set[0].tv_usec = 0;
		set[1].tv_sec = s.st_mtime;
		set[1].tv_usec = 0;
		good = !futimes(out_h, set);
	}
#endif
	CAMLreturn(Val_bool(good));
}
开发者ID:hmage,项目名称:mp3packer,代码行数:30,代码来源:c_part.c

示例2: caml_dynlink_lookup_symbol

/*#include <stdio.h>*/
CAMLprim value caml_dynlink_lookup_symbol(value handle, value symbolname)
{
  void * symb;
  value result;
  symb = caml_dlsym(Handle_val(handle), String_val(symbolname));
  /* printf("%s = 0x%lx\n", String_val(symbolname), symb);
     fflush(stdout); */
  if (symb == NULL) return Val_unit /*caml_failwith(caml_dlerror())*/;
  result = caml_alloc_small(1, Abstract_tag);
  Handle_val(result) = symb;
  return result;
}
开发者ID:ArnaudParant,项目名称:install_script,代码行数:13,代码来源:dynlink.c

示例3: CAMLparam5

CAMLprim value w_create_process_native
(value prog, value wprog, value wargs, value fd1, value fd2, value fd3)
{
  int res, flags;
  PROCESS_INFORMATION pi;
  STARTUPINFOW si;
  wchar_t fullname [MAX_PATH];
  HANDLE h;
  CAMLparam5(wprog, wargs, fd1, fd2, fd3);

  res = SearchPathW (NULL, (LPCWSTR) String_val(wprog), L".exe",
		     MAX_PATH, fullname, NULL);
  if (res == 0) {
    win32_maperr (GetLastError ());
    uerror("create_process", prog);
  }

  ZeroMemory(&si, sizeof(STARTUPINFO));

  si.cb = sizeof(STARTUPINFO);
  si.dwFlags = STARTF_USESTDHANDLES;
  si.hStdInput = Handle_val(fd1);
  si.hStdOutput = Handle_val(fd2);
  si.hStdError = Handle_val(fd3);

  flags = GetPriorityClass (GetCurrentProcess ());
  /*
  h = CreateFile ("CONOUT$", GENERIC_WRITE, FILE_SHARE_WRITE, NULL,
                  OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
  if (h != INVALID_HANDLE_VALUE)
    CloseHandle (h);
  else {
    flags |= CREATE_NEW_CONSOLE;
    //    si.dwFlags |= STARTF_USESHOWWINDOW;
    //    si.wShowWindow = SW_MINIMIZE;
  }
  */

  res = CreateProcessW (fullname, (LPWSTR) String_val(wargs),
			NULL, NULL, TRUE, flags,
		        NULL, NULL, &si, &pi);
  if (res == 0) {
    win32_maperr (GetLastError ());
    uerror("create_process", prog);
  }

  CloseHandle (pi.hThread);
  CAMLreturn (Val_long (pi.hProcess));
}
开发者ID:Phylliade,项目名称:Unison,代码行数:49,代码来源:system_win_stubs.c

示例4: win_set_inherit

int win_set_inherit(value fd, BOOL inherit)
{
  HANDLE oldh, newh;

  oldh = Handle_val(fd);
  if (! DuplicateHandle(GetCurrentProcess(), oldh,
                        GetCurrentProcess(), &newh,
                        0L, inherit, DUPLICATE_SAME_ACCESS)) {
    win32_maperr(GetLastError());
    return -1;
  }
  Handle_val(fd) = newh;
  CloseHandle(oldh);
  return 0;
}
开发者ID:retired-camels,项目名称:ocaml,代码行数:15,代码来源:close_on.c

示例5: lwt_unix_read

CAMLprim value lwt_unix_read(value fd, value buf, value vofs, value vlen)
{
  intnat ofs, len, written;
  DWORD numbytes, numwritten;
  DWORD err = 0;

  Begin_root (buf);
    ofs = Long_val(vofs);
    len = Long_val(vlen);
    written = 0;
    if (len > 0) {
      numbytes = len;
      if (Descr_kind_val(fd) == KIND_SOCKET) {
        int ret;
        SOCKET s = Socket_val(fd);
        ret = recv(s, &Byte(buf, ofs), numbytes, 0);
        if (ret == SOCKET_ERROR) err = WSAGetLastError();
        numwritten = ret;
      } else {
        HANDLE h = Handle_val(fd);
        if (! ReadFile(h, &Byte(buf, ofs), numbytes, &numwritten, NULL))
          err = GetLastError();
      }
      if (err) {
        win32_maperr(err);
        uerror("write", Nothing);
      }
      written = numwritten;
    }
  End_roots();
  return Val_long(written);
}
开发者ID:avsm,项目名称:lwt-OLD,代码行数:32,代码来源:lwt_unix_windows.c

示例6: handle_of_descr

static HANDLE handle_of_descr(value x)
{
	if(Descr_kind_val(x) != KIND_HANDLE){
		failwith("mlterminal(the channel is not a file handle)");
	}
	return Handle_val(x);
}
开发者ID:tanyataylor,项目名称:terminal-ocaml,代码行数:7,代码来源:terminal_stub.c

示例7: unix_read

CAMLprim value unix_read(value fd, value buf, value ofs, value vlen)
{
  intnat len;
  DWORD numbytes, numread;
  char iobuf[UNIX_BUFFER_SIZE];
  DWORD err = 0;

  Begin_root (buf);
    len = Long_val(vlen);
    numbytes = len > UNIX_BUFFER_SIZE ? UNIX_BUFFER_SIZE : len;
    if (Descr_kind_val(fd) == KIND_SOCKET) {
      int ret;
      SOCKET s = Socket_val(fd);
      enter_blocking_section();
      ret = recv(s, iobuf, numbytes, 0);
      if (ret == SOCKET_ERROR) err = WSAGetLastError();
      leave_blocking_section();
      numread = ret;
    } else {
      HANDLE h = Handle_val(fd);
      enter_blocking_section();
      if (! ReadFile(h, iobuf, numbytes, &numread, NULL))
        err = GetLastError();
      leave_blocking_section();
    }
    if (err) {
      win32_maperr(err);
      uerror("read", Nothing);
    }
    memmove (&Byte(buf, Long_val(ofs)), iobuf, numread);
  End_roots();
  return Val_int(numread);
}
开发者ID:MassD,项目名称:ocaml,代码行数:33,代码来源:read.c

示例8: onlyWin32_create_process_chdir_native

value onlyWin32_create_process_chdir_native(value cmd, value cmdline, value env,
				  value fd1, value fd2, value fd3, value maybe_chdir)
{
  PROCESS_INFORMATION pi;
  STARTUPINFO si;
  char * exefile, * envp;
  int flags;
  LPCTSTR lpCurrentDirectory = NULL;

  exefile = search_exe_in_path(String_val(cmd));
  if (env != Val_int(0)) {
    envp = String_val(Field(env, 0));
  } else {
    envp = NULL;
  }
  /* Prepare stdin/stdout/stderr redirection */
  ZeroMemory(&si, sizeof(STARTUPINFO));
  si.cb = sizeof(STARTUPINFO);
  si.dwFlags = STARTF_USESTDHANDLES;
  si.hStdInput = Handle_val(fd1);
  si.hStdOutput = Handle_val(fd2);
  si.hStdError = Handle_val(fd3);
  /* If we do not have a console window, then we must create one
     before running the process (keep it hidden for apparence).
     If we are starting a GUI application, the newly created
     console should not matter. */
  if (onlyWin32_has_console())
    flags = 0;
  else {
    flags = CREATE_NEW_CONSOLE;
    si.dwFlags = (STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES);
    si.wShowWindow = SW_HIDE;
  }
  if( maybe_chdir != Val_int(0) ){
    lpCurrentDirectory = String_val(Field(maybe_chdir,0));
  }
  /* Create the process */
  if (! CreateProcess(NULL, String_val(cmdline), NULL, NULL,
                      TRUE, flags, envp, lpCurrentDirectory, &si, &pi)) {
    win32_maperr(GetLastError());
    uerror("create_process", cmd);
  }
  CloseHandle(pi.hThread);
  /* Return the process handle as pseudo-PID
     (this is consistent with the wait() emulation in the MSVC C library */
  return Val_long(pi.hProcess);
}
开发者ID:lefessan,项目名称:typerex-build,代码行数:47,代码来源:onlyWin32_c.c

示例9: win_alloc_handle

value win_alloc_handle(HANDLE h)
{
  value res = alloc_custom(&win_handle_ops, sizeof(struct filedescr), 0, 1);
  Handle_val(res) = h;
  Descr_kind_val(res) = KIND_HANDLE;
  CRT_fd_val(res) = NO_CRT_FD;
  return res;
}
开发者ID:dirkdokter,项目名称:pprz-installer-fedora,代码行数:8,代码来源:unixsupport.c

示例10: win_findclose

CAMLprim value win_findclose(value valh)
{
  if (! FindClose(Handle_val(valh))) {
    win32_maperr(GetLastError());
    uerror("closedir", Nothing);
  }
  return Val_unit;
}
开发者ID:vouillon,项目名称:ocaml,代码行数:8,代码来源:windir.c

示例11: unix_lseek_64

CAMLprim value unix_lseek_64(value fd, value ofs, value cmd)
{
  __int64 ret;

  ret = caml_set_file_pointer(Handle_val(fd), Int64_val(ofs),
                              seek_command_table[Int_val(cmd)]);
  return copy_int64(ret);
}
开发者ID:OCamlPro,项目名称:OCamlPro-OCaml-Branch,代码行数:8,代码来源:lseek.c

示例12: do_fstat

static value do_fstat(value handle, int use_64)
{
  int ret;
  struct _stat64 buf;
  __int64 st_ino;
  HANDLE h;
  DWORD ft;

  st_ino = 0;
  memset(&buf, 0, sizeof buf);
  buf.st_nlink = 1;

  h = Handle_val(handle);
  ft = GetFileType(h) & ~FILE_TYPE_REMOTE;
  switch(ft) {
  case FILE_TYPE_DISK:
    if (!safe_do_stat(0, use_64, NULL, Handle_val(handle), &st_ino, &buf)) {
      uerror("fstat", Nothing);
    }
    break;
  case FILE_TYPE_CHAR:
    buf.st_mode = S_IFCHR;
    break;
  case FILE_TYPE_PIPE:
    {
      DWORD n_avail;
      if (Descr_kind_val(handle) == KIND_SOCKET) {
        buf.st_mode = S_IFSOCK;
      }
      else {
        buf.st_mode = S_IFIFO;
      }
      if (PeekNamedPipe(h, NULL, 0, NULL, &n_avail, NULL)) {
        buf.st_size = n_avail;
      }
    }
    break;
  case FILE_TYPE_UNKNOWN:
    unix_error(EBADF, "fstat", Nothing);
  default:
    win32_maperr(GetLastError());
    uerror("fstat", Nothing);
  }
  return stat_aux(use_64, st_ino, &buf);
}
开发者ID:dhil,项目名称:ocaml-multicore,代码行数:45,代码来源:stat.c

示例13: win_findclosew

CAMLprim value win_findclosew(value valh)
{
  CAMLparam1(valh);

  if (! FindClose(Handle_val(valh))) {
    win32_maperr(GetLastError());
    uerror("closedir", Nothing);
  }
  CAMLreturn (Val_unit);
}
开发者ID:Phylliade,项目名称:Unison,代码行数:10,代码来源:system_win_stubs.c

示例14: win_CRT_fd_of_filedescr

int win_CRT_fd_of_filedescr(value handle)
{
  if (CRT_fd_val(handle) != NO_CRT_FD) {
    return CRT_fd_val(handle);
  } else {
    int fd = _open_osfhandle((long) Handle_val(handle), O_BINARY);
    if (fd == -1) uerror("channel_of_descr", Nothing);
    return fd;
  }
}
开发者ID:d5nguyenvan,项目名称:mirage,代码行数:10,代码来源:channels.c

示例15: unix_fstat_64

CAMLprim value unix_fstat_64(value handle)
{
  int ret;
  struct _stat64 buf;
  __int64 st_ino;
  if (!do_stat(0, 1, NULL, 0, Handle_val(handle), &st_ino, &buf)) {
    uerror("fstat", Nothing);
  }
  return stat_aux(1, st_ino, &buf);
}
开发者ID:ocsigen,项目名称:ocaml-eliom,代码行数:10,代码来源:stat.c


注:本文中的Handle_val函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。