/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import "oaidl.idl";
import "ocidl.idl";

[
  uuid(0492311C-1718-4F53-A6EB-86AD7039988D),
  version(1.0),
  pointer_default(unique),
  //implicit_handle(handle_t hHadoopWinutilsSvcBinding),
  endpoint("ncalrpc:[hadoopwinutilsvc]"),
#ifndef __midl  
  explicit_handle
#endif  
]
interface HadoopWinutilSvc
{
  typedef struct {
    [string] const wchar_t* cwd;
    [string] const wchar_t* jobName;
    [string] const wchar_t* user;
    [string] const wchar_t* pidFile;
    [string] const wchar_t* cmdLine;
  } CREATE_PROCESS_REQUEST;

  typedef struct {
    LONG_PTR hProcess;
    LONG_PTR hThread;
    LONG_PTR hStdIn;
    LONG_PTR hStdOut;
    LONG_PTR hStdErr;
  } CREATE_PROCESS_RESPONSE;

  typedef struct {
    [string] const wchar_t* filePath;
    [string] const wchar_t* ownerName;
    [string] const wchar_t* groupName;
  } CHOWN_REQUEST;

  typedef struct {
    [string] const wchar_t* filePath;
    int mode;
  } CHMOD_REQUEST;  

  typedef struct {
    [string] const wchar_t* filePath;
  } MKDIR_REQUEST;  

  typedef enum { MOVE_FILE = 1, COPY_FILE = 2} MOVE_COPY_OPERATION;

  typedef struct {
    MOVE_COPY_OPERATION operation;
    [string] const wchar_t* sourcePath;
    [string] const wchar_t* destinationPath;
    boolean replaceExisting;
  } MOVEFILE_REQUEST;

  typedef struct {
    [string] const wchar_t* path;
    int desiredAccess;
    int shareMode;
    int creationDisposition;
    int flags;
  } CREATEFILE_REQUEST;

  typedef struct {
    LONG_PTR hFile;
  } CREATEFILE_RESPONSE;

  typedef enum {PATH_IS_DIR = 1, PATH_IS_FILE = 2} DELETEPATH_TYPE;

  typedef struct {
  	DELETEPATH_TYPE type;
  	[string] const wchar_t* path;
  } DELETEPATH_REQUEST;

  typedef struct {
  	boolean deleted;
  } DELETEPATH_RESPONSE;

  typedef struct {
  	[string] const wchar_t* taskName;
  } KILLTASK_REQUEST;

  error_status_t WinutilsKillTask(
    [in] KILLTASK_REQUEST *request);

  error_status_t WinutilsMkDir(
    [in] MKDIR_REQUEST *request);

  error_status_t WinutilsMoveFile(
    [in] MOVEFILE_REQUEST *request);

  error_status_t WinutilsChown(
    [in] CHOWN_REQUEST *request);

  error_status_t WinutilsChmod(
    [in] CHMOD_REQUEST *request);

  error_status_t WinutilsCreateFile(
    [in] int nmPid,
    [in] CREATEFILE_REQUEST *request,
    [out] CREATEFILE_RESPONSE **response);

  error_status_t WinutilsDeletePath(
  	[in] DELETEPATH_REQUEST *request,
  	[out] DELETEPATH_RESPONSE **response);

  error_status_t WinutilsCreateProcessAsUser(
    [in] int nmPid,
    [in] CREATE_PROCESS_REQUEST *request,
    [out] CREATE_PROCESS_RESPONSE **response);
    
}
