Page 1057 tdelete frees the memory required for the node in the tree. The user is responsible for freeing the memory for the corresponding data. The example program depends on the fact that twalk makes no further reference to a node after calling the user function with argument endorder or leaf. This works with the GNU library implementation, but is not in the SysV documentation. EXAMPLE The following program inserts twelve random numbers into a binary tree, then prints the numbers in order. The numbers are removed from the tree and their storage freed during the traversal. #include <search.h> #include <stdlib.h> #include <stdio.h> void *root=NULL; void *xmalloc(unsigned n) { void *p; p = malloc(n); if(p) return p; fprintf(stderr, "insufficient memory\n"); exit(1); } int compare(const void *pa, const void *pb) { if(*(int *)pa < *(int *)pb) return -1; if(*(int *)pa > *(int *)pb) return 1; return 0; } void action(const void *nodep, const VISIT which, const int depth) { int *datap; void *val; switch(which) { case preorder: break; case postorder: datap = *(int **)nodep; printf("%6d\n", *datap); break; case endorder: datap = *(int **)nodep; (void)tdelete(datap, &root, compare); free(datap); break; case leaf: datap = *(int **)nodep; printf("%6d\n", *datap); val = tdelete(datap, &root, compare); free(datap); break; } return; Page 1058 } int main() { int i, *ptr; void *val; for (i = 0; i < 12; i++) { ptr = (int *)xmalloc(sizeof(int)); *ptr = rand()&0xff; val = tsearch((void *)ptr, &root, compare); if(val == NULL) exit(1); } twalk(root, action); return 0; } CONFORMS TO SVID SEE ALSO qsort(3), bsearch(3), hsearch(3), lsearch(3) GNU, 24 September 1995 ttynamettynameReturns name of a terminal SYNOPSIS #include <unistd.h> char *ttyname ( int desc ); DESCRIPTION Returns a pointer to the pathname of the terminal device that is open on the file descriptor desc, or NULL on error (for example, if desc is not connected to a terminal). CONFORMS TO POSIX.1 SEE ALSO isatty(3), fstat(3) Linux, 20 April 1995 tzsettzsetInitializes time conversion information SYNOPSIS #include <time.h> void tzset (void); extern char *tzname[2]; Page 1059 DESCRIPTION The tzset() function initializes the tzname variable from the TZ environment variable. This function is automatically called by the other time conversion functions that depend on the time zone. If the TZ variable does not appear in the environment, the tzname variable is initialized with the best approximation of local wall clock time, as specified by the tzfile(5)-format file /usr/lib/zoneinfo/localtime. If the TZ variable does appear in the environment but its value is NULL or its value cannot be interpreted using any of the formats specified in the following paragraphs, Coordinated Universal Time (UTC) is used. The value of TZ can be one of three formats. The first format is used when there is no daylight saving time in the local time zone: std offset The std string specifies the name of the time zone and must be three or more alphabetic characters. The offset string immediately follows std and specifies the time value to be added to the local time to get Coordinated Universal Time (UTC). The offset is positive if the local time zone is west of the Prime Meridian and negative if it is east. The hour must be between 0 and 24, and the minutes and seconds 0 and 59. The second format is used when there is daylight saving time: std offset dst [offset],start[/time],end[/time] There are no spaces in the specification. The initial std and offset specify the standard time zone, as described. The dst string and offset specify the name and offset for the corresponding daylight savings time zone. If the offset is omitted, it defaults to one hour ahead of standard time. The start field specifies when Daylight Savings Time goes into effect and the end field specifies when the change is made back to Standard Time. These fields may have the following formats:
The time fields specify when, in the local time currently in effect, the change to the other time occurs. If omitted, the default is 02:00:00. The third format specifies that the time zone information should be read from a file: :[filespec] If the file specification filespec is omitted, the time zone information is read from /usr/lib/zoneinfo/localtime, which is in tzfile(5) format. If filespec is given, it specifies an-other tzfile(5)-format file to read the time zone information from. If filespec does not begin with a /, the file specification is relative to the system time conversion information directory /usr/lib/zoneinfo. FILES
CONFORMS TO SVID 3, POSIX, BSD 4.3 Page 1060 SEE ALSO date(1), gettimeofday(2), time(2), ctime(3), getenv(3), tzfile(5) BSD, 2 July 1993 nonenoneUndocumented library functions SYNOPSIS Undocumented library functions DESCRIPTION This man page mentions those library functions that are implemented in the standard libraries but not yet documented in man pages. SOLICITATION If you have information about these functions, please look in the source code, write a man page (using a style similar to that of the other Linux section 3 man pages), and send it to aeb@cwi.nl for inclusion in the next man page release. THE LIST des_setparity, dn_skipname, ecb_crypt, encrypt, endnetgrent, endrpcent, endutent, execlp, fcrypt, fp_nquery, fp_query, fp_resstat, get_myaddress, getnetgrent, getnetname, getopt_long_only, getpublickey, getrpcbyname, getrpcbynumber, getrpcent, getrpcport, getsecretkey, getutid, getutline, h_errlist, host2netname, hostalias, inet_nsap_addr, inet_nsap_ntoa_init_des, innetgr, key_decryptsession, key_encryptsession, key_gendes, key_setsecret, lfind, libc_nls_init, lockf, lsearch, mcheck, memalign, mstats, mtrace, netname2host, netname2user, nlist, obstack_free, p_cdname, p_cdnname, p_class, p_fqname, p_option, p_query, p_rr, p_time, p_type, passwd2des, pmap_getmaps, pmap_getport, pmap_rmtcall, pmap_set, pmap_unset, putlong, putshort, pututline, rcmd, re_compile_fastmap, re_compile_pattern, re_match, re_match_2, re_rx_search, re_search, re_search_2, re_set_registers, re_set_syntax, registerrpc, res_send_setqhook, res_send_setrhook, rexec, rresvport, rtime, ruserok, ruserpass, setfileno, sethostfile, setkey, setlogmask, setnetgrent, setrpcent, setutent, siglongjmp, snprintf, stpcpy, svc_exit, svc_getreq, svc_getreqset, svc_register, svc_run, svc_sendreply, svc_unregister, svcerr_auth, svcerr_decode, svcerr_noproc, svcerr_noprog, svcerr_progvers, svcerr_systemerr, svcerr_weakauth, svcfd_create, svcraw_create, svctcp_create, svcudp_bufcreate, svcudp_create, svcudp_enablecachesyscall, tdelete, tell, tfind, timegm, tr_break, tsearch, twalk, tzsetwall, ufc_dofinalperm, ufc_doit, user2netname, utmpname, valloc, vsnprintf, vsyslog, xdecrypt, xdr_accepted_reply, xdr_array, xdr_authdes_cred, xdr_authdes_verf, xdr_authunix_parms, xdr_bool, xdr_bytes, xdr_callhdr, xdr_callmsg, xdr_char, xdr_cryptkeyarg, xdr_cryptkeyres, xdr_datum, xdr_des_block, xdr_domainname, xdr_double, xdr_enum, xdr_float, xdr_free, xdr_getcredres, xdr_int, xdr_keybuf, xdr_keystatus, xdr_long, xdr_mapname, xdr_netnamestr, xdr_netobj, xdr_opaque, xdr_opaque_auth, xdr_passwd, xdr_peername, xdr_pmap, xdr_pmaplist, xdr_pointer, xdr_reference, xdr_rejected_reply, xdr_replymsg, xdr_rmtcall_args, xdr_rmtcallres, xdr_short, xdr_string, xdr_u_char, xdr_u_int, xdr_u_long, xdr_u_short, xdr_union, xdr_unixcred, xdr_vector, xdr_void, xdr_wrapstring, xdr_yp_buf, xdr_yp_inaddr, xdr_ypbind_binding, xdr_ypbind_resp, xdr_ypbind_resptype, xdr_ypbind_setdom, xdr_ypdelete_args, xdr_ypmaplist, xdr_ypmaplist_str, xdr_yppasswd, xdr_ypreq_key, xdr_ypreq_nokey, xdr_ypresp_all, xdr_ypresp_all_seq, xdr_ypresp_key_val, xdr_ypresp_maplist, xdr_ypresp_master, xdr_ypresp_order, xdr_ypresp_val, xdr_ypstat, xdr_ypupdate_args, xdrmem_create, xdrrec_create, xdrrec_endofrecord, xdrrec_eof, xdrrec_skiprecord, xdrstdio_create, xencrypt, xprt_register, xprt_unregister, yp_all, yp_bind, yp_first, yp_get_default_domain, yp_maplist, yp_master, yp_match, yp_next, yp_order, yp_unbind, yp_update, yperr_string, ypprot_err Linux 1.3.15, 25 August 1995 |