1 /* $Id: utils.h,v 1.17 2008/01/04 22:11:05 yooden Exp $ */
2 /*******************************************************************************
4 * utils.h -- Nirvana Editor Utilities Header File *
6 * Copyright 2002 The NEdit Developers *
8 * This is free software; you can redistribute it and/or modify it under the *
9 * terms of the GNU General Public License as published by the Free Software *
10 * Foundation; either version 2 of the License, or (at your option) any later *
11 * version. In addition, you may distribute versions of this program linked to *
12 * Motif or Open Motif. See README for details. *
14 * This software is distributed in the hope that it will be useful, but WITHOUT *
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
19 * You should have received a copy of the GNU General Public License along with *
20 * software; if not, write to the Free Software Foundation, Inc., 59 Temple *
21 * Place, Suite 330, Boston, MA 02111-1307 USA *
23 * Nirvana Text Editor *
26 *******************************************************************************/
28 #ifndef NEDIT_UTILS_H_INCLUDED
29 #define NEDIT_UTILS_H_INCLUDED
31 #include <sys/utsname.h>
36 #include <sys/param.h>
39 const char *GetCurrentDir(void);
40 const char *GetHomeDir(void);
41 char *PrependHome(const char *filename
, char *buf
, size_t buflen
);
42 const char *GetUserName(void);
43 const char *GetNameOfHost(void);
44 int Min(int i1
, int i2
);
45 const char* GetRCFileName(int type
);
48 ** Simple stack implementation which only keeps void pointers.
49 ** The stack must already be allocated and initialised:
51 ** Stack* stack = (Stack*) XtMalloc(sizeof(Stack));
55 ** NULL is not allowed to pass in, as it is used to signal an empty stack.
57 ** The user should only ever care about Stack, stackObject is an internal
58 ** object. (So it should really go in utils.c. A forward reference was
59 ** refused by my compiler for some reason though.)
61 typedef struct _stackObject
{
63 struct _stackObject
* next
;
71 void Push(Stack
* stack
, const void* value
);
72 void* Pop(Stack
* stack
);
74 /* N_FILE_TYPES must be the last entry!! This saves us from counting. */
75 enum {NEDIT_RC
, AUTOLOAD_NM
, NEDIT_HISTORY
, N_FILE_TYPES
};
77 /* If anyone knows where to get this from system include files (in a machine
78 independent way), please change this (L_cuserid is apparently not ANSI) */
79 #define MAXUSERNAMELEN 32
81 /* Ditto for the maximum length for a node name. SYS_NMLN is not available
82 on most systems, and I don't know what the portable alternative is. */
84 #define MAXNODENAMELEN SYS_NMLN
86 #define MAXNODENAMELEN (MAXPATHLEN+2)
89 #endif /* NEDIT_UTILS_H_INCLUDED */