77范文网 - 专业文章范例文档资料分享平台

IDA简易教程(10)

来源:网络收集 时间:2019-08-28 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

// and we sell computer softwares

struct software_info_t { // a structure containing various bitfields

unsigned int plateform : 2; // 2 bits reserved for the plateform - plateforms can be combined (0x03) #define PC 0x1 // 0x01 #define MAC 0x2 // 0x02

unsigned int os : 3; // 3 bits reserved for the OS - OS can be combined (0x1C) #define WINDOWS 0x1 // 0x04 #define DOS 0x2 // 0x08 #define OS_X 0x4 // 0x10

unsigned int category : 2; // 2 bits reserved for the category - categories can't be combined (0x60)

#define DISASSEMBLY 0x1 // 0x20 #define RECOVERY 0x2 // 0x40 #define CRYPTOGRAPHY 0x3 // 0x60 };

struct software_t { software_info_t info; char name[32]; };

struct softwares_t { // a variable length structure to memorize our softwares long count; software_t softs[]; };

// generic products we're selling

enum product_category_t { // an enumerated type BOOK,

SOFTWARE,

HARDWARE // we actually don't sell hardware };

union product_u { // an union to contain product information depending on its category book_t book; software_t software;

// struct hardware_t hardware; // we actually don't sell hardware };

struct product_t { // a structure containing another structure long id;

product_category_t category; product_u p; };

// our data // ======== // our customers

customer_t customers[] = { // an initialized array to memorize our customers { 1, \ { 2, \ { 3, \ { 0 } };

// our products

book_t ida_book = { \

softwares_t softwares = // an initialized variable length structure { 3, {

{ { PC, WINDOWS|DOS, DISASSEMBLY }, \ { { PC|MAC, WINDOWS|OS_X, RECOVERY }, \ { { PC, WINDOWS, CRYPTOGRAPHY }, \ } };

#define PRODUCTS_COUNT 4

// our functions // =============

// check software information

int check_software(software_info_t software_info) {

bool valid = true;

if (software_info.plateform & PC) {

if (! (software_info.plateform & MAC) && (software_info.os & OS_X)) valid = false; // OS-X isn't yet available on PC ;) }

else if (software_info.plateform & MAC) {

if (! (software_info.plateform & PC) && ((software_info.os & WINDOWS) || (software_info.os & DOS)))

valid = false; // Windows & DOS aren't available on Mac... } else

valid = false; return valid; }

// check product category

int check_product(product_category_t product_category) {

bool valid = true;

if (product_category == HARDWARE) {

valid = false;

printf(\ }

return valid; }

// print customer information

void print_customer(customer_t *customer) {

printf(\customer->id, customer->name, customer->sex); }

// print book information

void print_book(book_t *book) {

printf(\book->title); }

// print software information

void print_software(software_t *software) {

printf(\software->name); // plateform

// we use 'if', as plateforms can be combined if (software->info.plateform & PC) printf(\

if (software->info.plateform & MAC) printf(\ printf(\ // OS

// we use 'if', as os can be combined if (software->info.os & WINDOWS) printf(\ if (software->info.os & DOS) printf(\

if (software->info.os & OS_X) printf(\ printf(\ // category

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库IDA简易教程(10)在线全文阅读。

IDA简易教程(10).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/jiaoyu/688581.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: