#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;
string yes_or_No(string value)
{
if(value=="1")
return "YES";
else
return "NO";
}
FILE* cd_FILE;
char buff_FILE[11][1024];
char **scanf_mat;
struct CD
{
string drive_name;
string drive_speed;
string open_tray;
string close_tray;
string lock_tray;
string write_cd_r;
string write_cd_rw;
string read_dvd;
string write_dvd_r;
string write_dvd_ram;
string select_disk;
};
size_t x_read[11];
int main(int argc, char **argv)
{
int i;
char d_Name[11][24];
struct CD cd_Info;
scanf_mat=new char*[11];
for(i=0;i<11;i++)
{
scanf_mat[i]=new char[1024];
}
for(i=0;i<11;i++)
{
cd_FILE=fopen("/proc/sys/dev/cdrom/info","r");
x_read[i]=fread(buff_FILE[i],1,sizeof(buff_FILE[i]),cd_FILE);
fclose(cd_FILE);
}
for(i=0;i<11;i++)
buff_FILE[i][x_read[i]]='\0';
scanf_mat[0]=strstr(buff_FILE[0],"drive name");
sscanf(scanf_mat[0],"drive name: %s",d_Name[0]);
cd_Info.drive_name=d_Name[0];
scanf_mat[1]=strstr(buff_FILE[1],"drive speed");
sscanf(scanf_mat[1],"drive speed: %s",d_Name[1]);
cd_Info.drive_speed=d_Name[1];
scanf_mat[2]=strstr(buff_FILE[2],"Can open tray");
sscanf(scanf_mat[2],"Can open tray: %s",d_Name[2]);
cd_Info.open_tray=yes_or_No(d_Name[2]);
scanf_mat[3]=strstr(buff_FILE[3],"Can close tray");
sscanf(scanf_mat[3],"Can close tray: %s",d_Name[3]);
cd_Info.close_tray=yes_or_No(d_Name[3]);
scanf_mat[4]=strstr(buff_FILE[4],"Can lock tray");
sscanf(scanf_mat[4],"Can lock tray: %s",d_Name[4]);
cd_Info.lock_tray=yes_or_No(d_Name[4]);
scanf_mat[5]=strstr(buff_FILE[5],"Can write CD-R");
sscanf(scanf_mat[5],"Can write CD-R: %s",d_Name[5]);
cd_Info.write_cd_r=yes_or_No(d_Name[5]);
scanf_mat[6]=strstr(buff_FILE[6],"Can write CD-RW");
sscanf(scanf_mat[6],"Can write CD-RW: %s",d_Name[6]);
cd_Info.write_cd_rw=yes_or_No(d_Name[6]);
scanf_mat[7]=strstr(buff_FILE[7],"Can read DVD");
sscanf(scanf_mat[7],"Can read DVD: %s",d_Name[7]);
cd_Info.read_dvd=yes_or_No(d_Name[7]);
scanf_mat[8]=strstr(buff_FILE[8],"Can write DVD-R");
sscanf(scanf_mat[8],"Can write DVD-R: %s",d_Name[8]);
cd_Info.write_dvd_r=yes_or_No(d_Name[8]);
scanf_mat[9]=strstr(buff_FILE[9],"Can write DVD-RAM");
sscanf(scanf_mat[9],"Can write DVD-RAM: %s",d_Name[9]);
cd_Info.write_dvd_ram=yes_or_No(d_Name[9]);
scanf_mat[10]=strstr(buff_FILE[10],"Can select disk");
sscanf(scanf_mat[10],"Can select disk: %s",d_Name[10]);
cd_Info.select_disk=yes_or_No(d_Name[10]);
cout<<"Name: "<<cd_Info.drive_name<<endl;
cout<<"Speed: "<<cd_Info.drive_speed<<endl;
cout<<"Can open tray: "<<cd_Info.open_tray<<endl;
cout<<"Can close tray: "<<cd_Info.close_tray<<endl;
cout<<"Can lock tray: "<<cd_Info.lock_tray<<endl;
cout<<"Can write CD-R: "<<cd_Info.write_cd_r<<endl;
cout<<"Can write CD-RW: "<<cd_Info.write_cd_rw<<endl;
cout<<"Can read DVD: "<<cd_Info.read_dvd<<endl;
cout<<"Can write DVD-R: "<<cd_Info.write_dvd_r<<endl;
cout<<"Can write DVD-RAM: "<<cd_Info.write_dvd_ram<<endl;
cout<<"Can select disk: "<<cd_Info.select_disk<<endl;
return 0;
}
Brak komentarzy:
Prześlij komentarz