common.h revision 178825
1178825Sdfr/* 2178825Sdfr * Copyright (c) 2006 Kungliga Tekniska H�gskolan 3178825Sdfr * (Royal Institute of Technology, Stockholm, Sweden). 4178825Sdfr * All rights reserved. 5178825Sdfr * 6178825Sdfr * Redistribution and use in source and binary forms, with or without 7178825Sdfr * modification, are permitted provided that the following conditions 8178825Sdfr * are met: 9178825Sdfr * 10178825Sdfr * 1. Redistributions of source code must retain the above copyright 11178825Sdfr * notice, this list of conditions and the following disclaimer. 12178825Sdfr * 13178825Sdfr * 2. Redistributions in binary form must reproduce the above copyright 14178825Sdfr * notice, this list of conditions and the following disclaimer in the 15178825Sdfr * documentation and/or other materials provided with the distribution. 16178825Sdfr * 17178825Sdfr * 3. Neither the name of KTH nor the names of its contributors may be 18178825Sdfr * used to endorse or promote products derived from this software without 19178825Sdfr * specific prior written permission. 20178825Sdfr * 21178825Sdfr * THIS SOFTWARE IS PROVIDED BY KTH AND ITS CONTRIBUTORS ``AS IS'' AND ANY 22178825Sdfr * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23178825Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24178825Sdfr * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KTH OR ITS CONTRIBUTORS BE 25178825Sdfr * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26178825Sdfr * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27178825Sdfr * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 28178825Sdfr * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29178825Sdfr * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 30178825Sdfr * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 31178825Sdfr * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32178825Sdfr */ 33178825Sdfr 34178825Sdfr/* $Id: common.h 18250 2006-10-06 07:22:00Z lha $ */ 35178825Sdfr 36178825Sdfr#ifdef HAVE_CONFIG_H 37178825Sdfr#include <config.h> 38178825Sdfr#endif 39178825Sdfr 40178825Sdfr/* 41178825Sdfr * pthread support is disable because the pthread 42178825Sdfr * test have no "application pthread libflags" variable, 43178825Sdfr * when this is fixed pthread support can be enabled again. 44178825Sdfr */ 45178825Sdfr#undef ENABLE_PTHREAD_SUPPORT 46178825Sdfr 47178825Sdfr#include <sys/param.h> 48178825Sdfr#ifdef HAVE_SYS_UTSNAME_H 49178825Sdfr#include <sys/utsname.h> 50178825Sdfr#endif 51178825Sdfr 52178825Sdfr#ifdef HAVE_SYS_WAIT_H 53178825Sdfr#include <sys/wait.h> 54178825Sdfr#endif 55178825Sdfr 56178825Sdfr#include <assert.h> 57178825Sdfr#include <krb5.h> 58178825Sdfr#include <gssapi.h> 59178825Sdfr#include <unistd.h> 60178825Sdfr 61178825Sdfr#include <roken.h> 62178825Sdfr#include <getarg.h> 63178825Sdfr 64178825Sdfr#include "protocol.h" 65178825Sdfr 66178825Sdfrkrb5_error_code store_string(krb5_storage *, const char *); 67178825Sdfr 68178825Sdfr 69178825Sdfr#define ret16(_client, num) \ 70178825Sdfr do { \ 71178825Sdfr if (krb5_ret_int16((_client)->sock, &(num)) != 0) \ 72178825Sdfr errx(1, "krb5_ret_int16 " #num); \ 73178825Sdfr } while(0) 74178825Sdfr 75178825Sdfr#define ret32(_client, num) \ 76178825Sdfr do { \ 77178825Sdfr if (krb5_ret_int32((_client)->sock, &(num)) != 0) \ 78178825Sdfr errx(1, "krb5_ret_int32 " #num); \ 79178825Sdfr } while(0) 80178825Sdfr 81178825Sdfr#define retdata(_client, data) \ 82178825Sdfr do { \ 83178825Sdfr if (krb5_ret_data((_client)->sock, &(data)) != 0) \ 84178825Sdfr errx(1, "krb5_ret_data " #data); \ 85178825Sdfr } while(0) 86178825Sdfr 87178825Sdfr#define retstring(_client, data) \ 88178825Sdfr do { \ 89178825Sdfr if (krb5_ret_string((_client)->sock, &(data)) != 0) \ 90178825Sdfr errx(1, "krb5_ret_data " #data); \ 91178825Sdfr } while(0) 92178825Sdfr 93178825Sdfr 94178825Sdfr#define put32(_client, num) \ 95178825Sdfr do { \ 96178825Sdfr if (krb5_store_int32((_client)->sock, num) != 0) \ 97178825Sdfr errx(1, "krb5_store_int32 " #num); \ 98178825Sdfr } while(0) 99178825Sdfr 100178825Sdfr#define putdata(_client, data) \ 101178825Sdfr do { \ 102178825Sdfr if (krb5_store_data((_client)->sock, data) != 0) \ 103178825Sdfr errx(1, "krb5_store_data " #data); \ 104178825Sdfr } while(0) 105178825Sdfr 106178825Sdfr#define putstring(_client, str) \ 107178825Sdfr do { \ 108178825Sdfr if (store_string((_client)->sock, str) != 0) \ 109178825Sdfr errx(1, "krb5_store_str " #str); \ 110178825Sdfr } while(0) 111178825Sdfr 112178825Sdfrchar *** permutate_all(struct getarg_strings *, size_t *); 113