⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cooking.c

📁 Linux下的系统信息获取
💻 C
📖 第 1 页 / 共 5 页
字号:
    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE0_CHAR_FD_TOSHIBA);        strcat(file, line);    }    if( (type0->characteristics) & 0x0000000000400000 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE0_CHAR_360);        strcat(file, line);    }    if( (type0->characteristics) & 0x0000000000800000 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE0_CHAR_1200);        strcat(file, line);    }    if( (type0->characteristics) & 0x0000000001000000 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE0_CHAR_720);        strcat(file, line);    }    if( (type0->characteristics) & 0x0000000002000000 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE0_CHAR_2880);        strcat(file, line);    }    if( (type0->characteristics) & 0x0000000004000000 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE0_CHAR_PRINT_SCREEN);        strcat(file, line);    }    if( (type0->characteristics) & 0x0000000008000000 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE0_CHAR_KEYBOARD);        strcat(file, line);    }    if( (type0->characteristics) & 0x0000000010000000 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE0_CHAR_SER_SERVICES);        strcat(file, line);    }    if( (type0->characteristics) & 0x0000000020000000 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE0_CHAR_PRINT_SERVICES);        strcat(file, line);    }    if( (type0->characteristics) & 0x0000000040000000 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE0_CHAR_VIDEO_SERVICES);        strcat(file, line);    }    if( (type0->characteristics) & 0x0000000080000000 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE0_CHAR_PC98);        strcat(file, line);    }    if(smbiosstruct->length > 0x12)    {        /* interpretation of extension byte 1 */        if( (type0->ext1) & 0x01 )        {            sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE0_EXT1_ACPI);            strcat(file, line);        }        if( (type0->ext1) & 0x02 )        {            sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE0_EXT1_USB);            strcat(file, line);        }        if( (type0->ext1) & 0x04 )        {            sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE0_EXT1_AGP);            strcat(file, line);        }        if( (type0->ext1) & 0x08 )        {            sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE0_EXT1_I2O_BOOT);            strcat(file, line);        }        if( (type0->ext1) & 0x10 )        {            sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE0_EXT1_LS120);            strcat(file, line);        }        if( (type0->ext1) & 0x20 )        {            sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE0_EXT1_ATAPI_ZIP_BOOT);            strcat(file, line);        }        if( (type0->ext1) & 0x40 )        {            sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE0_EXT1_1394_BOOT);            strcat(file, line);        }        if( (type0->ext1) & 0x80 )        {            sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE0_EXT1_SMART_BATTERY);            strcat(file, line);        }    }    if(smbiosstruct->length > 0x13)    {        /* interpretation of extension byte 2 */        if( (type0->ext2) & 0x01 )        {            sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE0_EXT2_BBS);            strcat(file, line);        }        if( (type0->ext2) & 0x02 )        {            sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE0_EXT2_NETWORK_BOOT);            strcat(file, line);        }    }	    /* now line contains a string with fully interpreted type 0 data */	*plength = strlen(file);	/* allocate memory */	scratch = kmalloc (*plength+1, GFP_BUFFER);	if (scratch == NULL)	{		*plength = 0;		return NULL;	}	/* copy the interpreted data */	memcpy (scratch, file, *plength);	/* return a string with all the interpreted data for the given raw structure. */		/* the caller is responsible to free the memory. */		return scratch;	}/** \fn unsigned char * bios_cook_type_1 (smbios_struct *smbiosstruct, unsigned int * plength)  * \brief writes interpreted SMBIOS Type 1 data to a /proc file  * \param smbiosstruct pointer to SMBIOS Type 1 raw structure  * \param plength amount of memory allocated by this function  * \return pointer to string that holds the interpreted data  *  * this function gets a raw SMBIOS Type 1 (System) structure. it  * interpretes the raw data and builds a string with the interpreted  * data. this is the return value of this structure. the caller is  * responsible to free the allocated memory.  *  * \author Joachim Braeuer  * \date March 2001  */unsigned char *bios_cook_type_1 (smbios_struct * smbiosstruct, unsigned int *plength){	/* contains the full block of interpreted data */    /* on some systems the system crashed if the stack (local variables) */    /* is bigger than one pages (4k). since linux needs some space in this */    /* page the variables should never exceed 3kB. */	smbios_type_1 *type1;    unsigned char * scratch;	/* contains the full block of interpreted data */    /* on some systems the system crashed if the stack (local variables) */    /* is bigger than one pages (4k). since linux needs some space in this */    /* page the variables should never exceed 3kB. */	unsigned char file[2800];	/* contains one line of the above file */    unsigned char line[128];    unsigned char help[8];                  /* helper string */    int i;    /* cast our data ptr to a structure ptr of SMBIOS type 1 */    type1 = (smbios_type_1 *)smbiosstruct;    /* prepare header strings */    sprintf (line, "%-35s%s %d %s\n", TYPE, SEP1, smbiosstruct->type, TYPE1_NAME);    strcpy(file, line);	sprintf (line, "%-35s%s %d %s\n", LENGTH, SEP1, smbiosstruct->length, BYTES);	strcat(file, line);	sprintf (line, "%-35s%s %d\n\n", HANDLE, SEP1, smbiosstruct->handle);	strcat(file, line);		/* prepare interpreted type 1 string */	sprintf (line, "%-35s%s %s\n", TYPE1_MANUFACTURER, SEP1, GetString(smbiosstruct, (unsigned int)(type1->manufacturer)));    strcat(file, line);	sprintf (line, "%-35s%s %s\n", TYPE1_PRODUCT_NAME, SEP1, GetString(smbiosstruct, (unsigned int)(type1->productname)));	strcat(file, line);		sprintf (line, "%-35s%s %s\n", TYPE1_VERSION, SEP1, GetString(smbiosstruct, (unsigned int)(type1->version)));	strcat(file, line);		sprintf (line, "%-35s%s %s\n", TYPE1_SERIAL_NUMBER, SEP1, GetString(smbiosstruct, (unsigned int)(type1->serialnumber)));	strcat(file, line);	    /* if smbios 2.1 or higher */    if(smbiosstruct->length > 0x08)			{  	    sprintf(line, "%-35s%s ", TYPE1_UUID, SEP1);  	    strcat(file, line);  	    for (i=0; i<16; i++) 		{			sprintf(help, "%.2X ", type1->uuid[i]);  	        strcat(file, help);		}		strcat(file, "\n");		switch(type1->wakeuptype)		{			case 0:		sprintf (line, "%-35s%s %s\n", TYPE1_WAKEUP, SEP1, TYPE1_WT_RESERVED);						break;			case 1:		sprintf (line, "%-35s%s %s\n", TYPE1_WAKEUP, SEP1, TYPE1_WT_OTHER);						break;			case 2:		sprintf (line, "%-35s%s %s\n", TYPE1_WAKEUP, SEP1, TYPE1_WT_UNKNOWN);						break;			case 3:		sprintf (line, "%-35s%s %s\n", TYPE1_WAKEUP, SEP1, TYPE1_WT_APM);						break;			case 4:		sprintf (line, "%-35s%s %s\n", TYPE1_WAKEUP, SEP1, TYPE1_WT_MODEM);						break;			case 5:		sprintf (line, "%-35s%s %s\n", TYPE1_WAKEUP, SEP1, TYPE1_WT_LAN);						break;			case 6:		sprintf (line, "%-35s%s %s\n", TYPE1_WAKEUP, SEP1, TYPE1_WT_POWER_SWITCH);						break;			case 7:		sprintf (line, "%-35s%s %s\n", TYPE1_WAKEUP, SEP1, TYPE1_WT_PCI_PME);						break;			case 8:		sprintf (line, "%-35s%s %s\n", TYPE1_WAKEUP, SEP1, TYPE1_WT_AC_PWR_RESTORE);						break;			default:    sprintf (line, "%-35s%s %d\n", TYPE1_WAKEUP, SEP1, type1->wakeuptype);		}  	    strcat(file, line);	} /* end - if smbios 2.1 or higher */	/* now line contains a string with fully interpreted type 1 data */	*plength = strlen(file);	/* allocate memory */	scratch = kmalloc (*plength+1, GFP_BUFFER);	if (scratch == NULL)	{		*plength = 0;		return NULL;	}	/* copy the interpreted data */	memcpy (scratch, file, *plength);	/* return a string with all the interpreted data for the given raw structure. */	    /* the caller is responsible to free the memory. */	    return scratch;}/** \fn unsigned char * bios_cook_type_2 (smbios_struct *smbiosstruct, unsigned int * plength)  * \brief writes interpreted SMBIOS Type 2 data to a /proc file  * \param smbiosstruct pointer to SMBIOS Type 2 raw structure  * \param plength amount of memory allocated by this function  * \return pointer to string that holds the interpreted data  *  * this function gets a raw SMBIOS Type 2 (BaseBoard) structure. it  * interpretes the raw data and builds a string with the interpreted  * data. this is the return value of this structure. the caller is  * responsible to free the allocated memory.  *  * \author Joachim Braeuer  * \date March 2001  */unsigned char *bios_cook_type_2 (smbios_struct * smbiosstruct, unsigned int *plength){	smbios_type_2 *type2;    unsigned char * scratch;		/* contains the full block of interpreted data */    /* on some systems the system crashed if the stack (local variables) */    /* is bigger than one pages (4k). since linux needs some space in this */    /* page the variables should never exceed 3kB. */	unsigned char file[2800];	/* contains one line of the above file */    unsigned char line[128];    /* cast our data ptr to a structure ptr of SMBIOS type 2 */    type2 = (smbios_type_2 *)smbiosstruct;    /* prepare header strings */    sprintf (line, "%-35s%s %d %s\n", TYPE, SEP1, smbiosstruct->type, TYPE2_NAME);    strcpy(file, line);	sprintf (line, "%-35s%s %d %s\n", LENGTH, SEP1, smbiosstruct->length, BYTES);	strcat(file, line);	sprintf (line, "%-35s%s %d\n\n", HANDLE, SEP1, smbiosstruct->handle);	strcat(file, line);	/* prepare interpreted type 2 strings */	sprintf (line, "%-35s%s %s\n", TYPE2_MANUFACTURER, SEP1, GetString(smbiosstruct, (unsigned int)(type2->manufacturer)));	strcat(file, line);	sprintf (line, "%-35s%s %s\n", TYPE2_PRODUCT, SEP1, GetString(smbiosstruct, (unsigned int)(type2->product)));	strcat(file, line);	sprintf (line, "%-35s%s %s\n", TYPE2_VERSION, SEP1, GetString(smbiosstruct, (unsigned int)(type2->version)));	strcat(file, line);	sprintf (line, "%-35s%s %s\n", TYPE2_SERIAL_NUMBER, SEP1, GetString(smbiosstruct, (unsigned int)(type2->serialnumber)));	strcat(file, line);    /* now line contains a string with fully interpreted type 2 data */	*plength = strlen(file);	/* allocate memory */	scratch = kmalloc (*plength+1, GFP_BUFFER);	if (scratch == NULL)	{		*plength = 0;		return NULL;	}	/* copy the interpreted data */	memcpy (scratch, file, *plength);	/* return a string with all the interpreted data for the given raw structure. */	/* the caller is responsible to free the memory. */		return scratch;}/** \fn unsigned char * bios_cook_type_3 (smbios_struct *smbiosstruct, unsigned int * plength)  * \brief writes interpreted SMBIOS Type 3 data to a /proc file  * \param smbiosstruct pointer to SMBIOS Type 3 raw structure  * \param plength amount of memory allocated by this function  * \return pointer to string that holds the interpreted data  *  * this function gets a raw SMBIOS Type 3 (Enclosure, Chassis) structure. it  * interpretes the raw data and builds a string with the interpreted  * data. this is the return value of this structure. the caller is  * responsible to free the allocated memory.  *  * \author Joachim Braeuer  * \date March 2001  */unsigned char *bios_cook_type_3 (smbios_struct * smbiosstruct, unsigned int *plength){	smbios_type_3 *type3;    unsigned char * scratch;	    /* contains the full block of interpreted data */    /* on some systems the system crashed if the stack (local variables) */    /* is bigger than one pages (4k). since linux needs some space in this */    /* page the variables should never exceed 3kB. */	unsigned char file[2800];	/* contains one line of the above file */    unsigned char line[128];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -