2003-06-30 16:44:03 +04:00
|
|
|
/*
|
2007-01-30 01:27:15 +03:00
|
|
|
* Copyright 2004-2007 James Bursa <bursa@users.sourceforge.net>
|
2008-08-05 05:30:31 +04:00
|
|
|
* Copyright 2004 John Tytgat <joty@netsurf-browser.org>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf 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; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
2002-04-22 13:24:35 +04:00
|
|
|
*/
|
|
|
|
|
2003-02-09 15:58:15 +03:00
|
|
|
#ifndef _NETSURF_UTILS_UTILS_H_
|
|
|
|
#define _NETSURF_UTILS_UTILS_H_
|
2002-08-12 03:04:02 +04:00
|
|
|
|
2003-11-08 02:47:55 +03:00
|
|
|
#include <stdbool.h>
|
2004-07-06 00:19:52 +04:00
|
|
|
#include <stddef.h>
|
2002-08-12 03:04:02 +04:00
|
|
|
#include <stdlib.h>
|
2003-12-27 23:15:23 +03:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <regex.h>
|
2008-05-25 19:04:22 +04:00
|
|
|
#include <assert.h>
|
2002-08-12 03:04:02 +04:00
|
|
|
|
2005-04-15 09:52:04 +04:00
|
|
|
#ifndef NOF_ELEMENTS
|
|
|
|
#define NOF_ELEMENTS(array) (sizeof(array)/sizeof(*(array)))
|
|
|
|
#endif
|
2005-04-22 01:36:23 +04:00
|
|
|
#ifndef ABS
|
|
|
|
#define ABS(x) (((x)>0)?(x):(-(x)))
|
|
|
|
#endif
|
|
|
|
#ifndef min
|
|
|
|
#define min(x,y) (((x)<(y))?(x):(y))
|
|
|
|
#endif
|
|
|
|
#ifndef max
|
|
|
|
#define max(x,y) (((x)>(y))?(x):(y))
|
|
|
|
#endif
|
2008-08-13 21:37:59 +04:00
|
|
|
#ifndef PRIxPTR
|
|
|
|
#define PRIxPTR "x"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__HAIKU__) || defined(__BEOS__)
|
|
|
|
#define strtof(s,p) ((float)(strtod((s),(p))))
|
|
|
|
#endif
|
2005-04-15 09:52:04 +04:00
|
|
|
|
2008-05-25 19:51:30 +04:00
|
|
|
/**
|
|
|
|
* Calculate length of constant C string.
|
|
|
|
*
|
|
|
|
* \param x a constant C string.
|
|
|
|
* \return the length of C string without its terminating NUL accounted.
|
|
|
|
*/
|
|
|
|
#define SLEN(x) (sizeof((x)) - 1)
|
|
|
|
|
2005-04-23 06:58:27 +04:00
|
|
|
enum query_response {
|
|
|
|
QUERY_CONTINUE,
|
|
|
|
QUERY_YES,
|
|
|
|
QUERY_NO,
|
|
|
|
QUERY_ESCAPE
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef int query_id;
|
|
|
|
|
|
|
|
#define QUERY_INVALID ((query_id)-1)
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
void (*confirm)(query_id id, enum query_response res, void *pw);
|
|
|
|
void (*cancel)(query_id, enum query_response res, void *pw);
|
|
|
|
} query_callback;
|
|
|
|
|
2010-01-31 03:36:02 +03:00
|
|
|
#ifdef HAVE_MKDIR
|
|
|
|
#define nsmkdir(dir, mode) mkdir((dir), (mode))
|
|
|
|
#else
|
|
|
|
#define nsmkdir(dir, mode) mkdir((dir))
|
|
|
|
#endif
|
2005-04-23 06:58:27 +04:00
|
|
|
|
2002-04-22 13:24:35 +04:00
|
|
|
char * strip(char * const s);
|
|
|
|
int whitespace(const char * str);
|
2002-05-22 01:27:29 +04:00
|
|
|
char * squash_whitespace(const char * s);
|
2009-12-18 02:55:02 +03:00
|
|
|
char *remove_underscores(const char *s, bool replacespace);
|
2004-07-06 00:19:52 +04:00
|
|
|
char *cnv_space2nbsp(const char *s);
|
2003-11-08 02:47:55 +03:00
|
|
|
bool is_dir(const char *path);
|
2003-12-27 23:15:23 +03:00
|
|
|
void regcomp_wrapper(regex_t *preg, const char *regex, int cflags);
|
2003-12-29 03:38:59 +03:00
|
|
|
void unicode_transliterate(unsigned int c, char **r);
|
2004-04-25 15:40:05 +04:00
|
|
|
char *human_friendly_bytesize(unsigned long bytesize);
|
2006-02-06 03:10:09 +03:00
|
|
|
const char *rfc1123_date(time_t t);
|
2007-01-30 18:32:31 +03:00
|
|
|
unsigned int wallclock(void);
|
2005-04-16 09:09:33 +04:00
|
|
|
|
2008-05-25 19:04:22 +04:00
|
|
|
/**
|
|
|
|
* Return a hex digit for the given numerical value.
|
|
|
|
*
|
|
|
|
* \return character in range 0-9a-f
|
|
|
|
*/
|
|
|
|
inline static char digit2lowcase_hex(unsigned char digit) {
|
|
|
|
assert(digit < 16);
|
|
|
|
return "0123456789abcdef"[digit];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-16 09:09:33 +04:00
|
|
|
/* Platform specific functions */
|
|
|
|
void die(const char * const error);
|
2004-06-11 00:41:26 +04:00
|
|
|
void warn_user(const char *warning, const char *detail);
|
2006-02-07 19:16:23 +03:00
|
|
|
query_id query_user(const char *query, const char *detail,
|
|
|
|
const query_callback *cb, void *pw, const char *yes, const char *no);
|
2005-04-23 06:58:27 +04:00
|
|
|
void query_close(query_id);
|
Second merge of Adam Blokus' GSoC work from his branch 'branches/adamblokus/netsurf'.
Merged revisions 4195-4211,4216,4219-4220,4222-4234,4236-4250,4252-4262,4264-4266,4268-4326,4329-4335,4338-4342,4344-4411,4413-4420,4422-4436,4438-4491,4494-4506,4508-4514,4516,4518-4552,4554,4556-4564,4567-4568,4570-4574,4576-4686,4689-4692,4694,4698-4709,4715-4723,4725-4755,4757-4769,4771-4919,4921-4996,4998-5110,5112-5117 via svnmerge from
svn://svn.netsurf-browser.org/branches/adamblokus/netsurf
........
r4736 | adamblokus | 2008-07-26 13:46:54 +0200 (Sat, 26 Jul 2008) | 2 lines
Sorting out some problems with svn.
........
r4737 | adamblokus | 2008-07-26 13:54:36 +0200 (Sat, 26 Jul 2008) | 4 lines
Added export tab to the options dialog.
Added the possibility of changing some print options.
........
r4897 | adamblokus | 2008-08-04 17:59:05 +0200 (Mon, 04 Aug 2008) | 5 lines
Added checking of horizontal clipping.
Added better table loosening.
Changed some minor bugs.
Applied changes in the Export options tab according to the review from tlsa.
........
r4905 | adamblokus | 2008-08-05 01:53:34 +0200 (Tue, 05 Aug 2008) | 2 lines
Fixed bug which made it impossible to export pdf's.
........
r4919 | adamblokus | 2008-08-05 16:39:33 +0200 (Tue, 05 Aug 2008) | 2 lines
Fixed some memory leaks which caused Netsurf to break.
........
r4927 | adamblokus | 2008-08-06 02:26:30 +0200 (Wed, 06 Aug 2008) | 4 lines
Fixed bug with filenames which crashed Netsurf.
Turned anti aliasing off for printing.
Fixed some scaling issues.
........
r4928 | adamblokus | 2008-08-06 17:52:44 +0200 (Wed, 06 Aug 2008) | 5 lines
Added new export/print options:
- suppressing images
- turning off backgrounds
- toggled loosening
........
r4950 | adamblokus | 2008-08-07 21:15:21 +0200 (Thu, 07 Aug 2008) | 5 lines
Added new options to PDF export:
- document compression
- document encryption
Added PDF password dialog
........
r4954 | adamblokus | 2008-08-07 22:11:31 +0200 (Thu, 07 Aug 2008) | 2 lines
Added saving print settings.
........
r4956 | adamblokus | 2008-08-07 22:44:48 +0200 (Thu, 07 Aug 2008) | 2 lines
Fixes to PDF encryption
........
r4970 | adamblokus | 2008-08-09 15:26:24 +0200 (Sat, 09 Aug 2008) | 3 lines
Fixed bug in plotting tiled bitmaps.
Fixed bug with too long text decorations.
........
r4977 | adamblokus | 2008-08-09 19:18:56 +0200 (Sat, 09 Aug 2008) | 2 lines
Fixed JPG embedding bug.
........
r4988 | adamblokus | 2008-08-10 16:59:51 +0200 (Sun, 10 Aug 2008) | 3 lines
Added clip checking to pdf plotters. No more "blank" clips.
Made PDF compression a default setting.
........
r4995 | adamblokus | 2008-08-10 20:03:00 +0200 (Sun, 10 Aug 2008) | 2 lines
Fixed Haru crash on font-size==0.
........
r4996 | adamblokus | 2008-08-10 21:04:43 +0200 (Sun, 10 Aug 2008) | 2 lines
Added changing text mode only if necessary.
........
r5045 | adamblokus | 2008-08-11 21:26:26 +0200 (Mon, 11 Aug 2008) | 3 lines
Removing gtk stuff from core code.
Little fix in options.
........
r5048 | adamblokus | 2008-08-11 21:57:45 +0200 (Mon, 11 Aug 2008) | 2 lines
Better font size checking in PDF export.
........
r5050 | adamblokus | 2008-08-11 22:19:56 +0200 (Mon, 11 Aug 2008) | 2 lines
Fixed riscos text scale bug.
........
r5073 | adamblokus | 2008-08-12 17:40:57 +0200 (Tue, 12 Aug 2008) | 2 lines
Added missing tooltips
........
r5092 | adamblokus | 2008-08-13 17:09:25 +0200 (Wed, 13 Aug 2008) | 2 lines
Moved /pdf folder to desktop/save_pdf
........
r5110 | adamblokus | 2008-08-13 22:44:50 +0200 (Wed, 13 Aug 2008) | 2 lines
Added comments.
........
r5113 | adamblokus | 2008-08-13 23:07:35 +0200 (Wed, 13 Aug 2008) | 2 lines
Cosmetic changes
........
r5116 | adamblokus | 2008-08-14 16:10:18 +0200 (Thu, 14 Aug 2008) | 2 lines
Fixed bug with BOX_INLINE_END in tree duplication.
........
r5117 | joty | 2008-08-14 21:47:46 +0200 (Thu, 14 Aug 2008) | 1 line
Improvement for r5116: use local vars when possible; rename global last to box_duplicate_last; check on box_duplicate_main_tree failure.
........
svn path=/trunk/netsurf/; revision=5118
2008-08-15 00:32:10 +04:00
|
|
|
void PDF_Password(char **owner_pass, char **user_pass, char *path);
|
2010-03-21 16:32:59 +03:00
|
|
|
char *filename_from_path(char *path);
|
2002-08-12 03:04:02 +04:00
|
|
|
#endif
|