[ofw][patch] improved prints
Slava Strebkov
slavas at voltaire.com
Tue Sep 9 07:32:01 PDT 2008
Improved prints
Index: tools/part_man/user/part_man.c
===================================================================
--- tools/part_man/user/part_man.c (revision 1545)
+++ tools/part_man/user/part_man.c (working copy)
@@ -35,7 +35,7 @@
void show_help()
{
- printf("Usage : part_man.exe <show|add|rem> <port_guid> <pkey1,
pkey2, ...>\n");
+ printf("Usage : part_man.exe <show|add|rem> <port_guid> <pkey1
pkey2 ...>\n");
}
/********************************************************************
@@ -50,7 +50,8 @@
LONG ret;
int retval;
DWORD read_length = DEFAULT_BUFER_SIZE;
-
+ const char *sep_group = ";";
+ const char *sep_guid_pkey = ":,";
ret =
RegOpenKeyEx(HKEY_LOCAL_MACHINE,IBBUS_SERV_KEY,0,KEY_SET_VALUE |
KEY_QUERY_VALUE ,reg_handle);
if (ERROR_SUCCESS != ret)
{
@@ -75,7 +76,57 @@
if(retval > 4)
{
if(show)
- printf("Existing Pkey(s):
%s\n",partKey);
+ {
+ char *pkey_group, *pkey_group_next,
*pkey_guid, tmp;
+ int i,j,k;
+ unsigned short *guid_vstat;
+ pkey_group = partKey;
+ while(pkey_group && (*pkey_group !=
'\0'))
+ {
+ pkey_group_next =
strstr(pkey_group,sep_group);
+ if(pkey_group_next)
+ *pkey_group_next = '\0';
+ pkey_guid =
strtok(pkey_group,sep_guid_pkey);
+ i = 0;
+ while(pkey_guid)
+ {
+ if(i == 0)
+ {
+ j = 1;
+ for (k =
strlen(pkey_guid) -1; k > 1; k--)
+ {
+ if (j%2)
+ {
+
tmp = pkey_guid[k -1];
+
pkey_guid[k -1] = pkey_guid[k];
+
pkey_guid[k] = tmp;
+ }
+
printf("%c",pkey_guid[k]);
+ if ((j%4
== 0) && (k > 2))
+ {
+
printf(":");
+
j = 1;
+ }
+ else
+
j++;
+ }
+ printf("\t");
+ }
+ else
+ {
+
printf("%s\t",pkey_guid);
+ }
+ pkey_guid =
strtok(NULL,sep_guid_pkey);
+ if((++i)%5 == 0)
+
printf("\n\t\t\t");
+ }
+ printf("\n\n");
+ if(pkey_group_next)
+ pkey_group =
pkey_group_next + 1;
+ else
+ pkey_group = NULL;
+ }
+ }
}
else
retval = 0;
@@ -404,7 +455,6 @@
if( 0 ==
send_pdo_req(&pkeys,UAL_REQ_CREATE_PDO))
{
ret =
RegOpenKeyEx(HKEY_LOCAL_MACHINE,IBBUS_SERV_KEY,0,KEY_SET_VALUE |
KEY_QUERY_VALUE ,®_handle);
-
ret =
RegSetValueEx(reg_handle,"PartitionKey",0,REG_SZ,(BYTE*)p_reg_string,reg
_length);
RegCloseKey( reg_handle );
if (ERROR_SUCCESS == ret)
@@ -459,16 +509,21 @@
int i;
unsigned short *guid_vstat;
guid_vstat = (unsigned
short*)&input->u.guid_pkey.port_guid;
-
sscanf(cmd[2],"%x:%x:%x:%x",&guid_vstat[0],&guid_vstat[1],&guid_vstat[2]
,&guid_vstat[3]);
- for( i = 0; i < 4; i++)
- guid_vstat[i] = (guid_vstat[i] << 8) |
(guid_vstat[i] >> 8);
+ if (4 ==
sscanf(cmd[2],"%x:%x:%x:%x",&guid_vstat[0],&guid_vstat[1],&guid_vstat[2]
,&guid_vstat[3]))
+ {
+ for( i = 0; i < 4; i++)
+ guid_vstat[i] = (guid_vstat[i] << 8) |
(guid_vstat[i] >> 8);
+ }
+ else
+ {
+ goto bad_inp;
+ }
}
else
{
- printf("port guid %s - illegal string format\n",cmd[2]);
- return 0;
+ goto bad_inp;
}
-
+
for( i = 3; i < num; i++)
{
if((strstr(cmd[i],"ffff")) || (strstr(cmd[i],"FFFF")))
@@ -480,6 +535,9 @@
input->u.guid_pkey.pkey_num++;
}
return 1;
+bad_inp:
+ printf("port guid %s - illegal port guid format, expected
xxxx:xxxx:xxxx:xxxx\n",cmd[2]);
+ return 0;
}
void partition_operation(char* cmd[],int num)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: part_man_improved_prints.diff
Type: application/octet-stream
Size: 3545 bytes
Desc: part_man_improved_prints.diff
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20080909/a8cb8e71/attachment.obj>
More information about the ofw
mailing list