[go: up one dir, main page]

Menu

[bde3dc]: / util / utils.h  Maximize  Restore  History

Download this file

90 lines (78 with data), 3.8 kB

 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
84
85
86
87
88
89
/*******************************************************************************
* *
* utils.h -- Nirvana Editor Utilities Header File *
* *
* Copyright 2002 The NEdit Developers *
* *
* This 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. In addition, you may distribute versions of this program linked to *
* Motif or Open Motif. See README for details. *
* *
* This software 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 *
* software; if not, write to the Free Software Foundation, Inc., 59 Temple *
* Place, Suite 330, Boston, MA 02111-1307 USA *
* *
* Nirvana Text Editor *
* July 31, 2001 *
* *
*******************************************************************************/
#ifndef NEDIT_UTILS_H_INCLUDED
#define NEDIT_UTILS_H_INCLUDED
#include <sys/utsname.h>
#include <sys/types.h>
#ifdef VMS
#include "vmsparam.h"
#else
#include <sys/param.h>
#endif /*VMS*/
const char *GetCurrentDir(void);
const char *GetHomeDir(void);
char *PrependHome(const char *filename, char *buf, size_t buflen);
const char *GetUserName(void);
const char *GetNameOfHost(void);
int Min(int i1, int i2);
const char* GetRCFileName(int type);
/*
** Simple stack implementation which only keeps void pointers.
** The stack must already be allocated and initialised:
**
** Stack* stack = (Stack*) XtMalloc(sizeof(Stack));
** stack->top = NULL;
** stack->size = 0;
**
** NULL is not allowed to pass in, as it is used to signal an empty stack.
**
** The user should only ever care about Stack, stackObject is an internal
** object. (So it should really go in utils.c. A forward reference was
** refused by my compiler for some reason though.)
*/
typedef struct _stackObject {
void* value;
struct _stackObject* next;
} stackObject;
typedef struct {
unsigned size;
stackObject* top;
} Stack;
void Push(Stack* stack, const void* value);
void* Pop(Stack* stack);
/* N_FILE_TYPES must be the last entry!! This saves us from counting. */
enum {NEDIT_RC, AUTOLOAD_NM, NEDIT_HISTORY, N_FILE_TYPES};
/* If anyone knows where to get this from system include files (in a machine
independent way), please change this (L_cuserid is apparently not ANSI) */
#define MAXUSERNAMELEN 32
/* Ditto for the maximum length for a node name. SYS_NMLN is not available
on most systems, and I don't know what the portable alternative is. */
#ifdef SYS_NMLN
#define MAXNODENAMELEN SYS_NMLN
#else
#define MAXNODENAMELEN (MAXPATHLEN+2)
#endif
#endif /* NEDIT_UTILS_H_INCLUDED */