Browse Source

add a few man pages

master
Felix von Leitner 17 years ago
parent
commit
cc8b30ba1d
12 changed files with 153 additions and 7 deletions
  1. +1
    -1
      fmt/fmt_long.3
  2. +20
    -0
      fmt/fmt_longlong.3
  3. +20
    -0
      fmt/fmt_ulonglong.3
  4. +21
    -0
      fmt/fmt_xlonglong.3
  5. +9
    -5
      open.h
  6. +14
    -0
      open/open_rw.3
  7. +11
    -0
      open/open_rw.c
  8. +1
    -1
      scan/scan_longlong.3
  9. +13
    -0
      scan/scan_short.3
  10. +13
    -0
      scan/scan_ulonglong.3
  11. +17
    -0
      scan/scan_xlonglong.3
  12. +13
    -0
      scan/scan_xlonglong.c

+ 1
- 1
fmt/fmt_long.3 View File

@ -4,7 +4,7 @@ fmt_long \- write an ASCII representation of a long integer
.SH SYNTAX
.B #include <fmt.h>
unsigned int \fBfmt_long\fP(char *\fIdest\fR,unsigned int \fIsource\fR);
unsigned int \fBfmt_long\fP(char *\fIdest\fR,long \fIsource\fR);
.SH DESCRIPTION
fmt_long writes an ASCII representation ('-' and '0' to '9', base 10) of
\fIsource\fR to \fIdest\fR and returns the number of bytes written.


+ 20
- 0
fmt/fmt_longlong.3 View File

@ -0,0 +1,20 @@
.TH fmt_longlong 3
.SH NAME
fmt_longlong \- write an ASCII representation of a long long integer
.SH SYNTAX
.B #include <fmt.h>
unsigned int \fBfmt_longlong\fP(char *\fIdest\fR,long long \fIsource\fR);
.SH DESCRIPTION
fmt_longlong writes an ASCII representation ('-' and '0' to '9', base 10) of
\fIsource\fR to \fIdest\fR and returns the number of bytes written.
fmt_longlong does not append \\0.
If \fIdest\fR equals FMT_LEN (i.e. is zero), fmt_longlong returns the number
of bytes it would have written.
For convenience, fmt.h defines the integer FMT_LONG to be big enough to
contain every possible fmt_longlong output plus \\0.
.SH "SEE ALSO"
scan_longlong(3)

+ 20
- 0
fmt/fmt_ulonglong.3 View File

@ -0,0 +1,20 @@
.TH fmt_ulonglong 3
.SH NAME
fmt_ulonglong \- write an ASCII representation of an unsigned long long integer
.SH SYNTAX
.B #include <fmt.h>
unsigned int \fBfmt_ulonglong\fP(char *\fIdest\fR,unsigned long long \fIsource\fR);
.SH DESCRIPTION
fmt_ulonglong writes an ASCII representation ('0' to '9', base 10) of
\fIsource\fR to \fIdest\fR and returns the number of bytes written.
fmt_ulonglong does not append \\0.
If \fIdest\fR equals FMT_LEN (i.e. is zero), fmt_ulonglong returns the
number of bytes it would have written.
For convenience, fmt.h defines the integer FMT_ULONG to be big enough to
contain every possible fmt_ulonglong output plus \\0.
.SH "SEE ALSO"
scan_ulonglong(3)

+ 21
- 0
fmt/fmt_xlonglong.3 View File

@ -0,0 +1,21 @@
.TH fmt_xlonglong 3
.SH NAME
fmt_xlonglong \- write a hexadecimal ASCII representation of an unsigned long long integer
.SH SYNTAX
.B #include <fmt.h>
unsigned int \fBfmt_xlonglong\fP(char *\fIdest\fR,unsigned long long \fIsource\fR);
.SH DESCRIPTION
fmt_xlonglong writes an ASCII representation ('0' to '9' and 'a' to 'f',
base 16) of \fIsource\fR to \fIdest\fR and returns the number of bytes
written.
fmt_xlonglong does not append \\0.
If \fIdest\fR equals FMT_LEN (i.e. is zero), fmt_xlonglong returns the
number of bytes it would have written.
For convenience, fmt.h defines the integer FMT_XLONG to be big enough to
contain every possible fmt_xlonglong output plus \\0.
.SH "SEE ALSO"
scan_xlonglong(3)

+ 9
- 5
open.h View File

@ -2,26 +2,30 @@
#define OPEN_H
/* open filename for reading and return the file handle or -1 on error */
int open_read(const char *filename);
int open_read(const char* filename);
/* create filename for exclusive write only use (mode 0600) and return
* the file handle or -1 on error */
int open_excl(const char *filename);
int open_excl(const char* filename);
/* open filename for appending write only use (mode 0600)
* and return the file handle or -1 on error.
* All write operation will append after the last byte, regardless of
* seeking or other processes also appending to the file. The file will
* be created if it does not exist. */
int open_append(const char *filename);
int open_append(const char* filename);
/* open filename for writing (mode 0644). Create the file if it does
* not exist, truncate it to zero length otherwise. Return the file
* handle or -1 on error. */
int open_trunc(const char *filename);
int open_trunc(const char* filename);
/* open filename for writing. Create the file if it does not exist.
* Return the file handle or -1 on error. */
int open_write(const char *filename);
int open_write(const char* filename);
/* open filename for reading and writing. Create file if not there.
* Return file handle or -1 on error. */
int open_rw(const char* filename);
#endif

+ 14
- 0
open/open_rw.3 View File

@ -0,0 +1,14 @@
.TH open_rw 3
.SH NAME
open_rw \- open a file for reading and writing
.SH SYNTAX
.B #include <open.h>
extern int \fBopen_rw\fP(const char *\fIfilename\fR);
.SH DESCRIPTION
open_rw opens the file \fIfilename\fR for reading and writing use and
returns the file handle. If the file does not exist, it will be created
with mode 0644. If there was an error opening or creating the file,
open_rw returns -1 and sets errno accordingly.
.SH "SEE ALSO"
open(2)

+ 11
- 0
open/open_rw.c View File

@ -0,0 +1,11 @@
#include <unistd.h>
#include <fcntl.h>
#include "open.h"
#ifndef O_NDELAY
#define O_NDELAY 0
#endif
int open_rw(const char *filename) {
return open(filename,O_RDWR|O_CREAT|O_NDELAY,0644);
}

+ 1
- 1
scan/scan_longlong.3 View File

@ -1,6 +1,6 @@
.TH scan_longlong 3
.SH NAME
scan_longlong \- parse an long integer in decimal ASCII representation
scan_longlong \- parse a long integer in decimal ASCII representation
.SH SYNTAX
.B #include <scan.h>


+ 13
- 0
scan/scan_short.3 View File

@ -0,0 +1,13 @@
.TH scan_short 3
.SH NAME
scan_short \- parse an integer in decimal ASCII representation
.SH SYNTAX
.B #include <scan.h>
int \fBscan_short\fP(const char *\fIsrc\fR,short int *\fIdest\fR);
.SH DESCRIPTION
scan_short parses a short integer in decimal ASCII representation
from \fIsrc\fR and writes the result into \fIdest\fR. It returns the
number of bytes read from \fIsrc\fR.
.SH "SEE ALSO"
scan_int(3), scan_ushort(3), scan_xshort(3), scan_8short(3), fmt_short(3)

+ 13
- 0
scan/scan_ulonglong.3 View File

@ -0,0 +1,13 @@
.TH scan_ulonglong 3
.SH NAME
scan_ulonglong \- parse an unsigned long integer in decimal ASCII representation
.SH SYNTAX
.B #include <scan.h>
int \fBscan_ulonglong\fP(const char *\fIsrc\fR,unsigned long long *\fIdest\fR);
.SH DESCRIPTION
scan_ulonglong parses an unsigned long long integer in decimal ASCII representation
from \fIsrc\fR and writes the result into \fIdest\fR. It returns the
number of bytes read from \fIsrc\fR.
.SH "SEE ALSO"
scan_longlong(3), fmt_ulonglong(3)

+ 17
- 0
scan/scan_xlonglong.3 View File

@ -0,0 +1,17 @@
.TH scan_xlonglong 3
.SH NAME
scan_xlonglong \- parse an unsigned long long integer in hexadecimal ASCII representation
.SH SYNTAX
.B #include <scan.h>
int \fBscan_xlonglong\fP(const char *\fIsrc\fR,unsigned long long* \fIdest\fR);
.SH DESCRIPTION
scan_xlonglong parses an unsigned long long integer in hexadecimal ASCII
representation from \fIsrc\fR and writes the result into \fIdest\fR. It
returns the number of bytes read from \fIsrc\fR.
scan_xlonglong understands both upper and lower case letters.
scan_xlonglong does not expect or understand a "0x" prefix.
.SH "SEE ALSO"
fmt_xlonglong(3)

+ 13
- 0
scan/scan_xlonglong.c View File

@ -0,0 +1,13 @@
#include "scan.h"
unsigned int scan_xlonglong(const char* src,unsigned long long* dest) {
register const char *tmp=src;
register int l=0;
register unsigned char c;
while ((c=scan_fromhex(*tmp))<16) {
l=(l<<4)+c;
++tmp;
}
*dest=l;
return tmp-src;
}

Loading…
Cancel
Save