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

📄 cooking.c

📁 Linux下的系统信息获取
💻 C
📖 第 1 页 / 共 5 页
字号:
		case 69:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_MIPS_R10000);					break;		case 80:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_SPARC);					break;		case 81:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_SPARC_SUPER);					break;	    case 82:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_SPARC_MICRO_II);					break;		case 83:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_SPARC_MICRO_IIEP);					break;		case 84:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_SPARC_ULTRA);					break;		case 85:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_SPARC_ULTRA_II);					break;		case 86:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_SPARC_ULTRA_II_I);					break;		case 87:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_SPARC_ULTRA_III);					break;		case 88:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_SPARC_ULTRA_III_I);					break;		case 96:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_68040);					break;		case 97:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_68XXX);					break;		case 98:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_68000);					break;		case 99:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_68010);					break;		case 100:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_68020);					break;		case 101:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_68030);					break;		case 112:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_HOBBIT);					break;		case 120:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_CRUSOE_TM5000);					break;		case 121:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_CRUSOE_TM3000);					break;		case 128:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_WEITEK);					break;		case 130:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_ITANIUM);					break;		case 144:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_PARISC);					break;		case 145:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_PARISC_8500);					break;		case 146:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_PARISC_8000);					break;		case 147:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_PARISC_7300LC);					break;		case 148:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_PARISC_7200);					break;		case 149:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_PARISC_7100LC);					break;		case 150:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_PARISC_7100);					break;		case 160:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_V30);					break;		case 176:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_PENTIUM_III_XEON);					break;	    case 177:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_PENTIUM_III_SPEED);					break;	    case 178:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_PENTIUM_4);					break;		case 180:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_AS400);					break;		case 200:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_IBM390);					break;		case 201:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_G4);					break;		case 202:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_G5);					break;		case 250:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_I860);					break;		case 251:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_I960);					break;		case 260:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_SH3);					break;		case 261:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_SH4);					break;		case 280:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_ARM);					break;		case 281:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_STRONG_ARM);					break;		case 300:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_6X86);					break;	    case 301:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_MEDIAGX);					break;	    case 302:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_MII);					break;		case 320:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_WINCHIP);					break;		case 350:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_DSP);					break;	    case 500:	sprintf (line, "%-35s%s %s\n", TYPE4_FAMILY, SEP1, TYPE4_FAMILY_VIDEO);					break;        default:    sprintf (line, "%-35s%s %d\n", TYPE4_FAMILY, SEP1, type4->family);	}    strcat(file, line);    sprintf (line, "%-35s%s %s\n", TYPE4_MANUFACTURER, SEP1, GetString(smbiosstruct, (unsigned int)(type4->manufacturer)));	strcat(file, line);    sprintf(line, "%-35s%s ", TYPE4_ID, SEP1);    strcat(file, line);    for (i=0; i<8; i++) 	{		sprintf(help, "%.2X ", (unsigned char)(type4->id[i]));        strcat(file, help);	}	strcat(file, "\n");    sprintf (line, "%-35s%s %s\n", TYPE4_VERSION, SEP1, GetString(smbiosstruct, (unsigned int)(type4->version)));	strcat(file, line);    if((type4->voltage) & 0x80)    {        if(((type4->voltage) & 0x7F) > 10)        {            sprintf(help, "%d", (type4->voltage) & 0x7F);            strncpy(help2, help, strlen(help)-1);            *(help2 + strlen(help)-1) = 0x00;        }        else        {            strcpy(help2, "0");        }        strcat(help2, ".");        if(((type4->voltage) & 0x7F) > 10)        {            strcat(help2, help + strlen(help)-1);        }        else        {            strcat(help2, help);        }        sprintf(line, "%-35s%s %sV\n", TYPE4_CURRENT_VOLTAGE, SEP1, help2);        strcat(file, line);    }    else    {        sprintf (line, "%-35s%s\n", TYPE4_VOLTAGE, SEP1);	    strcat(file, line);        if(type4->voltage & 0x01)        {            sprintf (line, "%-35s  %s %s\n", "", SEP2, TYPE4_VOLTAGE_50);	        strcat(file, line);        }        if(type4->voltage & 0x02)        {            sprintf (line, "%-35s  %s %s\n", "", SEP2, TYPE4_VOLTAGE_33);	        strcat(file, line);		}        if(type4->voltage & 0x04)        {            sprintf (line, "%-35s  %s %s\n", "", SEP2, TYPE4_VOLTAGE_29);	        strcat(file, line);        }    }    if(type4->external_clock > 0)    {        sprintf (line, "%-35s%s %d %s\n", TYPE4_EXTERNAL_CLOCK, SEP1, type4->external_clock, MHZ);        strcat(file, line);    }    if(type4->max_speed > 0)    {        sprintf (line, "%-35s%s %d %s\n", TYPE4_MAX_SPEED, SEP1, type4->max_speed, MHZ);	    strcat(file, line);    }    if(type4->current_speed > 0)    {        sprintf (line, "%-35s%s %d %s\n", TYPE4_CURRENT_SPEED, SEP1, type4->current_speed, MHZ);	    strcat(file, line);    }    switch(type4->status &0x07)	{	    case 0:		sprintf (line, "%-35s%s %s\n", TYPE4_STATUS, SEP1, TYPE4_STATUS_UNKNOWN);					break;        case 1:		sprintf (line, "%-35s%s %s\n", TYPE4_STATUS, SEP1, TYPE4_STATUS_ENABLED);					break;        case 2:		sprintf (line, "%-35s%s %s\n", TYPE4_STATUS, SEP1, TYPE4_STATUS_DISABLED_USER);					break;		case 3:		sprintf (line, "%-35s%s %s\n", TYPE4_STATUS, SEP1, TYPE4_STATUS_DISABLED_POST);					break;	    case 4:		sprintf (line, "%-35s%s %s\n", TYPE4_STATUS, SEP1, TYPE4_STATUS_IDLE);					break;		case 7:		sprintf (line, "%-35s%s %s\n", TYPE4_STATUS, SEP1, TYPE4_STATUS_OTHER);					break;  	    default:    sprintf (line, "%-35s%s %d\n", TYPE4_STATUS, SEP1, type4->status &0x07);	}	strcat(file, line);    if(type4->status &0x40)        sprintf (line, "%-35s%s %s\n", TYPE4_SOCKET, SEP1, TYPE4_SOCKET_POPULATED);    else        sprintf (line, "%-35s%s %s\n", TYPE4_SOCKET, SEP1, TYPE4_SOCKET_UNPOPULATED);    strcat(file, line);    switch(type4->upgrade)	{        case 1:		sprintf (line, "%-35s%s %s\n", TYPE4_UPGRADE, SEP1, TYPE4_UPGRADE_OTHER);					break;		case 2:		sprintf (line, "%-35s%s %s\n", TYPE4_UPGRADE, SEP1, TYPE4_UPGRADE_UNKNOWN);					break;		case 3:		sprintf (line, "%-35s%s %s\n", TYPE4_UPGRADE, SEP1, TYPE4_UPGRADE_DAUGHTER);					break;		case 4:		sprintf (line, "%-35s%s %s\n", TYPE4_UPGRADE, SEP1, TYPE4_UPGRADE_ZIFF);					break;		case 5:		sprintf (line, "%-35s%s %s\n", TYPE4_UPGRADE, SEP1, TYPE4_UPGRADE_PIGGY_BACK);					break;		case 6:		sprintf (line, "%-35s%s %s\n", TYPE4_UPGRADE, SEP1, TYPE4_UPGRADE_NONE);					break;		case 7:		sprintf (line, "%-35s%s %s\n", TYPE4_UPGRADE, SEP1, TYPE4_UPGRADE_LIF);					break;		case 8:		sprintf (line, "%-35s%s %s\n", TYPE4_UPGRADE, SEP1, TYPE4_UPGRADE_SLOT1);					break;		case 9:		sprintf (line, "%-35s%s %s\n", TYPE4_UPGRADE, SEP1, TYPE4_UPGRADE_SLOT2);					break;		case 10:	sprintf (line, "%-35s%s %s\n", TYPE4_UPGRADE, SEP1, TYPE4_UPGRADE_370);					break;		case 11:	sprintf (line, "%-35s%s %s\n", TYPE4_UPGRADE, SEP1, TYPE4_UPGRADE_A);					break;		case 12:	sprintf (line, "%-35s%s %s\n", TYPE4_UPGRADE, SEP1, TYPE4_UPGRADE_M);					break;		case 13:	sprintf (line, "%-35s%s %s\n", TYPE4_UPGRADE, SEP1, TYPE4_UPGRADE_423);			    	break;		case 14:	sprintf (line, "%-35s%s %s\n", TYPE4_UPGRADE, SEP1, TYPE4_UPGRADE_A462);					break;        default:    sprintf (line, "%-35s%s %d\n", TYPE4_UPGRADE, SEP1, type4->upgrade);	}	strcat(file, line);    /* SMBIOS 2.1 and higher */    if(smbiosstruct->length > 0x1A)    {        if(type4->l1_cache_handle != 0xFFFF)        {            sprintf(line, "%-35s%s %d\n", TYPE4_L1_CACHE_HANDLE, SEP1, type4->l1_cache_handle);            strcat(file, line);        }        if(type4->l2_cache_handle != 0xFFFF)        {            sprintf(line, "%-35s%s %d\n", TYPE4_L2_CACHE_HANDLE, SEP1, type4->l2_cache_handle);            strcat(file, line);        }        if(type4->l3_cache_handle != 0xFFFF)        {            sprintf(line, "%-35s%s %d\n", TYPE4_L3_CACHE_HANDLE, SEP1, type4->l3_cache_handle);            strcat(file, line);        }    }    /* SMBIOS 2.3 and higher */    if(smbiosstruct->length > 0x20)    {        sprintf (line, "%-35s%s %s\n", TYPE4_SERIAL_NUMBER, SEP1, GetString(smbiosstruct, (unsigned int)(type4->serialnumber)));  	    strcat(file, line);        sprintf (line, "%-35s%s %s\n", TYPE4_ASSET_TAG, SEP1, GetString(smbiosstruct, (unsigned int)(type4->asset_tag)));	    strcat(file, line);        sprintf (line, "%-35s%s %s\n", TYPE4_PART_NUMBER, SEP1, GetString(smbiosstruct, (unsigned int)(type4->part_number)));	    strcat(file, line);    }    /* now line contains a string with fully interpreted type 4 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_5 (smbios_struct *smbiosstruct, unsigned int * plength)  * \brief writes interpreted SMBIOS Type 5 data to a /proc file  * \param smbiosstruct pointer to SMBIOS Type 5 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 5 (Memory Controller) 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_5 (smbios_struct * smbiosstruct, unsigned int *plength){	smbios_type_5 *type5;    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 *ptr;    int i;    /* cast our data ptr to a structure ptr of SMBIOS type 5 */    type5 = (smbios_type_5 *)smbiosstruct;    /* prepare header strings */    sprintf (line, "%-35s%s %d %s\n", TYPE, SEP1, smbiosstruct->type, TYPE5_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);    switch(type5->error_detection)	{	    case 1:		sprintf (line, "%-35s%s %s\n", TYPE5_ERROR_DETECTION, SEP1, TYPE5_ED_OTHER);					break;        case 2:		sprintf (line, "%-35s%s %s\n", TYPE5_ERROR_DETECTION, SEP1, TYPE5_ED_UNKNOWN);					break;        case 3:		sprintf (line, "%-35s%s %s\n", TYPE5_ERROR_DETECTION, SEP1, TYPE5_ED_NONE);					break;        case 4:		sprintf (line, "%-35s%s %s\n", TYPE5_ERROR_DETECTION, SEP1, TYPE5_ED_PARITY);					break;        case 5:		sprintf (line, "%-35s%s %s\n", TYPE5_ERROR_DETECTION, SEP1, TYPE5_ED_32ECC);					break;        case 6:		sprintf (line, "%-35s%s %s\n", TYPE5_ERROR_DETECTION, SEP1, TYPE5_ED_64ECC);					break;

⌨️ 快捷键说明

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