File: util.h

package info (click to toggle)
mpsql 2.1-2
  • links: PTS
  • area: non-free
  • in suites: potato
  • size: 3,528 kB
  • ctags: 4,886
  • sloc: ansic: 35,184; makefile: 3,761; sh: 44
file content (162 lines) | stat: -rw-r--r-- 6,083 bytes parent folder | download | duplicates (2)
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*  -*- c -*-  */
/* -------------------------------------------------------------------- *
**  copyright (c) 1995 ipvr stuttgart and thomas harrer
** -------------------------------------------------------------------- *
**
**  libhelp
**
**  a comprehensive hypertext help system for OSF/Motif(tm) applications. 
**  based on libhtmlw from NCSA Mosaic(tm) version 2.4
**
**  written by thomas harrer
**  e-mail: Thomas.Harrer@rus.uni-stuttgart.de
**  
** -------------------------------------------------------------------- *
*h  $Id: util.h,v 1.3 1995/06/28 12:59:30 thomas Exp $
** -------------------------------------------------------------------- *
**
*h  module:		util.h
**
**  contents:		header file for utilities
**
**  interface:		#include "util.h"
**
** -------------------------------------------------------------------- *
**  license and copying issues:
**
**  this software is free; you can redistribute it and/or modify it 
**  under terms similar to the gnu general public license (version 1 
**  or any later version published by the free software foundation). 
**  see the file Licence for more details.
**
**  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.  
** -------------------------------------------------------------------- */
#ifndef _UTIL_H_
#define _UTIL_H_ 1

/* -------------------------------------------------------------------- *
*g  prototypes
** -------------------------------------------------------------------- */
/* -------------------------------------------------------------------- *
*g  file types
** -------------------------------------------------------------------- */
#define file_html  	1
#define file_plain	2
#define file_special 	4
#define file_dir   	8
#define file_gif   	16
#define file_executable	32
#define file_no_access 	64

#define file_regular (file_html | file_plain)

/* -------------------------------------------------------------------- *
*g  prototypes
** -------------------------------------------------------------------- */
/* -------------------------------------------------------------------- *
*p  procedure-name:	get_file
**
**  purpose:		extracts file (plus opt. path) from url.
**			strips of prefix and anchor.
** -------------------------------------------------------------------- *
**  args:		filename and opt. anchor in a '\0' terminated
**			string.  format: "[file:]<file>[#<anchor>]".
**  return type:	char* (allocated). caller is responsible for
**			freeing the returned memory (if != NULL).
** -------------------------------------------------------------------- */
char*
get_file (/* i  */ char* url);

/* -------------------------------------------------------------------- *
*p  procedure-name:	get_anchor
**
**  purpose:		returns the anchor from the given url or an
**			empty string if there was no anchor.
** -------------------------------------------------------------------- *
**  args:		filename + opt anchor.
**  returns:		the anchor or "" (\0 terminated).
**			the application must not free the returned ptr.
** -------------------------------------------------------------------- */
char*
get_anchor (/* i  */ char* url);

/* -------------------------------------------------------------------- *
*p  procedure-name:	convert_newlines_to_spaces
**
**  purpose:		removes leading whitespace and converts all
**			newlines with spaces.
**  and:		shows we can fluently deal with pointers :-)
** -------------------------------------------------------------------- *
**  args:		string str
**  return type:	char*
**  precondition:	\0 terminated string must be passed.
**  postcondition:	see purpose. side effect is, that non blank part
**			of str is copied to the beginning of string.
**  error handling.:	assumes \0 at the end of string.
** -------------------------------------------------------------------- */
char*
convert_newlines_to_spaces (/* io */ char*	str);

/* -------------------------------------------------------------------- *
*p  procedure-name:	get_file_and_strip_path
**
**  purpose:		strips the path component from a filename.
** -------------------------------------------------------------------- *
**  return-value:	returns a newly allocated string filename.
**			or null if ref does not contain a filename 
**			or ref is a directory.
**			the caller is responsible to free the returned 
**			string.
** -------------------------------------------------------------------- */
char*
get_file_and_strip_path (/* i  */ char* url);

/* -------------------------------------------------------------------- *
*p  procedure-name:	get_path
**
**  purpose:		returns the path component of filename
** -------------------------------------------------------------------- *
**  precondition:	file must be accessible (for reading).
**
**  return value:	path component of file in a newly allocated 
**			string or NULL if name of file
** -------------------------------------------------------------------- */
char*
get_path (/* i  */ char* filename);

/* -------------------------------------------------------------------- *
*p  procedure-name:	file_type
**
**  purpose:		returns the type of the file `filename'.
**			
**			possible values are:
**			
**			* file_html
**			* file_dir
**			* file_plain
**			* file_gif
**			* file_executable
**			* file_no_access
**			
**			possible more than one attributes belong to a file
**			the caller can test if attribute is true by
**			using the & (and) operator. e.g. 
**			
**			xxx = file_type ("?");
**			if (xxx & file_dir) printf ("? is a dir\n");
** -------------------------------------------------------------------- */
int
file_type (/* i  */ char* filename);

#endif /* !_UTIL_H_ */
/* -------------------------------------------------------------------- *
*l  emacs:
**  local variables:
**  mode:		c
**  outline-regexp:	"\*[HGPLT]"
**  comment-column:	32
**  eval:		(outline-minor-mode t)
**  end:
** -------------------------------------------------------------------- */