service.h revision 1298
0N/A/*
0N/A * CDDL HEADER START
0N/A *
0N/A * The contents of this file are subject to the terms of the
0N/A * Common Development and Distribution License, Version 1.0 only
0N/A * (the "License"). You may not use this file except in compliance
0N/A * with the License.
0N/A *
0N/A * You can obtain a copy of the license at
0N/A * trunk/opends/resource/legal-notices/OpenDS.LICENSE
0N/A * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
0N/A * See the License for the specific language governing permissions
0N/A * and limitations under the License.
0N/A *
0N/A * When distributing Covered Code, include this CDDL HEADER in each
0N/A * file and include the License file at
0N/A * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
873N/A * add the following below this CDDL HEADER, with the fields enclosed
0N/A * by brackets "[]" replaced with your own identifying * information:
0N/A * Portions Copyright [yyyy] [name of copyright owner]
0N/A *
0N/A * CDDL HEADER END
0N/A *
733N/A *
0N/A * Portions Copyright 2007 Sun Microsystems, Inc.
0N/A */
0N/A
0N/A#include "common.h"
0N/A#include <errno.h>
0N/A#include <fcntl.h>
0N/A#include <io.h>
0N/A#include <stdio.h>
0N/A#include <sys/locking.h>
0N/A#include "EventLogMsg.h"
0N/A
0N/A#define MAX_SERVICE_NAME 256
0N/A
0N/A// ----------------------------------------------------
0N/A// Estimated time for a given operation (in ms).
0N/A// Note: if the estimated value is too short then the service controler
0N/A// may consider the service as not alive anymore! so the value
0N/A// must be as precise as possible (better have it too big rather
0N/A// than to small)
0N/A// ----------------------------------------------------
0N/A
0N/A#define TIMEOUT_NONE 0
0N/A#define TIMEOUT_CREATE_EVENT 5000
0N/A#define TIMEOUT_START_SERVICE 30000
0N/A#define TIMEOUT_STOP_SERVICE 30000
0N/A
0N/A// ----------------------------------------------------
0N/A// The first value to use for checkpoints
0N/A// ----------------------------------------------------
0N/A#define CHECKPOINT_FIRST_VALUE 1
0N/A
0N/A// ----------------------------------------------------
0N/A// Checkpoint value to use to let the SCM knows that there is
0N/A// no ongoing operation
0N/A// ----------------------------------------------------
0N/A#define CHECKPOINT_NO_ONGOING_OPERATION 0
0N/A
0N/A// ----------------------------------------------------
0N/A// Event Log Key.
0N/A// ----------------------------------------------------
0N/A#define EVENT_LOG_KEY "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\%s"
0N/A
0N/A// ----------------------------------------------------
0N/A// Max size of the registry key
0N/A// ----------------------------------------------------
0N/A#define MAX_REGISTRY_KEY 512
0N/A
0N/A// ----------------------------------------------------
0N/A// Max size of the binary to run the service
0N/A// ----------------------------------------------------
0N/A#define COMMAND_SIZE 2048
0N/A
0N/A#define SERVICE_ACCEPT_NONE 0
0N/A
0N/Atypedef struct {
0N/A char* serviceName; // the name of the service
0N/A char* displayName; // the display name of the service
0N/A char* cmdToRun; // the executable to run
0N/A } ServiceDescriptor;
0N/A
0N/Atypedef enum {
0N/A SERVICE_RETURN_OK, SERVICE_RETURN_ERROR, SERVICE_IN_USE,
0N/A SERVICE_NOT_IN_USE, DUPLICATED_SERVICE_NAME, SERVICE_ALREADY_EXISTS,
0N/A SERVICE_MARKED_FOR_DELETION
0N/A} ServiceReturnCode;
0N/A
0N/A
0N/AServiceReturnCode registerServiceHandler (char* serviceName,
0N/ALPHANDLER_FUNCTION serviceHandler, SERVICE_STATUS_HANDLE* serviceStatusHandle);
0N/AServiceReturnCode serviceNameInUse(char* serviceName);
0N/AServiceReturnCode createServiceName(char* serviceName, char* baseName);
0N/AServiceReturnCode getServiceList(ServiceDescriptor** serviceList,
0N/Aint *nbServices);
0N/AServiceReturnCode createServiceBinPath(char* serviceBinPath);
0N/AServiceReturnCode getServiceName(char* cmdToRun, char* serviceName);
0N/AServiceReturnCode updateServiceStatus (
0N/A DWORD statusToSet,
0N/A DWORD win32ExitCode,
0N/A DWORD serviceExitCode,
0N/A DWORD checkPoint,
0N/A DWORD waitHint,
0N/A SERVICE_STATUS_HANDLE *serviceStatusHandle
0N/A );
0N/Avoid serviceHandler(DWORD controlCode);
0N/A
0N/A