[PATCH 1/5] dvb_cmd_name function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 lib/include/dvb-fe.h  |    1 +
 lib/libdvbv5/dvb-fe.c |   21 +++++++++++++++------
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/lib/include/dvb-fe.h b/lib/include/dvb-fe.h
index 872a558..b4c5279 100644
--- a/lib/include/dvb-fe.h
+++ b/lib/include/dvb-fe.h
@@ -108,6 +108,7 @@ int dvb_set_sys(struct dvb_v5_fe_parms *parms,
 		   fe_delivery_system_t sys);
 int dvb_set_compat_delivery_system(struct dvb_v5_fe_parms *parms,
 				   uint32_t desired_system);
+const char *dvb_cmd_name(int cmd);
 void dvb_fe_prt_parms(FILE *fp, const struct dvb_v5_fe_parms *parms);
 int dvb_fe_set_parms(struct dvb_v5_fe_parms *parms);
 int dvb_fe_get_parms(struct dvb_v5_fe_parms *parms);
diff --git a/lib/libdvbv5/dvb-fe.c b/lib/libdvbv5/dvb-fe.c
index 87f48db..9ec9893 100644
--- a/lib/libdvbv5/dvb-fe.c
+++ b/lib/libdvbv5/dvb-fe.c
@@ -382,6 +382,15 @@ int dvb_set_compat_delivery_system(struct dvb_v5_fe_parms *parms,
 	return 0;
 }
 
+const char *dvb_cmd_name(int cmd)
+{
+  if (cmd < DTV_USER_COMMAND_START)
+    return dvb_v5_name[cmd];
+  else if (cmd <= DTV_MAX_USER_COMMAND)
+    return dvb_user_name[cmd - DTV_USER_COMMAND_START];
+  return NULL;
+}
+
 void dvb_fe_prt_parms(FILE *fp, const struct dvb_v5_fe_parms *parms)
 {
 	int i;
@@ -400,11 +409,11 @@ void dvb_fe_prt_parms(FILE *fp, const struct dvb_v5_fe_parms *parms)
 
 		if (!attr_name || !*attr_name)
 			fprintf(fp, "%s = %u\n",
-				dvb_v5_name[parms->dvb_prop[i].cmd],
+				dvb_cmd_name(parms->dvb_prop[i].cmd),
 				parms->dvb_prop[i].u.data);
 		else
 			fprintf(fp, "%s = %s\n",
-				dvb_v5_name[parms->dvb_prop[i].cmd],
+				dvb_cmd_name(parms->dvb_prop[i].cmd),
 				*attr_name);
 	}
 };
@@ -419,8 +428,8 @@ int dvb_fe_retrieve_parm(struct dvb_v5_fe_parms *parms,
 		*value = parms->dvb_prop[i].u.data;
 		return 0;
 	}
-	fprintf(stderr, "%s (%d) command not found during retrieve\n",
-		dvb_v5_name[cmd], cmd);
+	fprintf(stderr, "command %s (%d) not found during retrieve\n",
+		dvb_cmd_name(cmd), cmd);
 
 	return EINVAL;
 }
@@ -435,8 +444,8 @@ int dvb_fe_store_parm(struct dvb_v5_fe_parms *parms,
 		parms->dvb_prop[i].u.data = value;
 		return 0;
 	}
-	fprintf(stderr, "%s (%d) command not found during store\n",
-		dvb_v5_name[cmd], cmd);
+	fprintf(stderr, "command %s (%d) not found during store\n",
+		dvb_cmd_name(cmd), cmd);
 
 	return EINVAL;
 }
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux