Imported Upstream version 3.2.0
[debian/amanda] / ndmp-src / ndmos_glib.h
1 /*
2  * Copyright (c) 1998,1999,2000
3  *      Traakan, Inc., Los Altos, CA
4  *      All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice unmodified, this list of conditions, and the following
11  *    disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28
29 /*
30  * Project:  NDMJOB
31  * Ident:    $Id: $
32  *
33  * Description:
34  *      This establishes the environment and options
35  *      for the Glib "platform".   That is, it reflects all of the ndmjoblib
36  *      abstractions into the corresponding glib abstractions.  This, combined
37  *      with the O/S generic ndmos.h, are the foundation
38  *      for NDMJOBLIB.
39  *
40  *      This file is #include'd by ndmos.h when
41  *      selected by #ifdef's of NDMOS_ID.
42  *
43  *      Refer to ndmos.h for explanations of the
44  *      macros thar are or can be #define'd here.
45  */
46
47 #include "amanda.h"
48 #ifdef HAVE_RPC_RPC_H
49 #include <rpc/rpc.h>
50 #else
51 #error rpc/rpc.h is required to compile ndmp-src
52 #endif
53
54
55 /* this may need to be autodetected, or NDMOS_MACRO_SET_SOCKADDR may need to be
56  * rewritten in terms of Amanda's sockaddr-util.h.  According to ndmpjoblib,
57  * only FreeBDS has sin_len. */
58 #undef NDMOS_OPTION_HAVE_SIN_LEN
59
60 #define NDMOS_OPTION_TAPE_SIMULATOR
61 #define NDMOS_OPTION_ROBOT_SIMULATOR
62
63 #define NDMOS_OPTION_USE_SELECT_FOR_CHAN_POLL
64
65 #define NDMOS_API_BCOPY(S,D,N) g_memmove((void*)(D), (void*)(S), (N))
66 /* default: NDMOS_API_BZERO */
67 #define NDMOS_API_MALLOC(N) g_malloc((N))
68 #define NDMOS_API_FREE(P) g_free((void*)(P))
69 #define NDMOS_API_STRTOLL(P,PP,BASE) strtoll((P),(PP),(BASE))
70 #define NDMOS_API_STRDUP(S) g_strdup((S))
71 /* default: NDMOS_API_STREND (default: implemented in ndml_util.c) */
72
73 /* default: NDMOS_CONST_ALIGN */
74 /* default: NDMOS_CONST_EWOULDBLOCK */
75 /* default: NDMOS_CONST_TAPE_REC_MAX */
76 /* default: NDMOS_CONST_TAPE_REC_MIN */
77 /* default: NDMOS_CONST_PATH_MAX */
78 #define NDMOS_CONST_NDMOS_REVISION "Glib-2.2+"
79
80 #define NDMOS_MACRO_NEW(T) g_new(T, 1)
81 #define NDMOS_MACRO_NEWN(T,N) g_new(T, (N))
82 /* default: NDMOS_MACRO_ZEROFILL */
83 #define NDMOS_MACRO_SRAND() g_random_set_seed(time(0))
84 #define NDMOS_MACRO_RAND() g_random_int()
85 /* default: NDMOS_MACRO_OK_TAPE_REC_LEN */
86
87 /* extra */
88 #ifdef assert
89 #undef assert
90 #endif
91 #define assert g_assert