home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / news / cnews.tar / doc / libs < prev    next >
Text File  |  1992-02-16  |  7KB  |  395 lines

  1. .Ch "A Tour Through the C News Libraries and Include Files"
  2. .Ix libraries
  3. .Ix files include
  4. .SH
  5. libc and friends
  6. .Df libc
  7. .LP
  8. .I libc
  9. contains routines that are sufficiently useful
  10. and general that they could profitably be added to
  11. one's C library.
  12. Indeed,
  13. on some systems they are in the C library.
  14. Notable inventions include
  15. .I fgetmfs
  16. .Df fgetmfs
  17. .Ix "read long lines"
  18. which safely reads arbitrarily-long input lines;
  19. it has an
  20. .B fgetmfs.h
  21. over in the header directories.
  22. .I ldiv
  23. .Df ldiv
  24. is the ANSI one,
  25. if you need it.
  26. .I memlist
  27. .Df memlist
  28. is a
  29. package to ease keeping track of a lot of allocated memory.
  30. .I stdfdopen
  31. .Df stdfdopen
  32. is invoked by setuid programs
  33. to ensure that the standard file descriptors are indeed open,
  34. opening
  35. .B /dev/null
  36. on each closed standard descriptor.
  37. .\".B libc/memcpy.fast
  38. .\"contains some alternate
  39. .\"implementations of
  40. .\".I memcpy (3)
  41. .\"which may be faster than the ones in your local C library.
  42. .LP
  43. .B libstdio
  44. .Df libstdio
  45. .Ix stdio "faster internals"
  46. contains new (faster) guts for
  47. the original
  48. .UX
  49. .I stdio
  50. library;
  51. if they compile on your V7,
  52. 4BSD
  53. or System III
  54. system,
  55. you may want to use them instead of the default versions
  56. in your C library.
  57. On System V,
  58. these routines are only slightly faster than the versions in the C library.
  59. .LP
  60. .B libfake
  61. .Df libfake
  62. contains things that probably should be in your C library,
  63. but might not be,
  64. and a couple of fake routines for system calls
  65. you might not have.
  66. .SH
  67. libcnews
  68. .LP
  69. .Df libcnews
  70. .B libcnews
  71. contains functions of general use to news software,
  72. but not the world at large.
  73. .I complain
  74. .Df complain
  75. is like
  76. .I warning ,
  77. but never prints the symbolic value of
  78. .I errno .
  79. .PP
  80. .Ix lock
  81. .Df lockdebug
  82. .Df newslock
  83. .Df newsunlock
  84. .Df errunlock
  85. .Df nemalloc
  86. There is a locking package,
  87. containing
  88. .I lockdebug ,
  89. .I newslock ,
  90. .I newsunlock ,
  91. .I errunlock ,
  92. and
  93. .I nemalloc .
  94. .I lockdebug
  95. enables or disables lock debugging.
  96. .I newslock
  97. attempts to lock
  98. the news transport layer
  99. against
  100. read-then-write access to the
  101. .B active
  102. file,
  103. writing to the
  104. .Ix history
  105. .Ix files batch
  106. .B history *,
  107. .B log ,
  108. .B errlog ,
  109. and batch files.
  110. It returns only when it has the lock;
  111. in the meantime it sleeps and retries until it gets the lock.
  112. There is no timeout;
  113. this is a feature.
  114. .I newsunlock
  115. removes the above-mentioned lock
  116. if this process locked the news system.
  117. .I errunlock
  118. is like
  119. .I error
  120. except that it
  121. unlocks the news system
  122. (via
  123. .I newsunlock)
  124. before exiting;
  125. it is should always be called instead of
  126. .I exit (3)
  127. or
  128. .I exit (2)
  129. if there is any chance that this process has locked the news system.
  130. .I nemalloc
  131. is like
  132. .I emalloc
  133. but it calls
  134. .I errunlock
  135. if it can't allocate memory.
  136. .PP
  137. .Ix ltoza
  138. .I ltoza
  139. converts a
  140. .B "long int"
  141. to a string of a given width,
  142. containing the decimal representation,
  143. zero-padding as needed on the left.
  144. .I ltozan
  145. .Ix ltozan
  146. is like
  147. .I ltoza
  148. but omits the terminating NUL,
  149. so it can be used to overwrite a string without truncating it.
  150. .I ngmatch
  151. .Ix ngmatch
  152. .Ix "newsgroup matching"
  153. returns a truth-value
  154. resulting from comparing
  155. a list of newsgroup patterns
  156. and
  157. a list of newsgroups.
  158. One may substitute ``distribution'' for ``newsgroup''.
  159. .PP
  160. .Ix files names
  161. .Ix configuration
  162. .Df artfile
  163. .Df fullartfile
  164. .Df ctlfile
  165. .Df binfile
  166. .Df cd
  167. .Df newsumask
  168. There is a package of pathname manipulators.
  169. .I artfile
  170. returns a name for its filename argument,
  171. assumed to be relative to
  172. .I $NEWSARTS ;
  173. .I fullartfile
  174. promises to return a fully-qualified path name.
  175. .I ctlfile
  176. returns a name for its filename argument,
  177. assumed to be relative to
  178. .I $NEWSCTL .
  179. .I binfile
  180. returns a name for its filename argument,
  181. assumed to be relative to
  182. .I $NEWSBIN .
  183. .I cd
  184. changes to its argument directory,
  185. check for errors,
  186. and notes the directory name,
  187. by making a private copy,
  188. for later optimisations.
  189. .I newsumask
  190. returns the value of
  191. .I $NEWSUMASK .
  192. .Df newspath
  193. .Df newsmaster
  194. .I newspath
  195. returns the value of
  196. .I $NEWSPATH .
  197. .I newsmaster
  198. returns the value of
  199. .I $NEWSMASTER .
  200. All these functions
  201. supply default values for the
  202. .I NEWS *
  203. variables if none are found in the environment.
  204. If values are found in the environment,
  205. they are used,
  206. and a function named
  207. .Df unprivileged
  208. .I unprivileged
  209. is called.
  210. .PP
  211. .Ix readline
  212. .I readline
  213. is like
  214. .I fgets ,
  215. but executes
  216. .I newslock
  217. upon encountering EOF
  218. and retries the read.
  219. This is used when reading growing files
  220. such as
  221. .B history
  222. or
  223. batch files.
  224. .Ix strlower
  225. .I strlower
  226. down-cases an entire string,
  227. in place.
  228. .Ix strsave
  229. .I strsave
  230. is like
  231. .I strdup
  232. but it calls
  233. .I nemalloc
  234. rather than
  235. .I emalloc .
  236. .Ix str3save
  237. .I str3save
  238. takes three strings,
  239. allocates space for their concatenation
  240. via
  241. .I nemalloc ,
  242. including terminating NUL,
  243. and concatenates them onto it.
  244. A
  245. .I NULL
  246. argument will be replaced by an empty string.
  247. .I timestamp
  248. writes a timestamp on a given stream,
  249. and returns the current time via an argument
  250. for later use.
  251. .SH
  252. Unix-variant-specific libraries
  253. .LP
  254. .Ix Unix variants
  255. There are several libraries that provide functions
  256. for talking to specific Unix variants.
  257. These are basically functions that change from one variant to another.
  258. .B libfake
  259. (see above) contains things which simply might not be there in a
  260. particular system.
  261. .LP
  262. These libraries all provide the same virtual interface to
  263. operating-system-dependent services:
  264. .Df fclsexec
  265. .Df fopenexcl
  266. .Df getcwd
  267. .Df gethostname
  268. .I fclsexec ,
  269. .I fopenexcl ,
  270. .I getcwd (3),
  271. and
  272. .I gethostname (3).
  273. Implementations for vanilla implementations of these
  274. .UX
  275. variants are provided:
  276. .Ix Unix V7
  277. Seventh Edition,
  278. .Ix Unix 4.1BSD
  279. including 4.1BSD
  280. (\c
  281. .B libv7 );
  282. .Df libv7
  283. Eighth
  284. and Ninth Editions
  285. .Ix Unix V8
  286. .Ix Unix V9
  287. .Df libv8
  288. (\c
  289. .B libv8 );
  290. 4.2BSD and later
  291. .Ix Unix 4.2BSD
  292. .Df libbsd42
  293. (\c
  294. .B libbsd42 );
  295. System III and System V
  296. .Ix Unix "System III"
  297. .Ix Unix "System V"
  298. .Df libusg
  299. (\c
  300. .B libusg ).
  301. .I fclsexec
  302. sets the close-on-exec flag
  303. for a given
  304. .I stdio
  305. stream.
  306. .I fopenexcl
  307. performs an ``exclusive create'' open:
  308. the open fails if the file already exists.
  309. .SH
  310. Address-space-size-specific libraries
  311. .LP
  312. These libraries provide alternate versions of the
  313. .Ix active
  314. .Ix files active
  315. .Ix sys
  316. .Ix files sys
  317. .B active
  318. and
  319. .B sys
  320. file code:
  321. .Df libsmall
  322. .B libsmall
  323. should work on any machine,
  324. but is suboptimally fast;
  325. .B libbig
  326. .Df libbig
  327. has worked even on PDP-11s,
  328. .Ix machines PDP-11
  329. and is quite fast,
  330. but consumes memory without apology.
  331. .SH
  332. Include files
  333. .LP
  334. .B libh
  335. .Df libh
  336. contains include files
  337. unique to C news.
  338. .B news.h
  339. .Df news.h
  340. .Df files news.h
  341. defines a few limits,
  342. some file names,
  343. some types
  344. (\c
  345. .B boolean
  346. and
  347. .B statust ),
  348. some characters,
  349. some status bits,
  350. some macros for speed,
  351. and
  352. declares functions in
  353. .B libcnews
  354. or miscellaneous functions in
  355. .I relaynews
  356. (oops!).
  357. .Df config.h
  358. .Df files config.h
  359. .B config.h
  360. declares the pathname functions in
  361. .B libcnews .
  362. .Df fgetmfs.h
  363. .Df files fgetmfs.h
  364. .B fgetmfs.h
  365. declares symbolic values and macros for using
  366. .B fgetmfs .
  367. .Df libc.h
  368. .Df files libc.h
  369. .B libc.h
  370. is a start at a V9-like declaration of all of the C library.
  371. .Df memlist.h
  372. .Df files memlist.h
  373. .B memlist.h
  374. defines the interface to
  375. .B memlist .
  376. .LP
  377. .Df hfake
  378. .Df files hfake
  379. .B hfake
  380. contains a few include files that your system ought to have but might not.
  381. .Df stdlib.h
  382. .Df files stdlib.h
  383. .B stdlib.h
  384. is a degenerate ANSI
  385. .B stdlib.h .
  386. .Df string.h
  387. .Df files string.h
  388. .B string.h
  389. declares the string functions.
  390. .Df timeb.h
  391. .Df files timeb.h
  392. .B timeb.h
  393. declares the structure used by
  394. .I ftime .
  395.