forked from gcc-mirror/gcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.texi
1998 lines (1479 loc) · 71.2 KB
/
functions.texi
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
@c Automatically generated from *.c and others (the comments before
@c each entry tell you which file and where in that file). DO NOT EDIT!
@c Edit the *.c files, configure with --enable-maintainer-mode,
@c run 'make stamp-functions' and gather-docs will build a new copy.
@c alloca.c:26
@deftypefn Replacement void* alloca (size_t @var{size})
This function allocates memory which will be automatically reclaimed
after the procedure exits. The @libib{} implementation does not free
the memory immediately but will do so eventually during subsequent
calls to this function. Memory is allocated using @code{xmalloc} under
normal circumstances.
The header file @file{alloca-conf.h} can be used in conjunction with the
GNU Autoconf test @code{AC_FUNC_ALLOCA} to test for and properly make
available this function. The @code{AC_FUNC_ALLOCA} test requires that
client code use a block of preprocessor code to be safe (see the Autoconf
manual for more); this header incorporates that logic and more, including
the possibility of a GCC built-in function.
@end deftypefn
@c asprintf.c:32
@deftypefn Extension int asprintf (char **@var{resptr}, const char *@var{format}, ...)
Like @code{sprintf}, but instead of passing a pointer to a buffer, you
pass a pointer to a pointer. This function will compute the size of
the buffer needed, allocate memory with @code{malloc}, and store a
pointer to the allocated memory in @code{*@var{resptr}}. The value
returned is the same as @code{sprintf} would return. If memory could
not be allocated, minus one is returned and @code{NULL} is stored in
@code{*@var{resptr}}.
@end deftypefn
@c atexit.c:6
@deftypefn Supplemental int atexit (void (*@var{f})())
Causes function @var{f} to be called at exit. Returns 0.
@end deftypefn
@c basename.c:6
@deftypefn Supplemental char* basename (const char *@var{name})
Returns a pointer to the last component of pathname @var{name}.
Behavior is undefined if the pathname ends in a directory separator.
@end deftypefn
@c bcmp.c:6
@deftypefn Supplemental int bcmp (char *@var{x}, char *@var{y}, int @var{count})
Compares the first @var{count} bytes of two areas of memory. Returns
zero if they are the same, nonzero otherwise. Returns zero if
@var{count} is zero. A nonzero result only indicates a difference,
it does not indicate any sorting order (say, by having a positive
result mean @var{x} sorts before @var{y}).
@end deftypefn
@c bcopy.c:3
@deftypefn Supplemental void bcopy (char *@var{in}, char *@var{out}, int @var{length})
Copies @var{length} bytes from memory region @var{in} to region
@var{out}. The use of @code{bcopy} is deprecated in new programs.
@end deftypefn
@c bsearch.c:33
@deftypefn Supplemental void* bsearch (const void *@var{key}, @
const void *@var{base}, size_t @var{nmemb}, size_t @var{size}, @
int (*@var{compar})(const void *, const void *))
Performs a search over an array of @var{nmemb} elements pointed to by
@var{base} for a member that matches the object pointed to by @var{key}.
The size of each member is specified by @var{size}. The array contents
should be sorted in ascending order according to the @var{compar}
comparison function. This routine should take two arguments pointing to
the @var{key} and to an array member, in that order, and should return an
integer less than, equal to, or greater than zero if the @var{key} object
is respectively less than, matching, or greater than the array member.
@end deftypefn
@c argv.c:135
@deftypefn Extension char** buildargv (char *@var{sp})
Given a pointer to a string, parse the string extracting fields
separated by whitespace and optionally enclosed within either single
or double quotes (which are stripped off), and build a vector of
pointers to copies of the string for each field. The input string
remains unchanged. The last element of the vector is followed by a
@code{NULL} element.
All of the memory for the pointer array and copies of the string
is obtained from @code{xmalloc}. All of the memory can be returned to the
system with the single function call @code{freeargv}, which takes the
returned result of @code{buildargv}, as it's argument.
Returns a pointer to the argument vector if successful. Returns
@code{NULL} if @var{sp} is @code{NULL} or if there is insufficient
memory to complete building the argument vector.
If the input is a null string (as opposed to a @code{NULL} pointer),
then buildarg returns an argument vector that has one arg, a null
string.
@end deftypefn
@c bzero.c:6
@deftypefn Supplemental void bzero (char *@var{mem}, int @var{count})
Zeros @var{count} bytes starting at @var{mem}. Use of this function
is deprecated in favor of @code{memset}.
@end deftypefn
@c calloc.c:6
@deftypefn Supplemental void* calloc (size_t @var{nelem}, size_t @var{elsize})
Uses @code{malloc} to allocate storage for @var{nelem} objects of
@var{elsize} bytes each, then zeros the memory.
@end deftypefn
@c choose-temp.c:46
@deftypefn Extension char* choose_temp_base (void)
Return a prefix for temporary file names or @code{NULL} if unable to
find one. The current directory is chosen if all else fails so the
program is exited if a temporary directory can't be found (@code{mktemp}
fails). The buffer for the result is obtained with @code{xmalloc}.
This function is provided for backwards compatibility only. Its use is
not recommended.
@end deftypefn
@c make-temp-file.c:96
@deftypefn Replacement char* choose_tmpdir ()
Returns a pointer to a directory path suitable for creating temporary
files in.
@end deftypefn
@c clock.c:27
@deftypefn Supplemental long clock (void)
Returns an approximation of the CPU time used by the process as a
@code{clock_t}; divide this number by @samp{CLOCKS_PER_SEC} to get the
number of seconds used.
@end deftypefn
@c concat.c:24
@deftypefn Extension char* concat (const char *@var{s1}, const char *@var{s2}, @
@dots{}, @code{NULL})
Concatenate zero or more of strings and return the result in freshly
@code{xmalloc}ed memory. Returns @code{NULL} if insufficient memory is
available. The argument list is terminated by the first @code{NULL}
pointer encountered. Pointers to empty strings are ignored.
@end deftypefn
@c argv.c:470
@deftypefn Extension int countargv (char **@var{argv})
Return the number of elements in @var{argv}.
Returns zero if @var{argv} is NULL.
@end deftypefn
@c crc32.c:141
@deftypefn Extension {unsigned int} crc32 (const unsigned char *@var{buf}, @
int @var{len}, unsigned int @var{init})
Compute the 32-bit CRC of @var{buf} which has length @var{len}. The
starting value is @var{init}; this may be used to compute the CRC of
data split across multiple buffers by passing the return value of each
call as the @var{init} parameter of the next.
This is intended to match the CRC used by the @command{gdb} remote
protocol for the @samp{qCRC} command. In order to get the same
results as gdb for a block of data, you must pass the first CRC
parameter as @code{0xffffffff}.
This CRC can be specified as:
Width : 32
Poly : 0x04c11db7
Init : parameter, typically 0xffffffff
RefIn : false
RefOut : false
XorOut : 0
This differs from the "standard" CRC-32 algorithm in that the values
are not reflected, and there is no final XOR value. These differences
make it easy to compose the values of multiple blocks.
@end deftypefn
@c argv.c:52
@deftypefn Extension char** dupargv (char **@var{vector})
Duplicate an argument vector. Simply scans through @var{vector},
duplicating each argument until the terminating @code{NULL} is found.
Returns a pointer to the argument vector if successful. Returns
@code{NULL} if there is insufficient memory to complete building the
argument vector.
@end deftypefn
@c strerror.c:567
@deftypefn Extension int errno_max (void)
Returns the maximum @code{errno} value for which a corresponding
symbolic name or message is available. Note that in the case where we
use the @code{sys_errlist} supplied by the system, it is possible for
there to be more symbolic names than messages, or vice versa. In
fact, the manual page for @code{perror(3C)} explicitly warns that one
should check the size of the table (@code{sys_nerr}) before indexing
it, since new error codes may be added to the system before they are
added to the table. Thus @code{sys_nerr} might be smaller than value
implied by the largest @code{errno} value defined in @code{<errno.h>}.
We return the maximum value that can be used to obtain a meaningful
symbolic name or message.
@end deftypefn
@c argv.c:341
@deftypefn Extension void expandargv (int *@var{argcp}, char ***@var{argvp})
The @var{argcp} and @code{argvp} arguments are pointers to the usual
@code{argc} and @code{argv} arguments to @code{main}. This function
looks for arguments that begin with the character @samp{@@}. Any such
arguments are interpreted as ``response files''. The contents of the
response file are interpreted as additional command line options. In
particular, the file is separated into whitespace-separated strings;
each such string is taken as a command-line option. The new options
are inserted in place of the option naming the response file, and
@code{*argcp} and @code{*argvp} will be updated. If the value of
@code{*argvp} is modified by this function, then the new value has
been dynamically allocated and can be deallocated by the caller with
@code{freeargv}. However, most callers will simply call
@code{expandargv} near the beginning of @code{main} and allow the
operating system to free the memory when the program exits.
@end deftypefn
@c fdmatch.c:23
@deftypefn Extension int fdmatch (int @var{fd1}, int @var{fd2})
Check to see if two open file descriptors refer to the same file.
This is useful, for example, when we have an open file descriptor for
an unnamed file, and the name of a file that we believe to correspond
to that fd. This can happen when we are exec'd with an already open
file (@code{stdout} for example) or from the SVR4 @file{/proc} calls
that return open file descriptors for mapped address spaces. All we
have to do is open the file by name and check the two file descriptors
for a match, which is done by comparing major and minor device numbers
and inode numbers.
@end deftypefn
@c fopen_unlocked.c:49
@deftypefn Extension {FILE *} fdopen_unlocked (int @var{fildes}, @
const char * @var{mode})
Opens and returns a @code{FILE} pointer via @code{fdopen}. If the
operating system supports it, ensure that the stream is setup to avoid
any multi-threaded locking. Otherwise return the @code{FILE} pointer
unchanged.
@end deftypefn
@c ffs.c:3
@deftypefn Supplemental int ffs (int @var{valu})
Find the first (least significant) bit set in @var{valu}. Bits are
numbered from right to left, starting with bit 1 (corresponding to the
value 1). If @var{valu} is zero, zero is returned.
@end deftypefn
@c filename_cmp.c:32
@deftypefn Extension int filename_cmp (const char *@var{s1}, const char *@var{s2})
Return zero if the two file names @var{s1} and @var{s2} are equivalent.
If not equivalent, the returned value is similar to what @code{strcmp}
would return. In other words, it returns a negative value if @var{s1}
is less than @var{s2}, or a positive value if @var{s2} is greater than
@var{s2}.
This function does not normalize file names. As a result, this function
will treat filenames that are spelled differently as different even in
the case when the two filenames point to the same underlying file.
However, it does handle the fact that on DOS-like file systems, forward
and backward slashes are equal.
@end deftypefn
@c filename_cmp.c:178
@deftypefn Extension int filename_eq (const void *@var{s1}, const void *@var{s2})
Return non-zero if file names @var{s1} and @var{s2} are equivalent.
This function is for use with hashtab.c hash tables.
@end deftypefn
@c filename_cmp.c:147
@deftypefn Extension hashval_t filename_hash (const void *@var{s})
Return the hash value for file name @var{s} that will be compared
using filename_cmp.
This function is for use with hashtab.c hash tables.
@end deftypefn
@c filename_cmp.c:89
@deftypefn Extension int filename_ncmp (const char *@var{s1}, const char *@var{s2}, size_t @var{n})
Return zero if the two file names @var{s1} and @var{s2} are equivalent
in range @var{n}.
If not equivalent, the returned value is similar to what @code{strncmp}
would return. In other words, it returns a negative value if @var{s1}
is less than @var{s2}, or a positive value if @var{s2} is greater than
@var{s2}.
This function does not normalize file names. As a result, this function
will treat filenames that are spelled differently as different even in
the case when the two filenames point to the same underlying file.
However, it does handle the fact that on DOS-like file systems, forward
and backward slashes are equal.
@end deftypefn
@c fnmatch.txh:1
@deftypefn Replacement int fnmatch (const char *@var{pattern}, @
const char *@var{string}, int @var{flags})
Matches @var{string} against @var{pattern}, returning zero if it
matches, @code{FNM_NOMATCH} if not. @var{pattern} may contain the
wildcards @code{?} to match any one character, @code{*} to match any
zero or more characters, or a set of alternate characters in square
brackets, like @samp{[a-gt8]}, which match one character (@code{a}
through @code{g}, or @code{t}, or @code{8}, in this example) if that one
character is in the set. A set may be inverted (i.e., match anything
except what's in the set) by giving @code{^} or @code{!} as the first
character in the set. To include those characters in the set, list them
as anything other than the first character of the set. To include a
dash in the set, list it last in the set. A backslash character makes
the following character not special, so for example you could match
against a literal asterisk with @samp{\*}. To match a literal
backslash, use @samp{\\}.
@code{flags} controls various aspects of the matching process, and is a
boolean OR of zero or more of the following values (defined in
@code{<fnmatch.h>}):
@table @code
@item FNM_PATHNAME
@itemx FNM_FILE_NAME
@var{string} is assumed to be a path name. No wildcard will ever match
@code{/}.
@item FNM_NOESCAPE
Do not interpret backslashes as quoting the following special character.
@item FNM_PERIOD
A leading period (at the beginning of @var{string}, or if
@code{FNM_PATHNAME} after a slash) is not matched by @code{*} or
@code{?} but must be matched explicitly.
@item FNM_LEADING_DIR
Means that @var{string} also matches @var{pattern} if some initial part
of @var{string} matches, and is followed by @code{/} and zero or more
characters. For example, @samp{foo*} would match either @samp{foobar}
or @samp{foobar/grill}.
@item FNM_CASEFOLD
Ignores case when performing the comparison.
@end table
@end deftypefn
@c fopen_unlocked.c:39
@deftypefn Extension {FILE *} fopen_unlocked (const char *@var{path}, @
const char * @var{mode})
Opens and returns a @code{FILE} pointer via @code{fopen}. If the
operating system supports it, ensure that the stream is setup to avoid
any multi-threaded locking. Otherwise return the @code{FILE} pointer
unchanged.
@end deftypefn
@c argv.c:90
@deftypefn Extension void freeargv (char **@var{vector})
Free an argument vector that was built using @code{buildargv}. Simply
scans through @var{vector}, freeing the memory for each argument until
the terminating @code{NULL} is found, and then frees @var{vector}
itself.
@end deftypefn
@c fopen_unlocked.c:59
@deftypefn Extension {FILE *} freopen_unlocked (const char * @var{path}, @
const char * @var{mode}, FILE * @var{stream})
Opens and returns a @code{FILE} pointer via @code{freopen}. If the
operating system supports it, ensure that the stream is setup to avoid
any multi-threaded locking. Otherwise return the @code{FILE} pointer
unchanged.
@end deftypefn
@c getruntime.c:82
@deftypefn Replacement long get_run_time (void)
Returns the time used so far, in microseconds. If possible, this is
the time used by this process, else it is the elapsed time since the
process started.
@end deftypefn
@c getcwd.c:6
@deftypefn Supplemental char* getcwd (char *@var{pathname}, int @var{len})
Copy the absolute pathname for the current working directory into
@var{pathname}, which is assumed to point to a buffer of at least
@var{len} bytes, and return a pointer to the buffer. If the current
directory's path doesn't fit in @var{len} characters, the result is
@code{NULL} and @code{errno} is set. If @var{pathname} is a null pointer,
@code{getcwd} will obtain @var{len} bytes of space using
@code{malloc}.
@end deftypefn
@c getpagesize.c:5
@deftypefn Supplemental int getpagesize (void)
Returns the number of bytes in a page of memory. This is the
granularity of many of the system memory management routines. No
guarantee is made as to whether or not it is the same as the basic
memory management hardware page size.
@end deftypefn
@c getpwd.c:5
@deftypefn Supplemental char* getpwd (void)
Returns the current working directory. This implementation caches the
result on the assumption that the process will not call @code{chdir}
between calls to @code{getpwd}.
@end deftypefn
@c gettimeofday.c:12
@deftypefn Supplemental int gettimeofday (struct timeval *@var{tp}, void *@var{tz})
Writes the current time to @var{tp}. This implementation requires
that @var{tz} be NULL. Returns 0 on success, -1 on failure.
@end deftypefn
@c hex.c:33
@deftypefn Extension void hex_init (void)
Initializes the array mapping the current character set to
corresponding hex values. This function must be called before any
call to @code{hex_p} or @code{hex_value}. If you fail to call it, a
default ASCII-based table will normally be used on ASCII systems.
@end deftypefn
@c hex.c:42
@deftypefn Extension int hex_p (int @var{c})
Evaluates to non-zero if the given character is a valid hex character,
or zero if it is not. Note that the value you pass will be cast to
@code{unsigned char} within the macro.
@end deftypefn
@c hex.c:50
@deftypefn Extension {unsigned int} hex_value (int @var{c})
Returns the numeric equivalent of the given character when interpreted
as a hexadecimal digit. The result is undefined if you pass an
invalid hex digit. Note that the value you pass will be cast to
@code{unsigned char} within the macro.
The @code{hex_value} macro returns @code{unsigned int}, rather than
signed @code{int}, to make it easier to use in parsing addresses from
hex dump files: a signed @code{int} would be sign-extended when
converted to a wider unsigned type --- like @code{bfd_vma}, on some
systems.
@end deftypefn
@c safe-ctype.c:25
@defvr Extension HOST_CHARSET
This macro indicates the basic character set and encoding used by the
host: more precisely, the encoding used for character constants in
preprocessor @samp{#if} statements (the C "execution character set").
It is defined by @file{safe-ctype.h}, and will be an integer constant
with one of the following values:
@ftable @code
@item HOST_CHARSET_UNKNOWN
The host character set is unknown - that is, not one of the next two
possibilities.
@item HOST_CHARSET_ASCII
The host character set is ASCII.
@item HOST_CHARSET_EBCDIC
The host character set is some variant of EBCDIC. (Only one of the
nineteen EBCDIC varying characters is tested; exercise caution.)
@end ftable
@end defvr
@c hashtab.c:336
@deftypefn Supplemental htab_t htab_create_typed_alloc (size_t @var{size}, @
htab_hash @var{hash_f}, htab_eq @var{eq_f}, htab_del @var{del_f}, @
htab_alloc @var{alloc_tab_f}, htab_alloc @var{alloc_f}, @
htab_free @var{free_f})
This function creates a hash table that uses two different allocators
@var{alloc_tab_f} and @var{alloc_f} to use for allocating the table itself
and its entries respectively. This is useful when variables of different
types need to be allocated with different allocators.
The created hash table is slightly larger than @var{size} and it is
initially empty (all the hash table entries are @code{HTAB_EMPTY_ENTRY}).
The function returns the created hash table, or @code{NULL} if memory
allocation fails.
@end deftypefn
@c index.c:5
@deftypefn Supplemental char* index (char *@var{s}, int @var{c})
Returns a pointer to the first occurrence of the character @var{c} in
the string @var{s}, or @code{NULL} if not found. The use of @code{index} is
deprecated in new programs in favor of @code{strchr}.
@end deftypefn
@c insque.c:6
@deftypefn Supplemental void insque (struct qelem *@var{elem}, @
struct qelem *@var{pred})
@deftypefnx Supplemental void remque (struct qelem *@var{elem})
Routines to manipulate queues built from doubly linked lists. The
@code{insque} routine inserts @var{elem} in the queue immediately
after @var{pred}. The @code{remque} routine removes @var{elem} from
its containing queue. These routines expect to be passed pointers to
structures which have as their first members a forward pointer and a
back pointer, like this prototype (although no prototype is provided):
@example
struct qelem @{
struct qelem *q_forw;
struct qelem *q_back;
char q_data[];
@};
@end example
@end deftypefn
@c safe-ctype.c:46
@deffn Extension ISALPHA (@var{c})
@deffnx Extension ISALNUM (@var{c})
@deffnx Extension ISBLANK (@var{c})
@deffnx Extension ISCNTRL (@var{c})
@deffnx Extension ISDIGIT (@var{c})
@deffnx Extension ISGRAPH (@var{c})
@deffnx Extension ISLOWER (@var{c})
@deffnx Extension ISPRINT (@var{c})
@deffnx Extension ISPUNCT (@var{c})
@deffnx Extension ISSPACE (@var{c})
@deffnx Extension ISUPPER (@var{c})
@deffnx Extension ISXDIGIT (@var{c})
These twelve macros are defined by @file{safe-ctype.h}. Each has the
same meaning as the corresponding macro (with name in lowercase)
defined by the standard header @file{ctype.h}. For example,
@code{ISALPHA} returns true for alphabetic characters and false for
others. However, there are two differences between these macros and
those provided by @file{ctype.h}:
@itemize @bullet
@item These macros are guaranteed to have well-defined behavior for all
values representable by @code{signed char} and @code{unsigned char}, and
for @code{EOF}.
@item These macros ignore the current locale; they are true for these
fixed sets of characters:
@multitable {@code{XDIGIT}} {yada yada yada yada yada yada yada yada}
@item @code{ALPHA} @tab @kbd{A-Za-z}
@item @code{ALNUM} @tab @kbd{A-Za-z0-9}
@item @code{BLANK} @tab @kbd{space tab}
@item @code{CNTRL} @tab @code{!PRINT}
@item @code{DIGIT} @tab @kbd{0-9}
@item @code{GRAPH} @tab @code{ALNUM || PUNCT}
@item @code{LOWER} @tab @kbd{a-z}
@item @code{PRINT} @tab @code{GRAPH ||} @kbd{space}
@item @code{PUNCT} @tab @kbd{`~!@@#$%^&*()_-=+[@{]@}\|;:'",<.>/?}
@item @code{SPACE} @tab @kbd{space tab \n \r \f \v}
@item @code{UPPER} @tab @kbd{A-Z}
@item @code{XDIGIT} @tab @kbd{0-9A-Fa-f}
@end multitable
Note that, if the host character set is ASCII or a superset thereof,
all these macros will return false for all values of @code{char} outside
the range of 7-bit ASCII. In particular, both ISPRINT and ISCNTRL return
false for characters with numeric values from 128 to 255.
@end itemize
@end deffn
@c safe-ctype.c:95
@deffn Extension ISIDNUM (@var{c})
@deffnx Extension ISIDST (@var{c})
@deffnx Extension IS_VSPACE (@var{c})
@deffnx Extension IS_NVSPACE (@var{c})
@deffnx Extension IS_SPACE_OR_NUL (@var{c})
@deffnx Extension IS_ISOBASIC (@var{c})
These six macros are defined by @file{safe-ctype.h} and provide
additional character classes which are useful when doing lexical
analysis of C or similar languages. They are true for the following
sets of characters:
@multitable {@code{SPACE_OR_NUL}} {yada yada yada yada yada yada yada yada}
@item @code{IDNUM} @tab @kbd{A-Za-z0-9_}
@item @code{IDST} @tab @kbd{A-Za-z_}
@item @code{VSPACE} @tab @kbd{\r \n}
@item @code{NVSPACE} @tab @kbd{space tab \f \v \0}
@item @code{SPACE_OR_NUL} @tab @code{VSPACE || NVSPACE}
@item @code{ISOBASIC} @tab @code{VSPACE || NVSPACE || PRINT}
@end multitable
@end deffn
@c lbasename.c:23
@deftypefn Replacement {const char*} lbasename (const char *@var{name})
Given a pointer to a string containing a typical pathname
(@samp{/usr/src/cmd/ls/ls.c} for example), returns a pointer to the
last component of the pathname (@samp{ls.c} in this case). The
returned pointer is guaranteed to lie within the original
string. This latter fact is not true of many vendor C
libraries, which return special strings or modify the passed
strings for particular input.
In particular, the empty string returns the same empty string,
and a path ending in @code{/} returns the empty string after it.
@end deftypefn
@c lrealpath.c:25
@deftypefn Replacement {const char*} lrealpath (const char *@var{name})
Given a pointer to a string containing a pathname, returns a canonical
version of the filename. Symlinks will be resolved, and ``.'' and ``..''
components will be simplified. The returned value will be allocated using
@code{malloc}, or @code{NULL} will be returned on a memory allocation error.
@end deftypefn
@c make-relative-prefix.c:24
@deftypefn Extension {const char*} make_relative_prefix (const char *@var{progname}, @
const char *@var{bin_prefix}, const char *@var{prefix})
Given three paths @var{progname}, @var{bin_prefix}, @var{prefix},
return the path that is in the same position relative to
@var{progname}'s directory as @var{prefix} is relative to
@var{bin_prefix}. That is, a string starting with the directory
portion of @var{progname}, followed by a relative pathname of the
difference between @var{bin_prefix} and @var{prefix}.
If @var{progname} does not contain any directory separators,
@code{make_relative_prefix} will search @env{PATH} to find a program
named @var{progname}. Also, if @var{progname} is a symbolic link,
the symbolic link will be resolved.
For example, if @var{bin_prefix} is @code{/alpha/beta/gamma/gcc/delta},
@var{prefix} is @code{/alpha/beta/gamma/omega/}, and @var{progname} is
@code{/red/green/blue/gcc}, then this function will return
@code{/red/green/blue/../../omega/}.
The return value is normally allocated via @code{malloc}. If no
relative prefix can be found, return @code{NULL}.
@end deftypefn
@c make-temp-file.c:174
@deftypefn Replacement char* make_temp_file (const char *@var{suffix})
Return a temporary file name (as a string) or @code{NULL} if unable to
create one. @var{suffix} is a suffix to append to the file name. The
string is @code{malloc}ed, and the temporary file has been created.
@end deftypefn
@c memchr.c:3
@deftypefn Supplemental void* memchr (const void *@var{s}, int @var{c}, @
size_t @var{n})
This function searches memory starting at @code{*@var{s}} for the
character @var{c}. The search only ends with the first occurrence of
@var{c}, or after @var{length} characters; in particular, a null
character does not terminate the search. If the character @var{c} is
found within @var{length} characters of @code{*@var{s}}, a pointer
to the character is returned. If @var{c} is not found, then @code{NULL} is
returned.
@end deftypefn
@c memcmp.c:6
@deftypefn Supplemental int memcmp (const void *@var{x}, const void *@var{y}, @
size_t @var{count})
Compares the first @var{count} bytes of two areas of memory. Returns
zero if they are the same, a value less than zero if @var{x} is
lexically less than @var{y}, or a value greater than zero if @var{x}
is lexically greater than @var{y}. Note that lexical order is determined
as if comparing unsigned char arrays.
@end deftypefn
@c memcpy.c:6
@deftypefn Supplemental void* memcpy (void *@var{out}, const void *@var{in}, @
size_t @var{length})
Copies @var{length} bytes from memory region @var{in} to region
@var{out}. Returns a pointer to @var{out}.
@end deftypefn
@c memmem.c:20
@deftypefn Supplemental void* memmem (const void *@var{haystack}, @
size_t @var{haystack_len} const void *@var{needle}, size_t @var{needle_len})
Returns a pointer to the first occurrence of @var{needle} (length
@var{needle_len}) in @var{haystack} (length @var{haystack_len}).
Returns @code{NULL} if not found.
@end deftypefn
@c memmove.c:6
@deftypefn Supplemental void* memmove (void *@var{from}, const void *@var{to}, @
size_t @var{count})
Copies @var{count} bytes from memory area @var{from} to memory area
@var{to}, returning a pointer to @var{to}.
@end deftypefn
@c mempcpy.c:23
@deftypefn Supplemental void* mempcpy (void *@var{out}, const void *@var{in}, @
size_t @var{length})
Copies @var{length} bytes from memory region @var{in} to region
@var{out}. Returns a pointer to @var{out} + @var{length}.
@end deftypefn
@c memset.c:6
@deftypefn Supplemental void* memset (void *@var{s}, int @var{c}, @
size_t @var{count})
Sets the first @var{count} bytes of @var{s} to the constant byte
@var{c}, returning a pointer to @var{s}.
@end deftypefn
@c mkstemps.c:58
@deftypefn Replacement int mkstemps (char *@var{pattern}, int @var{suffix_len})
Generate a unique temporary file name from @var{pattern}.
@var{pattern} has the form:
@example
@var{path}/ccXXXXXX@var{suffix}
@end example
@var{suffix_len} tells us how long @var{suffix} is (it can be zero
length). The last six characters of @var{pattern} before @var{suffix}
must be @samp{XXXXXX}; they are replaced with a string that makes the
filename unique. Returns a file descriptor open on the file for
reading and writing.
@end deftypefn
@c pexecute.txh:278
@deftypefn Extension void pex_free (struct pex_obj @var{obj})
Clean up and free all data associated with @var{obj}. If you have not
yet called @code{pex_get_times} or @code{pex_get_status}, this will
try to kill the subprocesses.
@end deftypefn
@c pexecute.txh:251
@deftypefn Extension int pex_get_status (struct pex_obj *@var{obj}, @
int @var{count}, int *@var{vector})
Returns the exit status of all programs run using @var{obj}.
@var{count} is the number of results expected. The results will be
placed into @var{vector}. The results are in the order of the calls
to @code{pex_run}. Returns 0 on error, 1 on success.
@end deftypefn
@c pexecute.txh:261
@deftypefn Extension int pex_get_times (struct pex_obj *@var{obj}, @
int @var{count}, struct pex_time *@var{vector})
Returns the process execution times of all programs run using
@var{obj}. @var{count} is the number of results expected. The
results will be placed into @var{vector}. The results are in the
order of the calls to @code{pex_run}. Returns 0 on error, 1 on
success.
@code{struct pex_time} has the following fields of the type
@code{unsigned long}: @code{user_seconds},
@code{user_microseconds}, @code{system_seconds},
@code{system_microseconds}. On systems which do not support reporting
process times, all the fields will be set to @code{0}.
@end deftypefn
@c pexecute.txh:2
@deftypefn Extension {struct pex_obj *} pex_init (int @var{flags}, @
const char *@var{pname}, const char *@var{tempbase})
Prepare to execute one or more programs, with standard output of each
program fed to standard input of the next. This is a system
independent interface to execute a pipeline.
@var{flags} is a bitwise combination of the following:
@table @code
@vindex PEX_RECORD_TIMES
@item PEX_RECORD_TIMES
Record subprocess times if possible.
@vindex PEX_USE_PIPES
@item PEX_USE_PIPES
Use pipes for communication between processes, if possible.
@vindex PEX_SAVE_TEMPS
@item PEX_SAVE_TEMPS
Don't delete temporary files used for communication between
processes.
@end table
@var{pname} is the name of program to be executed, used in error
messages. @var{tempbase} is a base name to use for any required
temporary files; it may be @code{NULL} to use a randomly chosen name.
@end deftypefn
@c pexecute.txh:161
@deftypefn Extension {FILE *} pex_input_file (struct pex_obj *@var{obj}, @
int @var{flags}, const char *@var{in_name})
Return a stream for a temporary file to pass to the first program in
the pipeline as input.
The name of the input file is chosen according to the same rules
@code{pex_run} uses to choose output file names, based on
@var{in_name}, @var{obj} and the @code{PEX_SUFFIX} bit in @var{flags}.
Don't call @code{fclose} on the returned stream; the first call to
@code{pex_run} closes it automatically.
If @var{flags} includes @code{PEX_BINARY_OUTPUT}, open the stream in
binary mode; otherwise, open it in the default mode. Including
@code{PEX_BINARY_OUTPUT} in @var{flags} has no effect on Unix.
@end deftypefn
@c pexecute.txh:179
@deftypefn Extension {FILE *} pex_input_pipe (struct pex_obj *@var{obj}, @
int @var{binary})
Return a stream @var{fp} for a pipe connected to the standard input of
the first program in the pipeline; @var{fp} is opened for writing.
You must have passed @code{PEX_USE_PIPES} to the @code{pex_init} call
that returned @var{obj}.
You must close @var{fp} using @code{fclose} yourself when you have
finished writing data to the pipeline.
The file descriptor underlying @var{fp} is marked not to be inherited
by child processes.
On systems that do not support pipes, this function returns
@code{NULL}, and sets @code{errno} to @code{EINVAL}. If you would
like to write code that is portable to all systems the @code{pex}
functions support, consider using @code{pex_input_file} instead.
There are two opportunities for deadlock using
@code{pex_input_pipe}:
@itemize @bullet
@item
Most systems' pipes can buffer only a fixed amount of data; a process
that writes to a full pipe blocks. Thus, if you write to @file{fp}
before starting the first process, you run the risk of blocking when
there is no child process yet to read the data and allow you to
continue. @code{pex_input_pipe} makes no promises about the
size of the pipe's buffer, so if you need to write any data at all
before starting the first process in the pipeline, consider using
@code{pex_input_file} instead.
@item
Using @code{pex_input_pipe} and @code{pex_read_output} together
may also cause deadlock. If the output pipe fills up, so that each
program in the pipeline is waiting for the next to read more data, and
you fill the input pipe by writing more data to @var{fp}, then there
is no way to make progress: the only process that could read data from
the output pipe is you, but you are blocked on the input pipe.
@end itemize
@end deftypefn
@c pexecute.txh:286
@deftypefn Extension {const char *} pex_one (int @var{flags}, @
const char *@var{executable}, char * const *@var{argv}, @
const char *@var{pname}, const char *@var{outname}, const char *@var{errname}, @
int *@var{status}, int *@var{err})
An interface to permit the easy execution of a
single program. The return value and most of the parameters are as
for a call to @code{pex_run}. @var{flags} is restricted to a
combination of @code{PEX_SEARCH}, @code{PEX_STDERR_TO_STDOUT}, and
@code{PEX_BINARY_OUTPUT}. @var{outname} is interpreted as if
@code{PEX_LAST} were set. On a successful return, @code{*@var{status}} will
be set to the exit status of the program.
@end deftypefn
@c pexecute.txh:237
@deftypefn Extension {FILE *} pex_read_err (struct pex_obj *@var{obj}, @
int @var{binary})
Returns a @code{FILE} pointer which may be used to read the standard
error of the last program in the pipeline. When this is used,
@code{PEX_LAST} should not be used in a call to @code{pex_run}. After
this is called, @code{pex_run} may no longer be called with the same
@var{obj}. @var{binary} should be non-zero if the file should be
opened in binary mode. Don't call @code{fclose} on the returned file;
it will be closed by @code{pex_free}.
@end deftypefn
@c pexecute.txh:224
@deftypefn Extension {FILE *} pex_read_output (struct pex_obj *@var{obj}, @
int @var{binary})
Returns a @code{FILE} pointer which may be used to read the standard
output of the last program in the pipeline. When this is used,
@code{PEX_LAST} should not be used in a call to @code{pex_run}. After
this is called, @code{pex_run} may no longer be called with the same
@var{obj}. @var{binary} should be non-zero if the file should be
opened in binary mode. Don't call @code{fclose} on the returned file;
it will be closed by @code{pex_free}.
@end deftypefn
@c pexecute.txh:34
@deftypefn Extension {const char *} pex_run (struct pex_obj *@var{obj}, @
int @var{flags}, const char *@var{executable}, char * const *@var{argv}, @
const char *@var{outname}, const char *@var{errname}, int *@var{err})
Execute one program in a pipeline. On success this returns
@code{NULL}. On failure it returns an error message, a statically
allocated string.
@var{obj} is returned by a previous call to @code{pex_init}.
@var{flags} is a bitwise combination of the following:
@table @code
@vindex PEX_LAST
@item PEX_LAST
This must be set on the last program in the pipeline. In particular,