getbootpent man page on HP-UX

Man page or keyword search:  
man Server   10987 pages
apropos Keyword Search (all sections)
Output format
HP-UX logo
[printable version]

getbootpent(3X)						       getbootpent(3X)

       getbootpent(),	  putbootpent(),     setbootpent(),	endbootpent(),
       parse_bp_htype(),  parse_bp_haddr(),  parse_bp_iaddr()  -  get  or  put
       bootptab entry

       These  functions	 reside in libdc.a, and are linked using the option to
       the or command.

       These functions help a program read or modify a bootptab control)  file
       one  entry  at  a  time.	 locates an entry in the file, or an alternate
       file specified to and returns a pointer to an array of objects of  type
       that  breaks  the  entry	 into  separate data fields with preceding, or
       embedded, comment (text) lines.

       The structure is defined in and includes the following members:

       The file also defines the following data type and constants:

       The fields are described in the section below.	The  purpose  of  each
       function is as follows.

       When first called,	returns	 a  pointer to, and the number of ele‐
				ments in, an array of structures.   The	 array
				holds  the first entry in the file (or from an
				alternate file specified by a call to  includ‐
				ing leading, or embedded, comment lines.  Each
				subsequent call returns a pointer to the  next
				entry in the file so that successive calls can
				be used to search the entire file.

				If no file is currently in memory,  reads  the
				file prior to doing its work.

				The  returned  array  exists  in  static space
				(malloc'd memory) overwritten by the next call
				(so   previously   returned   pointers	become
				invalid).   However,  each   array   element's
				pointer points to text in an in-memory copy of
				the file.  This text is	 not  altered  by  the
				next call (nor by changes to the file itself).
				Hence, it is possible to copy an entry's array
				in  order to save it, as illustrated in below.
				The data remains valid until the next call  of

				If  there  are	comments after the last entry,
				they are returned as a separate entry with  no
				data parts.

       Opens the specified file for reading by
				reads  a copy into memory, and closes the file
				(which as a side-effect releases any locks  on
				the file; see lockf(2)).  If the given path is
				a null pointer or a  null  string,  opens  and

				If  the	 last file opened by (or implicitly by
				was a subsequent call to  for  the  same  file
				rewinds the file to the beginning, making vis‐
				ible any recent changes to the	file,  without
				first requiring a call to

       Frees the in-memory copy of the last file opened by

       Writes (to the current location in the stream specified by
				bootpfile)  the ASCII equivalent of the speci‐
				fied array of structures containing  one  file
				entry,	and its leading, or embedded, comments
				(a  total  of	numfields   array   elements).
				Entries are written in canonical form, meaning
				the entry name and each data field are on sep‐
				arate  lines,  data fields are preceded by one
				tab each, and each line except the  last  ends
				with  ``:\''.	If  numfields  is less than or
				equal to zero, nothing is written.

       Converts a host address type from string to numeric format
				in the same manner as

       Converts a host (hardware, link level) address from  string  to	binary
				in  the	 same  manner  as given a host address
				type The calling program's result, which  must
				be  an	array containing at least elements, is
				modified  to  hold  the	 host  address	binary
				value,	and is modified to indicate the length
				in bytes of the resulting address.   This  can
				be  used  to compare two host addresses, inde‐
				pendent of string representations.  source  is
				modified  to point to the first char after the
				parsed address.

       Converts an internet address from string to binary format in  the  same
       manner as
				This  can  be  used  to	 compare  two internet
				addresses, independent of  string  representa‐
				tions.	 The calling program's result is modi‐
				fied  to  hold	the  internet  address	binary
				value.	 source	 is  modified  to point to the
				first char after the parsed address.

   Field Definitions
       If is the associated text is one field from the current	entry,	either
       the  name  field or one of the tag fields.  Null tag fields (two colons
       in a row) are ignored, not returned.

       If is or the associated text is one comment line or blank line from the
       file,  either preceding the current entry or embedded in it following a
       data line that was continued with a backslash.  The text is exactly  as
       it  appears  in the file, including any whitespace appearing on a blank
       line, and there is no trailing newline.

       The returned array elements are in the same order as  data  fields  and
       comment lines appear in the file.

       Entry field strings are of the form:

       with  surrounding  whitespace,  if any, removed (see bootpd(1M) for the
       full description).  Double quotes, and backslashes, can appear anywhere
       in the field strings.

       Template	 entries (those referred to by other entries using fields) are
       not special.  They can be managed like other entries.  It is the	 call‐
       ing  program's  responsibility to correctly manage the order of fields,
       fields, and ``@'' fields that override earlier field values.

       returns the number of valid array elements (one or more) upon  success‐
       ful  completion.	  At the end of the input file it returns zero.	 If it
       cannot open or close the file it returns -1.  If it encounters a memory
       allocation or map error, or a read error, it returns -2.

       returns zero if successful opening and reading the specified or default
       file.  If it cannot open or close  the  file  it	 returns  -1.	If  it
       encounters  a memory allocation or map error or a read error it returns

       returns zero if successful freeing the  memory  for  the	 current  open
       file.   If  there  is no current file it returns -1.  If it cannot free
       the memory for the current file it returns -2.

       returns zero if successful writing an entry to the specified file, with
       the  indication	clear (see ferror(3S)).	 Otherwise it returns non-zero
       with set.

       In all cases above, if a failure is due to a failed  system  call,  the
       value from the system is valid on return from the called function.

       returns if the hardware type string is unrecognized.

       returns	zero  if  successful,  otherwise  non-zero  in case of parsing
       error, invalid htype, or a host address	type  for  which  the  address
       length  is  unknown;  source  is modified to point to the first illegal
       char (a NUL if the string is too short).	 The caller's bytes  value  is
       unmodified, but result might be changed.

       returns	zero if successful, otherwise non-zero, and source is modified
       to point to the first illegal char (a NUL if the string is null).

       The following code fragment copies all data and comments from to a tem‐
       porary copy of the file.	 It converts data entries to canonical form as
       a side effect, and prints to standard output the first  field  of  each
       entry  copied  (should  be  the	field name, assuming the entry doesn't
       start with a continuation line).

	      #include <bootpent.h>

	      FILE *newfilep;	/* to write temp file */
	      bpp_t bp;		/* read from file */
	      int field;	/* current field number */
	      int fields;	/* total in array for one entry */

	      if ((newfilep = fopen ("/tmp/bootptab", "w")) == (FILE *) NULL)
		  (handle error)

	      while ((fields = getbootpent (&bp)) > 0)
		  for (field = 0; field < fields; ++field)
		      if ((bp[field].bp_type) == BP_DATA)
			  (void) puts (bp[field].bp_text);

		  if (putbootpent (bp, fields, newfilep))
		      (handle error)

	      if (fields < 0)	 /* error reading file */
		  (handle error)

	      if (endbootpent())
		  (handle error)

	      if (fclose (newfilep))
		  (handle error)

       The following code fragment saves a copy of a bootptab  entry  returned

	      #include <malloc.h>
	      #include <string.h>
	      #include <bootpent.h>

	      bpp_t bpnew;
	      unsigned size;

	      size = fields *BP_SIZE;

	      if ((bpnew = (bpp_t) malloc (size)) == BP_NULLP)
		  (handle error)

	      (void) memcpy ((void *)bpnew, (void *)bp, size);

       These functions are unsafe in multi-thread applications.

       Calling releases any locks on the file it opens.

       These functions were developed by HP.

       control file for

       bootpd(1M), errno(2), lockf(2), ferror(3S), fopen(3S), malloc(3C).


List of man pages available for HP-UX

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
Vote for polarhome
Free Shell Accounts :: the biggest list on the net