File: utils.h

package info (click to toggle)
latd 1.32
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 1,352 kB
  • sloc: cpp: 8,489; sh: 878; makefile: 85
file content (83 lines) | stat: -rw-r--r-- 2,106 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/******************************************************************************
    (c) 2002 Christine Caulfield                 christine.caulfield@googlemail.com

    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
    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.
******************************************************************************/


void add_string(unsigned char *packet, int *ptr, 
		const unsigned char *string);

void get_string(unsigned char *packet, int *ptr, 
		unsigned char *string);


int expand_issue(const char *original, int len,
		 char *newstring, int maxlen,
		 const char *servicename);

#ifndef HAVE_OPENPTY
#define INTERNAL_OPENPTY
#else
#ifdef HAVE_PTY_H
#include <pty.h>
#endif /* HAVE_PTY_H */
#ifdef HAVE_TERMIOS_H
#include <termios.h>
#endif /* HAVE_TERMIOS_H */
#ifdef HAVE_LIBUTIL_H
#include <libutil.h>
#endif /* HAVE_LIBUTIL_H */
#ifdef HAVE_UTIL_H
#include <util.h>
#endif /* HAVE_UTIL_H */
#endif

// RedHat 5 has a broken openpty()
#ifdef INTERNAL_OPENPTY
int chrissie_openpty(int*,int*, char*,char*,char*);
#define openpty chrissie_openpty
#endif

#if defined(VERBOSE_DEBUG)
#include <stdarg.h>
extern void chrissie_debuglog(char *,...);
#endif

#ifdef VERBOSE_DEBUG
#define debuglog(x) chrissie_debuglog x

//#include <stdarg.h>
//extern void chrissie_debuglog(char *,...);
#else
#define debuglog(x)
#endif

#include <signal.h>

class sig_blk_t {
public:
    sig_blk_t(int sig_num)
    {
        sigset_t new_set;

        sigemptyset(&new_set);
        sigaddset(&new_set, sig_num);
        sigprocmask(SIG_BLOCK, &new_set, &saved_set);
    }
    virtual ~sig_blk_t()
    {
        sigprocmask(SIG_SETMASK, &saved_set, NULL);
    }

private:
    sigset_t saved_set;
};