FreeCalypso > hg > freecalypso-tools
view rvinterf/tmsh/audiocmd.c @ 41:2c9ea966edb9
target-utils/{compalstage,loadagent}/Makefile: move to /opt/freecalypso
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 26 Oct 2016 05:32:42 +0000 |
parents | ea061975c883 |
children | 2159f260ed13 |
line wrap: on
line source
/* * ETM audio commands */ #include <sys/types.h> #include <stdio.h> #include <string.h> #include <strings.h> #include <stdlib.h> #include "limits.h" #include "localtypes.h" #include "etm.h" void cmd_audio_load(argc, argv) char **argv; { u_char cmdpkt[MAX_PKT_TO_TARGET], *dp; int slen; slen = strlen(argv[1]); if (slen > 9) { printf("error: audio config name is limited to 9 chars\n"); return; } dp = cmdpkt + 1; *dp++ = ETM_AUDIO; *dp++ = 'L'; strcpy(dp, argv[1]); dp += slen + 1; send_etm_cmd(cmdpkt, dp - cmdpkt - 1); } void cmd_audio_save(argc, argv) char **argv; { u_char cmdpkt[MAX_PKT_TO_TARGET], *dp; int slen; slen = strlen(argv[1]); if (slen > 9) { printf("error: audio config name is limited to 9 chars\n"); return; } dp = cmdpkt + 1; *dp++ = ETM_AUDIO; *dp++ = 'S'; strcpy(dp, argv[1]); dp += slen + 1; send_etm_cmd(cmdpkt, dp - cmdpkt - 1); } static struct cmdtab { char *cmd; int minargs; int maxargs; void (*func)(); } audio_cmds[] = { {"load", 1, 1, cmd_audio_load}, {"save", 1, 1, cmd_audio_save}, {0, 0, 0, 0} }; void cmd_audio(argc, argv) char **argv; { struct cmdtab *tp; int extargs; for (tp = audio_cmds; tp->cmd; tp++) if (!strcmp(tp->cmd, argv[1])) break; if (!tp->func) { printf("error: no such audio command\n"); return; } extargs = argc - 2; if (extargs > tp->maxargs) { printf("error: too many arguments\n"); return; } if (extargs < tp->minargs) { printf("error: too few arguments\n"); return; } tp->func(argc - 1, argv + 1); }