/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*-
 * ex: set softtabstop=4 tabstop=8 expandtab shiftwidth=4: *
 * Editor Settings: expandtabs and use 4 spaces for indentation */

/*
 * Copyright Likewise Software
 * All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.  You should have received a copy of the GNU General
 * Public License along with this program.  If not, see
 * <http://www.gnu.org/licenses/>.
 *
 * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
 * TERMS AS WELL.  IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
 * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
 * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
 * GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE.  IF YOU
 * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
 * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
 * license@likewisesoftware.com
 */

/*
 * Copyright (C) Likewise Software. All rights reserved.
 *
 * Module Name:
 *
 *        protocolapi_p.h
 *
 * Abstract:
 *
 *        Likewise IO (LWIO) - SRV
 *
 *        Protocol API (Private to protocol handlers)
 *
 * Authors: Sriram Nambakam (snambakam@likewise.com)
 *
 */

#ifndef __PROTOCOL_API_P_H__
#define __PROTOCOL_API_P_H__

typedef ULONG SRV_PERM_FILE;

#define SRV_PERM_FILE_NONE   0x0
#define SRV_PERM_FILE_READ   0x1
#define SRV_PERM_FILE_WRITE  0x2
#define SRV_PERM_FILE_CREATE 0x4

typedef struct _SRV_EXEC_CONTEXT_SMB_V1* PSRV_EXEC_CONTEXT_SMB_V1;
typedef struct _SRV_EXEC_CONTEXT_SMB_V2* PSRV_EXEC_CONTEXT_SMB_V2;

/**
 * @brief Allocate the space necessary to return the number of 64-bit FILETIMEs
 *    whose corresponding @GMT token strings would fit in OutputBufferSize
 *
 * An @GMT token is a NULL-terminated string formatted @GMT-YYYY.MM.DD-HH.MM-SS
 * and takes exactly 25 characters including the NULL terminator.  The space
 * needed for SMB_SRV_SNAPSHOT_ARRAY_HEADER and the header portion of
 * IO_SNAPSHOT_LIST is also taken into account.
 *
 * @param[in] OutputBufferSize  The @GMT token string buffer size
 * @param[in,out] pSnapshotListSize  The size, in bytes of the retuned buffer
 * @param[out] ppSnapshotList  Pointer to the PIO_SNAPSHOT_LIST buffer that will
 *     be allocated
 *
 * @retval STATUS_SUCCESS successfully allocated
 * @retval STATUS_BUFFER_TOO_SMALL OutputBufferSize is too small to accommodate
 *     any @GMT tokens
 * @retval STATUS_INSUFFICIENT_RESOURCES memory allocation failed
 * @retval STATUS_INVALID_PARAMETER failure-- date out of range
 * @retval !STATUS_SUCCESS
 */
NTSTATUS
SrvShadowCopyCreateQueryBuffer(
    IN ULONG OutputBufferSize,
    IN OUT PUSHORT pSnapshotListSize,
    OUT PVOID* ppSnapshotList
    );

/**
 * @brief Allocate space and convert a list of timestamps to @GMT token strings
 *
 * @param [in] OutputBufferSize  The size of the output buffer to be allocated
 * @param [in] pSnapshotList  The list of 64-bit FILETIMEs to convert
 * @param [out] pActualOutputBufferSize The actual size of the output buffer to
 *     be returned to the client
 * @param [out] ppSnapshotArray  Pointer to the output buffer to be allocated,
 *     inlcudes SMB_SRV_SNAPSHOT_ARRAY_HEADER and an array of @GMT tokens.
 *
 * @retval STATUS_SUCCESS Buffer successfully allocated, FILETIMEs converted
 * @retval !STATUS_SUCCESS
 */
NTSTATUS
SrvShadowCopyCreateEnumerateResponse(
    IN ULONG AllowedOutputBufferSize,
    IN PIO_SNAPSHOT_LIST pSnapshotList,
    OUT PULONG pActualOutputBufferSize,
    OUT PVOID* ppSnapshotArray
    );

#endif /* __PROTOCOL_API_P_H__ */

