1%%	options
2
3copyright owner	=	Dirk Krause
4copyright year	=	2015-xxxx
5SPDX-License-Identifier:	BSD-3-Clause
6
7%%	header
8
9/**	@file	dk4strx.h	String functions for wxChar.
10*/
11
12#ifndef DK4CONF_H_INCLUDED
13#if DK4_BUILDING_DKTOOLS4
14#include "dk4conf.h"
15#else
16#include <dktools-4/dk4conf.h>
17#endif
18#endif
19
20#ifndef DK4TYPES_H_INCLUDED
21#if DK4_BUILDING_DKTOOLS4
22#include <libdk4base/dk4types.h>
23#else
24#include <dktools-4/dk4types.h>
25#endif
26#endif
27
28#ifndef DK4CONST_H_INCLUDED
29#if DK4_BUILDING_DKTOOLS4
30#include <libdk4base/dk4const.h>
31#else
32#include <dktools-4/dk4const.h>
33#endif
34#endif
35
36#ifndef DK4ERROR_H_INCLUDED
37#if DK4_BUILDING_DKTOOLS4
38#include <libdk4base/dk4error.h>
39#else
40#include <dktools-4/dk4error.h>
41#endif
42#endif
43
44#ifndef DK4WXCS_H_INCLUDED
45#if DK4_BUILDING_DKTOOLS4
46#include "dk4wxcs.h"
47#else
48#include <dktools-4/dk4wxcs.h>
49#endif
50#endif
51
52
53#ifndef	WX_WXPREC_H_INCLUDED
54#include <wx/wxprec.h>
55#define	WX_WXPREC_H_INCLUDED 1
56#endif
57#ifdef __BORLANDC__
58#pragma hdrstop
59#endif
60#ifndef WX_PRECOMP
61#if	DK4_HAVE_WX_CHARTYPE_H
62#ifndef	WX_CHARTYPE_H_INCLUDED
63#include <wx/chartype.h>
64#define	WX_CHARTYPE_H_INCLUDED 1
65#endif
66#else
67#if	DK4_HAVE_WX_WXCHAR_H
68#ifndef	WX_WXCHAR_H_INCLUDED
69#include <wx/wxchar.h>
70#define	WX_WXCHAR_H_INCLUDED 1
71#endif
72#else
73#ifndef	WX_WX_H_INCLUDED
74#include <wx/wx.h>
75#define	WX_WX_H_INCLUDED
76#endif
77#endif
78#endif
79#endif
80
81
82
83#if DK4_ON_WINDOWS || DK4_HAVE_BACKSLASH
84/**	File name separator.
85*/
86#define	DK4_WX_CHAR_SEP	wxT('\\')
87#else
88/**	File name separator.
89*/
90#define DK4_WX_CHAR_SEP wxT('/')
91#endif
92
93
94
95#ifdef __cplusplus
96extern "C" {
97#endif
98
99/**	Copy string, check destination buffer size.
100	@param	dst	Destination buffer address.
101	@param	sz	Destination buffer size.
102	@param	src	Source string.
103	@param	erp	Error report, may be NULL.
104	@return	1 on success, 0 on error.
105
106	Error codes:
107	- DK4_E_INVALID_ARGUMENTS<br>
108	  if dst or src is NULL or sz is 0,
109	- DK4_E_BUFFER_TOO_SMALL<br>
110	  if the dst buffer is too small.
111*/
112int
113dk4strx_cpy_s(wxChar *dst, size_t sz, const wxChar *src, dk4_er_t *erp);
114
115/**	Concatenate strings, check destination buffer size.
116	@param	dst	Destination buffer address.
117	@param	sz	Destination buffer size.
118	@param	src	Source string.
119	@param	erp	Error report, may be NULL.
120	@return	1 on success, 0 on error.
121
122	Error codes:
123	- DK4_E_INVALID_ARGUMENTS<br>
124	  if dst or src is NULL or sz is 0,
125	- DK4_E_MATH_OVERFLOW<br>
126	  if a mathematical overflow occured in size calculation,
127	- DK4_E_BUFFER_TOO_SMALL<br>
128	  if the concatenated string doest not fit into the buffer.
129*/
130int
131dk4strx_cat_s(wxChar *dst, size_t sz, const wxChar *src, dk4_er_t *erp);
132
133/**	Copy characters within a string from right to left.
134	This copy operation is intended for moving characters within
135	one string from right to left, making the string shorter
136	as is. This function does not check buffer size or report
137	any error.
138	For normal string copy operations, use the dk4strx_cpy_s()
139	function instead.
140	@param	dst	Destination buffer address.
141	@param	src	Source string.
142*/
143void
144dk4strx_cpy_to_left(wxChar *dst, const wxChar *src);
145
146/**	Find string length.
147	@param	src	Source string.
148	@return	String length.
149*/
150size_t
151dk4strx_len(const wxChar *src);
152
153/**	Compare two strings.
154	@param	s1	Left string, may be NULL.
155	@param	s2	Right string, may be NULL.
156	@return	1 if s1>s2, 0 if s1==s2, -1 if s1<s2.
157*/
158int
159dk4strx_cmp(const wxChar *s1, const wxChar *s2);
160
161/**	Compare two strings, case-insensitive comparison.
162	@param	s1	Left string, may be NULL.
163	@param	s2	Right string, may be NULL.
164	@return	1 if s1>s2, 0 if s1==s2, -1 if s1<s2.
165*/
166int
167dk4strx_casecmp(const wxChar *s1, const wxChar *s2);
168
169/**	Compare two file path names.
170	@param	s1	Left string, may be NULL.
171	@param	s2	Right string, may be NULL.
172	@return	1 if s1>s2, 0 if s1==s2, -1 if s1<s2.
173*/
174int
175dk4strx_pathcmp(const wxChar *s1, const wxChar *s2);
176
177/**	Find first occurance of character c in string s.
178	@param	s	String to search for c.
179	@param	c	Character to find.
180	@return	Pointer to first occurance if found, NULL otherwise.
181*/
182wxChar *
183dk4strx_chr(const wxChar *s, wxChar c);
184
185/**	Find last occurance of character c in string s.
186	@param	s	String to search for c.
187	@param	c	Character to find.
188	@return	Pointer to last occurance if found, NULL otherwise.
189*/
190wxChar *
191dk4strx_rchr(const wxChar *s, wxChar c);
192
193/**	Retrieve first token from *stringp.
194	@param	stringp	Adress of string pointer.
195	@param	delim	String containing the delimiter set,
196			my be NULL to use the default delimiter
197			set (space, tabulator, carriage return and newline).
198	@return	Pointer to first token on success, NULL if no (further)
199	token found.
200*/
201wxChar *
202dk4strx_sep(wxChar **stringp, const wxChar *delim);
203
204/**	Find first token in string.
205	@param	src	String to search for tokens.
206	@param	delim	String containing the delimiter characters,
207			may be NULL to use the default delimiter set.
208	@return	Pointer to first token if found, NULL otherwise.
209*/
210wxChar *
211dk4strx_start(const wxChar *src, const wxChar *delim);
212
213/**	Cut string after first token, find start of second token in string.
214	@param	src	String to search for tokens,
215			normally the result of dk4strx_start() or a
216			previous dk4strx_next() call.
217	@param	delim	String containing the delimiter characters,
218			may be NULL to use the default delimiter set.
219	@return	Pointer to second token if found, NULL otherwise.
220*/
221wxChar *
222dk4strx_next(wxChar *src, const wxChar *delim);
223
224/**	Split a string into tokens.
225	@param	dpp	Pointer to string pointer array.
226	@param	szdpp	Size of destination string pointer array.
227	@param	src	Source string to process.
228	@param	delim	String containing delimiter characters,
229			may be NULL to use the default delimiter set.
230	@param	erp	Error report, may be NULL.
231	@return	Number of tokens found on success, 0 if no token
232	found or on error.
233
234	Error codes:
235	- DK4_E_INVALID_ARGUMENTS<br>
236	  for invalid function arguments,
237	- DK4_E_BUFFER_TOO_SMALL<br>
238	  with dt.mem.nelem set to the number of tokens in string if the dpp
239	  array is too short.
240*/
241size_t
242dk4strx_tokenize(
243  wxChar **dpp, size_t szdpp, wxChar *src, const wxChar *delim, dk4_er_t *erp
244);
245
246/**	Normalize a string (remove leading and trailing delimiters,
247	replace delimiter sequences by just one delimiter).
248	@param	src	Buffer containing the string to normalize.
249	@param	delim	String containing delimiter characters,
250			may be NULL to use the default delimiter set.
251*/
252void
253dk4strx_normalize(wxChar *src, const wxChar *delim);
254
255/**	Find index of a string in an array of strings.
256	@param	arr	Array of strings.
257	@param	str	String to find in array.
258	@param	cs	Flag: Case-sensitive search (0=no, other=yes).
259	@return	Non-negative index value on success, -1 on error.
260*/
261int
262dk4strx_array_index(const wxChar * const *arr, const wxChar *str, int cs);
263
264/**	Find index of a string in an array of strings.
265	@param	arr	Array of strings allowing abbreviation.
266	@param	spec	Special character indicating start of optional text.
267	@param	str	String to find in array.
268	@param	cs	Flag: Case-sensitive search (0=no, other=yes).
269	@return	Non-negative index value on success, -1 on error.
270*/
271int
272dk4strx_abbr_index(
273  const wxChar * const	*arr,
274  wxChar		 spec,
275  const wxChar		*str,
276  int cs
277);
278
279/**	Check whether a text matches a pattern, the text may be abbreviated.
280 	@param	str	Text to check.
281 	@param	pattern	Pattern for comparison.
282 	@param	spec	Special character marking the abbreviation in the
283	pattern.
284 	@param	cs	Flag: Case sensitive (1) or not (0).
285 	@return	1 for a match, 0 otherwise.
286*/
287int
288dk4strx_is_abbr(const wxChar *str, const wxChar *pattern, wxChar spec, int cs);
289
290/**	Check whether a string represents a boolean value.
291	@param	str	String to check.
292	@return	1 if str represents a boolean value, 0 otherwise.
293*/
294int
295dk4strx_is_bool(const wxChar *str);
296
297/**	Check whether a string represents the boolean value TRUE.
298	@param	str	String to check.
299	@return	1 if str represents the boolean value TRUE, 0 otherwise.
300*/
301int
302dk4strx_is_on(const wxChar *str);
303
304#if (defined(_WIN32) && DK4_USE_WINDOWS_LOCAL_ALLOC) \
305    || (DK4_HAVE_MALLOC && DK4_HAVE_FREE)
306
307/**	Duplicate string in dynamically allocated memory.
308	@param	src	String to duplicate.
309	@param	erp	Error report, may be NULL.
310	@return	Pointer to string in new memory on succes, NULL on error.
311	Use dk4mem_free() to release the memory after usage.
312
313	Error codes:
314	- DK4_E_INVALID_ARGUMENTS<br>
315	  if src is a NULL pointer,
316	- DK4_E_MATH_OVERFLOW<br>
317	  on mathematical overflow in size calculation,
318	- DK4_E_MEMORY<br>
319	  if no memory is available.
320*/
321wxChar *
322dk4strx_dup(const wxChar *src, dk4_er_t *erp);
323
324#endif
325/* if (defined(_WIN32) ... */
326
327/**	Remove trailing white spaces.
328	@param	str	String to remove white spaces from.
329	@param	whsp	White spaces set.
330*/
331void
332dk4strx_rtwh(wxChar *str, const wxChar *whsp);
333
334/**	Remove trailing newline from line.
335	@param	lptr	Line pointer.
336*/
337void
338dk4strx_delnl(wxChar *lptr);
339
340/**	Find file name suffix.
341	@param	filename	File name to find suffix from.
342	@param	erp		Error report, may be NULL.
343	@return	Valid pointer on success, NULL on error.
344*/
345wxChar const *
346dk4strx_get_path_suffix(wxChar const *filename, dk4_er_t *erp);
347
348/**	Check whether a file name is an absolute path.
349	CRT on Windows: Not used.
350	@param	path	Path name to check.
351	@return	1 for absolute path, 0 for other path.
352*/
353int
354dk4strx_path_is_absolute(const wxChar *path);
355
356/**	Check whether a file name is a relative path.
357	CRT on Windows: Not used.
358	@param	path	Path name to check.
359	@return	1 for absolute path, 0 for other path.
360*/
361int
362dk4strx_path_is_relative(const wxChar *path);
363
364/**	Append path filename to path name already stored in buffer.
365	Resolve . and .. for current directory and parent directory.
366	CRT on Windows: Optional, disabling CRT degrades performance.
367	@param	buffer		Buffer already containing a path.
368	@param	sz		Buffer size.
369	@param	filename	Relative file name to append to buffer.
370	@param	erp		Error report, may be NULL.
371	@return	1 on success, 0 on error.
372
373	Error codes:
374	- DK4_E_INVALID_ARGUMENTS<br>
375	  if buffer or filename is NULL or sz is 0,
376	- DK4_E_MATH_OVERFLOW<br>
377	  if filename is too long,
378	- DK4_E_MEMORY<br>
379	  if allocation of a filename copy fails,
380	- DK4_E_SYNTAX<br>
381	  if too many .. in filename,
382	- DK4_E_BUFFER_TOO_SMALL<br>
383	  if buffer size is too small.
384*/
385int
386dk4strx_path_append(
387  wxChar *buffer, size_t sz, const wxChar *filename, dk4_er_t *erp
388);
389
390
391/**	Find pointer to suffix.
392	CRT on Windows: Not used.
393	@param	filename	File name to find suffix for.
394	@param	erp		Error report, may be NULL.
395	@return	Pointer to suffix dot if found, NULL otherwise.
396
397	Error codes:
398	- DK4_E_INVALID_ARGUMENTS<br>
399	  if filename is NULL,
400	- DK4_E_NOT_FOUND<br>
401	  if the file name does not contain a suffix.
402*/
403wxChar *
404dk4strx_path_get_suffix(const wxChar *filename, dk4_er_t *erp);
405
406
407/**	Correct file name separators from slash to backslash on Windows,
408	vice versa on other systems.
409	CRT on Windows: Not used.
410	@param	filename	File name to correct.
411*/
412void
413dk4strx_path_correct_sep(wxChar *filename);
414
415/**	Check whether file name needs expansion on Windows.
416	CRT on Windows: Not used.
417	@param	filename	File name to check.
418	@return	1 if expansion is necessary, 0 otherwise.
419*/
420int
421dk4strx_path_must_expand(const wxChar *filename);
422
423/**	Create file name with specified suffix.
424	@param	pdst	Destination buffer.
425	@param	szdst	Size of pdst (number of wxChar).
426	@param	srcname	Source file name.
427	@param	newsu	New file suffix.
428	@param	erp	Error report, may be NULL.
429	@return	1 on success, 0 on error.
430
431	Error codes:
432	- DK4_E_INVALID_ARGUMENTS<br>
433	  if pdst or srcname or newsu is NULL or szdst is 0,
434	- DK4_E_BUFFER_TOO_SMALL<br>
435	  if the dst buffer is too small.
436	- DK4_E_MATH_OVERFLOW<br>
437	  if a mathematical overflow occured in size calculation,
438*/
439int
440dk4strx_path_set_suffix(
441  wxChar	*pdst,
442  size_t	 szdst,
443  wxChar const	*srcname,
444  wxChar const	*newsu,
445  dk4_er_t	*erp
446);
447
448/**	Create a dynamic copy of a file name with changed suffix.
449	@param	srcname	Old file name.
450	@param	newsu	New suffix.
451	@param	erp	Error report, may be NULL.
452	@return	Valid pointer to changed file name on success, NULL on error.
453	On success call dk4mem_free() on the pointer when no longer needed
454	to release the memory.
455
456	Error codes:
457	- DK4_E_INVALID_ARGUMENTS<br>
458	  if srcname or newsu is NULL,
459	- DK4_E_BUG<br>
460	  if a bug occured,
461	- DK4_E_MATH_OVERFLOW<br>
462	  if a mathematical overflow occured in size calculation,
463	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
464	  with mem.elsize and mem.nelem set if there is not enough memory
465	  available.
466*/
467wxChar *
468dk4strx_path_dup_change_suffix(
469  wxChar const	*srcname,
470  wxChar const	*newsu,
471  dk4_er_t	*erp
472);
473
474/**	Calculate buffer size required to concatenate a directory
475	name and a file name.
476	@param	dirname		Directory name.
477	@param	filename	File name.
478	@param	erp		Error report, may be NULL.
479	@return	Buffer size for concatenated names including the finalizer
480	byte on success, 0 on error.
481
482	Error codes:
483	- DK4_E_INVALID_ARGUMENTS<br>
484	  if dirname or filename is NULL,
485	- DK4_E_MATH_OVERFLOW<br>
486	  if the calculation results in a numeric overflow.
487*/
488size_t
489dk4strx_path_concatenate_size(
490  wxChar const	*dirname,
491  wxChar const	*filename,
492  dk4_er_t	*erp
493);
494
495/**	Concatenate a directory name and a file name into an existing buffer.
496	This function simply concatenates directory name and file name,
497	. and .. for current and parent directory are not resolved.
498	@param	buffer	Result buffer for combined file name.
499	@param	szbuf	Buffer size (number of wxChar).
500	@param	dirn	Directory name.
501	@param	filen	File name.
502	@param	erp	Error report, may be NULL.
503	@return	1 on success, 0 on error.
504
505	Error codes:
506	- DK4_E_INVALID_ARGUMENTS<br>
507	  if buffer, dirn or filen is NULL or szbuf is 0,
508	- DK4_E_BUFFER_TOO_SMALL<br>
509	  if the buffer is too small.
510*/
511int
512dk4strx_path_concatenate_buffer(
513  wxChar	*buffer,
514  size_t	 szbuf,
515  wxChar const	*dirn,
516  wxChar const	*filen,
517  dk4_er_t	*erp
518);
519
520/**	Concatenate a directory name and a file name into newly
521	allocated memory.
522	This function simply concatenates directory name and file name,
523	. and .. for current and parent directory are not resolved.
524	@param	dirn	Directory name.
525	@param	filen	File name.
526	@param	erp	Error report, may be NULL.
527	@return	Valid pointer to newly allocated memory containing the
528	concatenation on success, NULL on error.
529	On success use dk4mem_free() to release the memory when done
530	with it.
531
532	Error codes:
533	- DK4_E_INVALID_ARGUMENTS<br>
534	  if dirn or filen is NULL,
535	- DK4_E_MATH_OVERFLOW<br>
536	  if the size calculation results in a numeric overflow.
537	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
538	  if the memory allocation failed,
539	- DK4_E_BUFFER_TOO_SMALL<br>
540	  if the buffer is too small.
541*/
542wxChar *
543dk4strx_path_concatenate_new(
544  wxChar const	*dirn,
545  wxChar const	*filen,
546  dk4_er_t	*erp
547);
548
549
550/**	Check whether a file name is in specified directory.
551	There is no check for the presence of the file, just
552	a name check.
553	@param	filename	File name to check.
554	@param	parent		Directory the file should be in.
555	@param	erp			Error report, may be NULL.
556	@return	Non-zero value if file is in directory, 0 otherwise.
557*/
558int
559dk4strx_path_is_in_subdir(
560	const wxChar	*filename,
561	const wxChar	*parent,
562	dk4_er_t		*erp
563);
564
565#ifdef __cplusplus
566}
567#endif
568
569
570/* vim: set ai sw=4 ts=4 : */
571
572%%	module
573
574#include "dk4conf.h"
575
576#ifndef	DK4_SIZEOF_WXCHAR
577#ifndef	DK4WXCS_H_INCLUDED
578#include "dk4wxcs.h"
579#endif
580#endif
581
582#include <libdk4wx/dk4strx.h>
583#include <libdk4base/dk4mem.h>
584#include <libdk4base/dk4mpl.h>
585
586#if DK4_SIZEOF_WXCHAR > 1
587#include <libdk4base/dk4strw.h>
588#include <libdk4c/dk4pathw.h>
589#else
590#include <libdk4base/dk4str8.h>
591#include <libdk4c/dk4path8.h>
592#endif
593
594
595
596$!trace-include
597
598
599
600int
601dk4strx_cpy_s(wxChar *dst, size_t sz, const wxChar *src, dk4_er_t *erp)
602{
603#if DK4_SIZEOF_WXCHAR > 1
604  return (dk4strw_cpy_s(dst, sz, src, erp));
605#else
606  return (dk4str8_cpy_s(dst, sz, src, erp));
607#endif
608}
609
610
611
612int
613dk4strx_cat_s(wxChar *dst, size_t sz, const wxChar *src, dk4_er_t *erp)
614{
615#if DK4_SIZEOF_WXCHAR > 1
616  return (dk4strw_cat_s(dst, sz, src, erp));
617#else
618  return (dk4str8_cat_s(dst, sz, src, erp));
619#endif
620}
621
622
623
624void
625dk4strx_cpy_to_left(wxChar *dst, const wxChar *src)
626{
627#if DK4_SIZEOF_WXCHAR > 1
628  dk4strw_cpy_to_left(dst, src);
629#else
630  dk4str8_cpy_to_left(dst, src);
631#endif
632}
633
634
635
636size_t
637dk4strx_len(const wxChar *src)
638{
639#if DK4_SIZEOF_WXCHAR > 1
640  return (dk4strw_len(src));
641#else
642  return (dk4str8_len(src));
643#endif
644}
645
646
647
648int
649dk4strx_cmp(const wxChar *s1, const wxChar *s2)
650{
651#if DK4_SIZEOF_WXCHAR > 1
652  return (dk4strw_cmp(s1, s2));
653#else
654  return (dk4str8_cmp(s1, s2));
655#endif
656}
657
658
659
660int
661dk4strx_casecmp(const wxChar *s1, const wxChar *s2)
662{
663#if DK4_SIZEOF_WXCHAR > 1
664  return (dk4strw_casecmp(s1, s2));
665#else
666  return (dk4str8_casecmp(s1, s2));
667#endif
668}
669
670
671
672int
673dk4strx_pathcmp(const wxChar *s1, const wxChar *s2)
674{
675#if DK4_SIZEOF_WXCHAR > 1
676  return (dk4strw_pathcmp(s1, s2));
677#else
678  return (dk4str8_pathcmp(s1, s2));
679#endif
680}
681
682
683
684wxChar *
685dk4strx_chr(const wxChar *s, wxChar c)
686{
687#if DK4_SIZEOF_WXCHAR > 1
688  return (dk4strw_chr(s, c));
689#else
690  return (dk4str8_chr(s, c));
691#endif
692}
693
694
695
696wxChar *
697dk4strx_rchr(const wxChar *s, wxChar c)
698{
699#if DK4_SIZEOF_WXCHAR > 1
700  return (dk4strw_rchr(s, c));
701#else
702  return (dk4str8_rchr(s, c));
703#endif
704}
705
706
707
708wxChar *
709dk4strx_sep(wxChar **stringp, const wxChar *delim)
710{
711#if DK4_SIZEOF_WXCHAR > 1
712  return (dk4strw_sep(stringp, delim));
713#else
714  return (dk4str8_sep(stringp, delim));
715#endif
716}
717
718
719
720wxChar *
721dk4strx_start(const wxChar *src, const wxChar *delim)
722{
723#if DK4_SIZEOF_WXCHAR > 1
724  return (dk4strw_start(src, delim));
725#else
726  return (dk4str8_start(src, delim));
727#endif
728}
729
730
731
732wxChar *
733dk4strx_next(wxChar *src, const wxChar *delim)
734{
735#if DK4_SIZEOF_WXCHAR > 1
736  return (dk4strw_next(src, delim));
737#else
738  return (dk4str8_next(src, delim));
739#endif
740}
741
742
743
744size_t
745dk4strx_tokenize(
746  wxChar **dpp, size_t szdpp, wxChar *src, const wxChar *delim, dk4_er_t *erp
747)
748{
749#if DK4_SIZEOF_WXCHAR > 1
750  return (dk4strw_tokenize(dpp, szdpp, src, delim, erp));
751#else
752  return (dk4str8_tokenize(dpp, szdpp, src, delim, erp));
753#endif
754}
755
756
757
758void
759dk4strx_normalize(wxChar *src, const wxChar *delim)
760{
761#if DK4_SIZEOF_WXCHAR > 1
762  dk4strw_normalize(src, delim);
763#else
764  dk4str8_normalize(src, delim);
765#endif
766}
767
768
769
770int
771dk4strx_array_index(const wxChar * const *arr, const wxChar *str, int cs)
772{
773#if DK4_SIZEOF_WXCHAR > 1
774  return (dk4strw_array_index(arr, str, cs));
775#else
776  return (dk4str8_array_index(arr, str, cs));
777#endif
778}
779
780
781
782int
783dk4strx_abbr_index(
784  const wxChar * const	*arr,
785  wxChar		 spec,
786  const wxChar		*str,
787  int cs
788)
789{
790#if DK4_SIZEOF_WXCHAR > 1
791  return (dk4strw_abbr_index(arr, spec, str, cs));
792#else
793  return (dk4str8_abbr_index(arr, spec, str, cs));
794#endif
795}
796
797
798
799int
800dk4strx_is_abbr(const wxChar *str, const wxChar *pattern, wxChar spec, int cs)
801{
802#if DK4_SIZEOF_WXCHAR > 1
803  return (dk4strw_is_abbr(str, pattern, spec, cs));
804#else
805  return (dk4str8_is_abbr(str, pattern, spec, cs));
806#endif
807}
808
809
810
811int
812dk4strx_is_bool(const wxChar *str)
813{
814#if DK4_SIZEOF_WXCHAR > 1
815  return (dk4strw_is_bool(str));
816#else
817  return (dk4str8_is_bool(str));
818#endif
819}
820
821
822
823int
824dk4strx_is_on(const wxChar *str)
825{
826#if DK4_SIZEOF_WXCHAR > 1
827  return (dk4strw_is_on(str));
828#else
829  return (dk4str8_is_on(str));
830#endif
831}
832
833
834
835#if (defined(_WIN32) && DK4_USE_WINDOWS_LOCAL_ALLOC) \
836    || (DK4_HAVE_MALLOC && DK4_HAVE_FREE)
837
838wxChar *
839dk4strx_dup(const wxChar *src, dk4_er_t *erp)
840{
841#if DK4_SIZEOF_WXCHAR > 1
842  return (dk4strw_dup(src, erp));
843#else
844  return (dk4str8_dup(src, erp));
845#endif
846}
847
848#endif
849/* if (defined(_WIN32) ... */
850
851void
852dk4strx_rtwh(wxChar *str, const wxChar *whsp)
853{
854#if DK4_SIZEOF_WXCHAR > 1
855  dk4strw_rtwh(str, whsp);
856#else
857  dk4str8_rtwh(str, whsp);
858#endif
859}
860
861
862
863void
864dk4strx_delnl(wxChar *lptr)
865{
866#if DK4_SIZEOF_WXCHAR > 1
867  dk4strw_delnl(lptr);
868#else
869  dk4str8_delnl(lptr);
870#endif
871}
872
873
874wxChar const *
875dk4strx_get_path_suffix(wxChar const *filename, dk4_er_t *erp)
876{
877#if DK4_SIZEOF_WXCHAR > 1
878  return (dk4pathw_get_suffix(filename, erp));
879#else
880  return (dk4path8_get_suffix(filename, erp));
881#endif
882}
883
884
885
886int
887dk4strx_path_is_absolute(const wxChar *path)
888{
889#if	DK4_SIZEOF_WXCHAR > 1
890	return (dk4pathw_is_absolute(path));
891#else
892	return (dk4path8_is_absolute(path));
893#endif
894}
895
896
897
898int
899dk4strx_path_is_relative(const wxChar *path)
900{
901#if	DK4_SIZEOF_WXCHAR > 1
902	return (dk4pathw_is_relative(path));
903#else
904	return (dk4path8_is_relative(path));
905#endif
906}
907
908
909
910int
911dk4strx_path_append(
912  wxChar *buffer, size_t sz, const wxChar *filename, dk4_er_t *erp
913)
914{
915#if	DK4_SIZEOF_WXCHAR > 1
916	return (dk4pathw_append(buffer, sz, filename, erp));
917#else
918	return (dk4path8_append(buffer, sz, filename, erp));
919#endif
920}
921
922
923
924wxChar *
925dk4strx_path_get_suffix(const wxChar *filename, dk4_er_t *erp)
926{
927#if	DK4_SIZEOF_WXCHAR > 1
928	return (dk4pathw_get_suffix(filename, erp));
929#else
930	return (dk4path8_get_suffix(filename, erp));
931#endif
932}
933
934
935
936void
937dk4strx_path_correct_sep(wxChar *filename)
938{
939#if	DK4_SIZEOF_WXCHAR > 1
940	dk4pathw_correct_sep(filename);
941#else
942	dk4path8_correct_sep(filename);
943#endif
944}
945
946
947
948int
949dk4strx_path_must_expand(const wxChar *filename)
950{
951#if	DK4_SIZEOF_WXCHAR > 1
952	return (dk4pathw_must_expand(filename));
953#else
954	return (dk4path8_must_expand(filename));
955#endif
956}
957
958
959
960int
961dk4strx_path_set_suffix(
962  wxChar	*pdst,
963  size_t	 szdst,
964  wxChar const	*srcname,
965  wxChar const	*newsu,
966  dk4_er_t	*erp
967)
968{
969
970#if	DK4_SIZEOF_WXCHAR > 1
971	return (dk4pathw_set_suffix(pdst, szdst, srcname, newsu, erp));
972#else
973	return (dk4path8_set_suffix(pdst, szdst, srcname, newsu, erp));
974#endif
975}
976
977
978
979wxChar *
980dk4strx_path_dup_change_suffix(
981  wxChar const	*srcname,
982  wxChar const	*newsu,
983  dk4_er_t	*erp
984)
985{
986#if	DK4_SIZEOF_WXCHAR > 1
987	return (dk4pathw_dup_change_suffix(srcname, newsu, erp));
988#else
989	return (dk4path8_dup_change_suffix(srcname, newsu, erp));
990#endif
991}
992
993
994
995size_t
996dk4strx_path_concatenate_size(
997  wxChar const	*dirname,
998  wxChar const	*filename,
999  dk4_er_t	*erp
1000)
1001{
1002#if	DK4_SIZEOF_WXCHAR > 1
1003	return (dk4pathw_concatenate_size(dirname, filename, erp));
1004#else
1005	return (dk4path8_concatenate_size(dirname, filename, erp));
1006#endif
1007}
1008
1009
1010
1011int
1012dk4strx_path_concatenate_buffer(
1013  wxChar	*buffer,
1014  size_t	 szbuf,
1015  wxChar const	*dirn,
1016  wxChar const	*filen,
1017  dk4_er_t	*erp
1018)
1019{
1020#if	DK4_SIZEOF_WXCHAR > 1
1021	return (dk4pathw_concatenate_buffer(buffer, szbuf, dirn, filen, erp));
1022#else
1023	return (dk4path8_concatenate_buffer(buffer, szbuf, dirn, filen, erp));
1024#endif
1025}
1026
1027
1028
1029wxChar *
1030dk4strx_path_concatenate_new(
1031  wxChar const	*dirn,
1032  wxChar const	*filen,
1033  dk4_er_t	*erp
1034)
1035{
1036#if	DK4_SIZEOF_WXCHAR > 1
1037	return (dk4pathw_concatenate_new(dirn, filen, erp));
1038#else
1039	return (dk4path8_concatenate_new(dirn, filen, erp));
1040#endif
1041}
1042
1043
1044
1045int
1046dk4strx_path_is_in_subdir(
1047	const wxChar *filename,const wxChar *parent,dk4_er_t *erp
1048)
1049{
1050  wxChar	 buf[DK4_MAX_PATH];
1051  size_t	 szf;
1052  size_t	 szp;
1053  int		 back = 0;
1054  $? "+ dk4path_is_in_subdir f=\"%!ws\" p=\"%!ws\"", filename, parent
1055  if ((NULL != filename) && (NULL != parent)) {
1056    if (0 != dk4strx_cpy_s(buf, DK4_SIZEOF(buf,wxChar), filename, erp)) {
1057      szf = dk4strx_len(buf);
1058      szp = dk4strx_len(parent);
1059      if (szf > szp) {			$? ". filename larger than parent"
1060#if DK4_ON_WINDOWS || DK4_HAVE_BACKSLASH_AS_SEP
1061	if (buf[szp] == wxT('\\'))
1062#else
1063        if (buf[szp] == wxT('/'))
1064#endif
1065	{				$? ". separator at right place"
1066	  buf[szp] = wxT('\0');
1067	  if (0 == dk4strx_pathcmp(buf, parent)) {
1068	    back = 1;			$? ". match"
1069	  }
1070#if DK4_ON_WINDOWS || DK4_HAVE_BACKSLASH_AS_SEP
1071	  buf[szp] = wxT('\\');
1072#else
1073          buf[szp] = wxT('/');
1074#endif
1075	}
1076      } else {
1077        if (szf == szp) {		$? ". equal lengths"
1078	  if (0 == dk4strx_pathcmp(buf, parent)) {
1079	    back = 1;			$? ". match"
1080	  }
1081	}
1082      }
1083    }
1084  } else {
1085    dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS);
1086  } $? "- dk4path_is_in_subdir %d", back
1087  return back;
1088}
1089
1090
1091
1092/* vim: set ai sw=4 ts=4 : */
1093