libhd 5.0
Data Structures | Defines | Typedefs | Enumerations | Functions | Variables

dvd.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/cdrom.h>
#include <errno.h>
#include <string.h>
#include <mntent.h>
#include <sys/wait.h>
#include <sys/utsname.h>
#include <scsi/scsi.h>
#include <scsi/sg.h>
#include <poll.h>
#include <sys/time.h>
#include "dvd.h"

Data Structures

struct  ScsiCommand

Defines

#define CREAM_ON_ERRNO(s)
#define ERRCODE(s)   ((((s)[2]&0x0F)<<16)|((s)[12]<<8)|((s)[13]))
#define SK(errcode)   (((errcode)>>16)&0xF)
#define ASC(errcode)   (((errcode)>>8)&0xFF)
#define ASCQ(errcode)   ((errcode)&0xFF)
#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
#define _FILE_OFFSET_BITS   64
#define _GNU_SOURCE
#define SG_FLAG_LUN_INHIBIT   0
#define DIRECTION(i)   (Dir_xlate[i]);

Typedefs

typedef struct ScsiCommand ScsiCommand

Enumerations

enum  Direction { NONE = CGC_DATA_NONE, READ = CGC_DATA_READ, WRITE = CGC_DATA_WRITE }

Functions

static ScsiCommandscsi_command_new (void)
static ScsiCommandscsi_command_new_from_fd (int f)
static void scsi_command_free (ScsiCommand *cmd)
static int scsi_command_transport (ScsiCommand *cmd, Direction dir, void *buf, size_t sz)
static void scsi_command_init (ScsiCommand *cmd, size_t i, int arg)
int get_dvd_profile (int fd)

Variables

const int Dir_xlate [4]

Define Documentation

#define _FILE_OFFSET_BITS   64
#define _GNU_SOURCE
#define _LARGEFILE64_SOURCE
#define _LARGEFILE_SOURCE
#define ASC (   errcode)    (((errcode)>>8)&0xFF)
#define ASCQ (   errcode)    ((errcode)&0xFF)
#define CREAM_ON_ERRNO (   s)
Value:
do {                            \
    switch ((s)[2]&0x0F)                                        \
    {   case 2: if ((s)[12]==4) errno=EAGAIN;   break;          \
        case 5: errno=EINVAL;                                   \
                if ((s)[13]==0)                                 \
                {   if ((s)[12]==0x21)          errno=ENOSPC;   \
                    else if ((s)[12]==0x20)     errno=ENODEV;   \
                }                                               \
                break;                                          \
    }                                                           \
} while(0)

Referenced by scsi_command_transport().

#define DIRECTION (   i)    (Dir_xlate[i]);

Referenced by scsi_command_transport().

#define ERRCODE (   s)    ((((s)[2]&0x0F)<<16)|((s)[12]<<8)|((s)[13]))

Referenced by scsi_command_transport().

#define SG_FLAG_LUN_INHIBIT   0

Referenced by scsi_command_init().

#define SK (   errcode)    (((errcode)>>16)&0xF)

Typedef Documentation

typedef struct ScsiCommand ScsiCommand

Enumeration Type Documentation

enum Direction
Enumerator:
NONE 
READ 
WRITE 

Function Documentation

int get_dvd_profile ( int  fd)
static void scsi_command_free ( ScsiCommand cmd) [static]
static void scsi_command_init ( ScsiCommand cmd,
size_t  i,
int  arg 
) [static]
static ScsiCommand* scsi_command_new ( void  ) [static]
static ScsiCommand* scsi_command_new_from_fd ( int  f) [static]
static int scsi_command_transport ( ScsiCommand cmd,
Direction  dir,
void *  buf,
size_t  sz 
) [static]

Variable Documentation

const int Dir_xlate[4]
Initial value:
 {
        0,                      
        SG_DXFER_TO_DEV,        
        SG_DXFER_FROM_DEV,      
        SG_DXFER_NONE           
}