net_radio.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <conio.h>
int p_count = 1;
int flag = 0;
char i_c = '0';
char stringCom[12] = "mpc play 1";
char stringComStop[10] = "mpc stop";
int stringDat[9];
int i = 0;
int res = 0;
char c;
int decode (int res)
{
flag = 1;
switch (res)
{
case 114 : {//r net_radio
p_count = 1;
}
break;
case 115 : {//s stop
system (stringComStop);
flag = 0;
}
break;
case 49 : {//1
p_count = 1;
}
break;
case 50 : {//2
p_count = 2;
}
break;
case 51 : {//3
p_count = 3;
}
break;
case 52 : {//4
p_count = 4;
}
break;
case 53 : {//5
p_count = 5;
}
break;
case 54 : {//6
p_count = 6;
}
break;
case 55 : {//7
p_count = 7;
}
break;
case 56 : {//8
p_count = 8;
}
break;
case 57 : {//9
p_count = 9;
}
break;
case 48 : {//0
p_count = 0;
}
break;
case 104 : p_count ++;//h kanal op
break;
case 118 : p_count --;//v kanal ned
break;
default:
{
flag = 0;
return 0;
}
}
if (flag == 1)
{
if (p_count > 9)
{
p_count = 1;
}
if (p_count < 1)
{
p_count = 9;
}
i_c = p_count + 48;//int to char max 9
stringCom[9] = i_c;
system (stringCom);
}
return 0;
}
int main (void)
{
while (1)
{
c = getch();
if (c == 46)
break;
res = (int) (c);
decode (res);
sleep(.5);
}
return 0 ;
}
Compile med: g++ -o net_radio net_radio.c
Bemærk:
dette er ekspermentel software der er ingen garanti for brugbarhed, det
kan derimod sandsynligvis være skadeligt, kun til brug i Danmark.