Laboratories/Lab11/send_mail.c
ssize_t read_line(int sockd, void *vptr, size_t maxlen)
{
    ssize_t n, rc;
    char c, *buffer;

    buffer = vptr;

    for (n = 1; n < maxlen; n++) {
        if ((rc = read(sockd, &c, 1)) == 1) {
            *buffer++ = c;

            if (c == '\n') {
                break;
            }
        } else if (rc == 0) {
            if (n == 1) {
                return 0;
            } else {
                break;
            }
        } else {
            if (errno == EINTR) {
                continue;
            }

            return -1;
        }
    }

    *buffer = 0;
    return n;
}
/**
 * Citeste maxim maxlen octeti de pe socket-ul sockfd in
 * buffer-ul vptr. Intoarce numarul de octeti cititi.
 */
Citeste maxim maxlen octeti de pe socket-ul sockfd in
buffer-ul vptr. Intoarce numarul de octeti cititi.
Citeste maxim maxlen octeti de pe socket - ul sockfd in buffer - ul vptr . Intoarce numarul de octeti cititi .
ssize_t read_line(int sockd, void *vptr, size_t maxlen)
{
    ssize_t n, rc;
    char c, *buffer;
    buffer = vptr;
    for (n = 1; n < maxlen; n++) {
        if ((rc = read(sockd, &c, 1)) == 1) {
            *buffer++ = c;
            if (c == '\n') {
                break;
            }
        } else if (rc == 0) {
            if (n == 1) {
                return 0;
            } else {
                break;
            }
        } else {
            if (errno == EINTR) {
                continue;
            }
            return -1;
        }
    }
    *buffer = 0;
    return n;
}
ssize_t read_line ( int sockd , void * vptr , size_t maxlen ) { ssize_t n , rc ; char c , * buffer ; buffer = vptr ; for ( n = 1 ; n < maxlen ; n ++ ) { if ( ( rc = read ( sockd , & c , 1 ) ) == 1 ) { * buffer ++ = c ; if ( c == ' \n ' ) { break ; } } else if ( rc == 0 ) { if ( n == 1 ) { return 0 ; } else { break ; } } else { if ( errno == EINTR ) { continue ; } return -1 ; } } * buffer = 0 ; return n ; }
Citeste maxim maxlen octeti de pe socket-ul sockfd in
 buffer-ul vptr.
Citeste maxim maxlen octeti de pe socket - ul sockfd in buffer - ul vptr .