#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
class info_Crypto
{
private:
char name[64];
char driver[64];
char module[64];
FILE *temp_File;
int priority;
int blocksize;
int digestsize;
bool is_End(size_t temp_size, char *temp_buffer)
{
if(temp_size==0 || temp_size==sizeof(temp_buffer))
return true;
else
return false;
}
int exit()
{
return 1;
}
char end;
public:
info_Crypto()
{
end='\0';
size_t s_read;
char *text_name;
char *text_priority;
char *text_driver;
char *text_blocksize;
char *text_digestsize;;
char *text_module;
char temp_Buffer[1024];
temp_File=fopen("/proc/crypto","r");
s_read=fread(temp_Buffer,1,sizeof(temp_Buffer),temp_File);
fclose(temp_File);
if(is_End(s_read,temp_Buffer))
exit();
temp_Buffer[s_read]=end;
text_name=strstr(temp_Buffer,"name");
sscanf(text_name,"name : %s",name);
text_priority=strstr(temp_Buffer,"priority");
sscanf(text_priority,"priority : %d",&priority);
text_driver=strstr(temp_Buffer,"driver");
sscanf(text_driver,"driver : %s",driver);
text_blocksize=strstr(temp_Buffer,"blocksize");
sscanf(text_blocksize,"blocksize : %d",&blocksize);
text_digestsize=strstr(temp_Buffer,"digestsize");
sscanf(text_digestsize,"digestsize : %d",&digestsize);
text_module=strstr(temp_Buffer,"module");
sscanf(text_module,"module : %s",module);
}
char *Name()
{
return name;
}
int Priority()
{
return priority;
}
char *Driver()
{
return driver;
}
int Blocksize()
{
return blocksize;
}
int Digestsize()
{
return digestsize;
}
char *Module()
{
return module;
}
};
int main(int argc, char **argv)
{
info_Crypto iC;
cout<<"name: "<<iC.Name()<<endl;
cout<<"driver: "<<iC.Driver()<<endl;
cout<<"module: "<<iC.Module()<<endl;
cout<<"priority: "<<iC.Priority()<<endl;
cout<<"blocksize: "<<iC.Blocksize()<<endl;
cout<<"digestsize: "<<iC.Digestsize()<<endl;
cout<<endl;
return 0;
}
Brak komentarzy:
Prześlij komentarz