\r
void show_help()\r
{\r
- printf("Usage : part_man.exe <show|add|rem> <port_guid> <pkey1, pkey2, ...>\n");\r
+ printf("Usage : part_man.exe <show|add|rem> <port_guid> <pkey1 pkey2 ...>\n");\r
}\r
\r
/********************************************************************\r
LONG ret;\r
int retval;\r
DWORD read_length = DEFAULT_BUFER_SIZE;\r
-\r
+ const char *sep_group = ";";\r
+ const char *sep_guid_pkey = ":,";\r
ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE,IBBUS_SERV_KEY,0,KEY_SET_VALUE | KEY_QUERY_VALUE ,reg_handle);\r
if (ERROR_SUCCESS != ret)\r
{\r
if(retval > 4)\r
{\r
if(show)\r
- printf("Existing Pkey(s): %s\n",partKey);\r
+ {\r
+ char *pkey_group, *pkey_group_next, *pkey_guid, tmp;\r
+ int i,j,k;\r
+ unsigned short *guid_vstat;\r
+ pkey_group = partKey;\r
+ while(pkey_group && (*pkey_group != '\0'))\r
+ {\r
+ pkey_group_next = strstr(pkey_group,sep_group);\r
+ if(pkey_group_next)\r
+ *pkey_group_next = '\0';\r
+ pkey_guid = strtok(pkey_group,sep_guid_pkey);\r
+ i = 0;\r
+ while(pkey_guid)\r
+ {\r
+ if(i == 0)\r
+ {\r
+ j = 1;\r
+ for (k = strlen(pkey_guid) -1; k > 1; k--)\r
+ {\r
+ if (j%2)\r
+ {\r
+ tmp = pkey_guid[k -1];\r
+ pkey_guid[k -1] = pkey_guid[k];\r
+ pkey_guid[k] = tmp;\r
+ }\r
+ printf("%c",pkey_guid[k]);\r
+ if ((j%4 == 0) && (k > 2))\r
+ {\r
+ printf(":");\r
+ j = 1;\r
+ }\r
+ else\r
+ j++;\r
+ }\r
+ printf("\t");\r
+ }\r
+ else\r
+ {\r
+ printf("%s\t",pkey_guid);\r
+ }\r
+ pkey_guid = strtok(NULL,sep_guid_pkey);\r
+ if((++i)%5 == 0)\r
+ printf("\n\t\t\t");\r
+ }\r
+ printf("\n\n");\r
+ if(pkey_group_next)\r
+ pkey_group = pkey_group_next + 1;\r
+ else\r
+ pkey_group = NULL;\r
+ }\r
+ }\r
}\r
else\r
retval = 0;\r
if( 0 == send_pdo_req(&pkeys,UAL_REQ_CREATE_PDO))\r
{\r
ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE,IBBUS_SERV_KEY,0,KEY_SET_VALUE | KEY_QUERY_VALUE ,®_handle);\r
-\r
ret = RegSetValueEx(reg_handle,"PartitionKey",0,REG_SZ,(BYTE*)p_reg_string,reg_length);\r
RegCloseKey( reg_handle );\r
if (ERROR_SUCCESS == ret)\r
int i;\r
unsigned short *guid_vstat;\r
guid_vstat = (unsigned short*)&input->u.guid_pkey.port_guid;\r
- sscanf(cmd[2],"%x:%x:%x:%x",&guid_vstat[0],&guid_vstat[1],&guid_vstat[2],&guid_vstat[3]);\r
- for( i = 0; i < 4; i++)\r
- guid_vstat[i] = (guid_vstat[i] << 8) | (guid_vstat[i] >> 8);\r
+ if (4 == sscanf(cmd[2],"%x:%x:%x:%x",&guid_vstat[0],&guid_vstat[1],&guid_vstat[2],&guid_vstat[3]))\r
+ {\r
+ for( i = 0; i < 4; i++)\r
+ guid_vstat[i] = (guid_vstat[i] << 8) | (guid_vstat[i] >> 8);\r
+ }\r
+ else\r
+ {\r
+ goto bad_inp;\r
+ }\r
}\r
else\r
{\r
- printf("port guid %s - illegal string format\n",cmd[2]);\r
- return 0;\r
+ goto bad_inp;\r
}\r
- \r
+\r
for( i = 3; i < num; i++)\r
{\r
if((strstr(cmd[i],"ffff")) || (strstr(cmd[i],"FFFF")))\r
input->u.guid_pkey.pkey_num++;\r
}\r
return 1;\r
+bad_inp:\r
+ printf("port guid %s - illegal port guid format, expected xxxx:xxxx:xxxx:xxxx\n",cmd[2]);\r
+ return 0; \r
}\r
\r
void partition_operation(char* cmd[],int num)\r