1 /* $Id: utils.h,v 1.18 2009/09/19 09:17:59 edg 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>
32 #include <sys/types.h>
37 #include <sys/param.h>
40 const char *GetCurrentDir(void);
41 const char *GetHomeDir(void);
42 char *PrependHome(const char *filename
, char *buf
, size_t buflen
);
43 const char *GetUserName(void);
44 const char *GetNameOfHost(void);
45 int Min(int i1
, int i2
);
46 const char* GetRCFileName(int type
);
49 ** Simple stack implementation which only keeps void pointers.
50 ** The stack must already be allocated and initialised:
52 ** Stack* stack = (Stack*) XtMalloc(sizeof(Stack));
56 ** NULL is not allowed to pass in, as it is used to signal an empty stack.
58 ** The user should only ever care about Stack, stackObject is an internal
59 ** object. (So it should really go in utils.c. A forward reference was
60 ** refused by my compiler for some reason though.)
62 typedef struct _stackObject
{
64 struct _stackObject
* next
;
72 void Push(Stack
* stack
, const void* value
);
73 void* Pop(Stack
* stack
);
75 /* N_FILE_TYPES must be the last entry!! This saves us from counting. */
76 enum {NEDIT_RC
, AUTOLOAD_NM
, NEDIT_HISTORY
, N_FILE_TYPES
};
78 /* If anyone knows where to get this from system include files (in a machine
79 independent way), please change this (L_cuserid is apparently not ANSI) */
80 #define MAXUSERNAMELEN 32
82 /* Ditto for the maximum length for a node name. SYS_NMLN is not available
83 on most systems, and I don't know what the portable alternative is. */
85 #define MAXNODENAMELEN SYS_NMLN
87 #define MAXNODENAMELEN (MAXPATHLEN+2)
90 #endif /* NEDIT_UTILS_H_INCLUDED */