-->

Previous | Table of Contents | Next

Page 905

getserverbyfile calls GetConfigValue to get the name of the local NNTP server. It returns a pointer to static space. The file parameter is ignored.

server_init opens a connect to the NNTP server at the specified host. It returns the server's response code or _1 on error. If a connection was made, ser_rd_fp and ser_wr_fp can be used to read from and write to the server, respectively, and ser_line will contain the server's response. ser_line can also be used in other routines.

handle_server_response decodes the response, which comes from the server on host. If the client is authorized, it returns 0. A client that is only allowed to read is authorized, but handle_server_response will print a message on the standard output. If the client is not authorized to talk to the server, a message is printed, and the routine returns _1.

put_server sends the text in buff to the server, adding the necessary NNTP line terminators and flushing the I/O buffer.

get_server reads a line of text from the server into buff, reading at most buffsize characters. Any trailing \r\n terminators are stripped off. get_server returns _1 on error.

close_server sends a quit command to the server and closes the connection.

HISTORY

Written by Rich $alz (rsalz@uunet.uu.net) for InterNetNews.

SEE ALSO


libinn(3)

clock

clock—Determine processor time

SYNOPSIS


#include <time.h>

clock_t clock(void);

DESCRIPTION

The clock() function returns an approximation of processor time used by the program.

RETURN VALUE

The value returned is the CPU time used so far as a clock_t; to get the number of seconds used, divide by CLOCKS_PER_SEC.

CONFORMS TO

ANSI C

BUGS

The C standard allows for arbitrary values at the start of the program; take the difference between the value returned from a call to clock() at the start of the program and the value returned at the end for maximum portability.

The times() function call returns more information.

SEE ALSO


times(2)

GNU, 21 April 1993

closedir

closedir—Close a directory

Page 906

SYNOPSIS


#include <sys/types.h>

#include <dirent.h>

int closedir(DIR *dir);

DESCRIPTION

The closedir() function closes the directory stream associated with dir. The directory stream descriptor dir is not available after this call.

RETURN VALUE

The closedir() function returns 0 on success or _1 on failure.

ERRORS

EBADF Invalid directory stream descriptor dir.

CONFORMS TO

SVID 3, POSIX, BSD 4.3

SEE ALSO


close(2), opendir(3), readdir(3), rewinddir(3),

seekdir(3), telldir(3), scandir(3)

11 June 1995

confstr

confstr—Get configuration-dependent string variables

SYNOPSIS


#define __USE_POSIX_2

#include <unistd.h>

size_t confstr(int name, char *buf, size_t len);

DESCRIPTION

confstr() gets the value of configuration-dependent string variables.

The name argument is the system variable to be queried. The following variables are supported:

CS_PATH A value for the PATH variable that indicates where all the POSIX.2 standard utilities can be found.

If buf is not NULL, and len is not 0, confstr() copies the value of the string to buf truncated to len_1 characters if necessary, with a null character as termination. This can be detected by comparing the return value of confstr() against len.

If len is 0 and buf is NULL, confstr() just returns the value in Return Value.

RETURN VALUE

If name does not correspond to a valid configuration variable, confstr() returns 0.

EXAMPLES

The following code fragment determines the path where you can find the POSIX.2 system utilities:


char *pathbuf; size_t n;

n = confstr(_CS_PATH,NULL,(size_t)0);

if ((pathbuf = malloc(n)) == NULL) abort();

confstr(_CS_PATH, pathbuf, n);

Page 907

ERRORS

If the value of name is invalid, errno is set to EINVAL.

CONFORMS TO

Proposed POSIX.2

BUGS

POSIX.2 is not yet an approved standard; the information in this man page is subject to change.

SEE ALSO


sh(1), exec(2), system(3)

GNU, 17 April 1993

copysign

copysign—Copies the sign of a number

SYNOPSIS


#include <math.h>

double copysign(double x, double y);

DESCRIPTION

The copysign() function returns a value whose absolute value matches x, but whose sign matches that of y.

CONFORMS TO

BSD 4.3

GNU, 6 June 1993

cos

cos—Cosine function

SYNOPSIS


#include <math.h>

double cos(double x);

DESCRIPTION

The cos() function returns the cosine of x, where x is given in radians.

RETURN VALUE

The cos() function returns a value between _1 and 1.

CONFORMS TO

SVID 3, POSIX, BSD 4.3, ISO 9899

SEE ALSO


acos(3), asin(3), atan(3), atan2(3), sin(3), tan(3)

8 June 1993

Page 908

cosh

cosh—Hyperbolic cosine function

SYNOPSIS


#include <math.h>

double cosh(double x);

DESCRIPTION

The cosh() function returns the hyperbolic cosine of x, which is defined mathematically as(exp(x)+exp(-x))/2.

CONFORMS TO

SVID 3, POSIX, BSD 4.3, ISO 9899

SEE ALSO


acosh(3), asinh(3), atanh(3), sinh(3), tanh(3)

13 June 1993

crypt

crypt—Password and data encryption

SYNOPSIS


#include <unistd.h>

char *crypt(const char *key, const char *salt);

DESCRIPTION

crypt is the password-encryption function. It is based on the Data Encryption Standard algorithm, with variations intended (among other things) to discourage the use of hardware implementations of a key search.

key is a user's typed password.

salt is a two-character string chosen from the set [a-zA-Z0-9./]. This string is used to perturb the algorithm in one of 4,096 different ways.

By taking the lowest seven bits of each character of the key, a 56-bit key is obtained. This 56-bit key is used to repeatedly encrypt a constant string (usually a string consisting of all 0s). The returned value points to the encrypted password, a series of 13 printable ASCII characters (with the first two characters representing the salt itself). The return value points to static data whose content is overwritten by each call.

Warning: The key space consists of equal 7.2e16 possible values. Exhaustive searches of this key space are possible using massively parallel computers. Software, such as crack(1), is available to search the portion of this key space that is generally used by humans for passwords. Hence, password selection should, at minimum, avoid common words and names. Using a passwd(1) program that checks for crackable passwords during the selection process is recommended.

The DES algorithm itself has a few quirks that make using the crypt(3) interface a very poor choice for anything other than password authentication. If you are planning to use the crypt(3) interface for a cryptography project, don't do it; get a good book on encryption and one of the widely available DES libraries instead.

CONFORMS TO

SVID, X/OPEN, BSD 4.3

Previous | Table of Contents | Next