mirror of
https://github.com/radio95-rnt/rds95.git
synced 2026-02-26 20:33:53 +01:00
whoops
This commit is contained in:
9
src/fs.c
9
src/fs.c
@@ -65,15 +65,6 @@ int encoder_loadFromFile(RDSEncoder *enc) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int encoder_saved() {
|
|
||||||
char encoderPath[128];
|
|
||||||
snprintf(encoderPath, sizeof(encoderPath), "%s/.rdsEncoder", getenv("HOME"));
|
|
||||||
FILE *file = fopen(encoderPath, "rb");
|
|
||||||
if(!file) return 0;
|
|
||||||
fclose(file);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Modulator_saveToFile(RDSModulatorParameters *emp) {
|
void Modulator_saveToFile(RDSModulatorParameters *emp) {
|
||||||
char modulatorPath[128];
|
char modulatorPath[128];
|
||||||
snprintf(modulatorPath, sizeof(modulatorPath), "%s/.rdsModulator", getenv("HOME"));
|
snprintf(modulatorPath, sizeof(modulatorPath), "%s/.rdsModulator", getenv("HOME"));
|
||||||
|
|||||||
1
src/fs.h
1
src/fs.h
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
void encoder_saveToFile(RDSEncoder *emp);
|
void encoder_saveToFile(RDSEncoder *emp);
|
||||||
int encoder_loadFromFile(RDSEncoder *emp);
|
int encoder_loadFromFile(RDSEncoder *emp);
|
||||||
int encoder_saved();
|
|
||||||
|
|
||||||
void Modulator_saveToFile(RDSModulatorParameters *emp);
|
void Modulator_saveToFile(RDSModulatorParameters *emp);
|
||||||
void Modulator_loadFromFile(RDSModulatorParameters *emp);
|
void Modulator_loadFromFile(RDSModulatorParameters *emp);
|
||||||
|
|||||||
@@ -586,7 +586,7 @@ void run_lua(char *str, char *cmd_output) {
|
|||||||
pthread_mutex_unlock(&lua_mutex);
|
pthread_mutex_unlock(&lua_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lua_group(RDSGroup* group) {
|
int lua_group(RDSGroup* group) {
|
||||||
pthread_mutex_lock(&lua_mutex);
|
pthread_mutex_lock(&lua_mutex);
|
||||||
lua_getglobal(L, "group");
|
lua_getglobal(L, "group");
|
||||||
|
|
||||||
@@ -595,31 +595,28 @@ void lua_group(RDSGroup* group) {
|
|||||||
lua_pushinteger(L, group->b);
|
lua_pushinteger(L, group->b);
|
||||||
lua_pushinteger(L, group->c);
|
lua_pushinteger(L, group->c);
|
||||||
lua_pushinteger(L, group->d);
|
lua_pushinteger(L, group->d);
|
||||||
if (lua_pcall(L, 3, 3, 0) == LUA_OK) {
|
if (lua_pcall(L, 4, 3, 0) == LUA_OK) {
|
||||||
if (!lua_isinteger(L, -1)) {
|
if (!lua_isinteger(L, -1)) {
|
||||||
pthread_mutex_unlock(&lua_mutex);
|
pthread_mutex_unlock(&lua_mutex);
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!lua_isinteger(L, -2)) {
|
if (!lua_isinteger(L, -2)) {
|
||||||
pthread_mutex_unlock(&lua_mutex);
|
pthread_mutex_unlock(&lua_mutex);
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!lua_isinteger(L, -3)) {
|
if (!lua_isinteger(L, -3)) {
|
||||||
pthread_mutex_unlock(&lua_mutex);
|
pthread_mutex_unlock(&lua_mutex);
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
group->d = luaL_checkinteger(L, -1);
|
group->d = luaL_checkinteger(L, -1);
|
||||||
group->c = luaL_checkinteger(L, -2);
|
group->c = luaL_checkinteger(L, -2);
|
||||||
group->b = luaL_checkinteger(L, -3);
|
group->b = luaL_checkinteger(L, -3);
|
||||||
lua_pop(L, 3);
|
lua_pop(L, 2);
|
||||||
} else {
|
} else fprintf(stderr, "Lua error: %s\n", lua_tostring(L, -1));
|
||||||
fprintf(stderr, "Lua error: %s\n", lua_tostring(L, -1));
|
|
||||||
lua_pop(L, 1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
} else lua_pop(L, 1);
|
||||||
pthread_mutex_unlock(&lua_mutex);
|
pthread_mutex_unlock(&lua_mutex);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lua_group_ref(RDSGroup* group, int ref) {
|
void lua_group_ref(RDSGroup* group, int ref) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
void init_lua(RDSModulator* rds_mod);
|
void init_lua(RDSModulator* rds_mod);
|
||||||
void run_lua(char *str, char *cmd_output);
|
void run_lua(char *str, char *cmd_output);
|
||||||
void lua_group(RDSGroup* group);
|
int lua_group(RDSGroup* group);
|
||||||
void lua_call_function(const char* function);
|
void lua_call_function(const char* function);
|
||||||
void lua_group_ref(RDSGroup* group, int ref);
|
void lua_group_ref(RDSGroup* group, int ref);
|
||||||
void destroy_lua();
|
void destroy_lua();
|
||||||
@@ -28,7 +28,7 @@ void get_rds_eon_group(RDSEncoder* enc, RDSGroup *group);
|
|||||||
void get_rds_ert_group(RDSEncoder* enc, RDSGroup *group);
|
void get_rds_ert_group(RDSEncoder* enc, RDSGroup *group);
|
||||||
uint8_t get_rds_custom_groups(RDSEncoder* enc, RDSGroup *group);
|
uint8_t get_rds_custom_groups(RDSEncoder* enc, RDSGroup *group);
|
||||||
uint8_t get_rds_custom_groups2(RDSEncoder* enc, RDSGroup *group);
|
uint8_t get_rds_custom_groups2(RDSEncoder* enc, RDSGroup *group);
|
||||||
void get_rdsp_lua_group(RDSGroup *group);
|
int get_rdsp_lua_group(RDSGroup *group);
|
||||||
void get_rds_user_oda_group(RDSEncoder* enc, RDSGroup *group);
|
void get_rds_user_oda_group(RDSEncoder* enc, RDSGroup *group);
|
||||||
int get_rds_user_oda_group_content(RDSEncoder* enc, RDSGroup *group);
|
int get_rds_user_oda_group_content(RDSEncoder* enc, RDSGroup *group);
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ static void get_rds_sequence_group(RDSEncoder* enc, RDSGroup *group, char* grp,
|
|||||||
get_rds_fasttuning_group(enc, group);
|
get_rds_fasttuning_group(enc, group);
|
||||||
break;
|
break;
|
||||||
case 'L':
|
case 'L':
|
||||||
get_rdsp_lua_group(group);
|
if(get_rdsp_lua_group(group) == 0) get_rds_ps_group(enc, group);
|
||||||
break;
|
break;
|
||||||
case 'O':
|
case 'O':
|
||||||
get_rds_user_oda_group(enc, group);
|
get_rds_user_oda_group(enc, group);
|
||||||
|
|||||||
@@ -366,9 +366,10 @@ uint8_t get_rds_custom_groups2(RDSEncoder* enc, RDSGroup *group) {
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
void get_rdsp_lua_group(RDSGroup *group) {
|
int get_rdsp_lua_group(RDSGroup *group) {
|
||||||
lua_group(group);
|
int generated = lua_group(group);
|
||||||
group->is_type_b = (IS_TYPE_B(group->b) != 0);
|
if(generated) group->is_type_b = (IS_TYPE_B(group->b) != 0);
|
||||||
|
return generated;
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_rds_user_oda_group(RDSEncoder* enc, RDSGroup *group) {
|
void get_rds_user_oda_group(RDSEncoder* enc, RDSGroup *group) {
|
||||||
|
|||||||
@@ -39,14 +39,13 @@ void poll_udp_server() {
|
|||||||
static char buf[BUF_SIZE];
|
static char buf[BUF_SIZE];
|
||||||
static char cmd_buf[BUF_SIZE];
|
static char cmd_buf[BUF_SIZE];
|
||||||
static char cmd_output[BUF_SIZE];
|
static char cmd_output[BUF_SIZE];
|
||||||
ssize_t bytes_read;
|
|
||||||
|
|
||||||
if (poll(&poller, 1, UDP_READ_TIMEOUT_MS) <= 0) return;
|
if (poll(&poller, 1, UDP_READ_TIMEOUT_MS) <= 0) return;
|
||||||
if (!(poller.revents & POLLIN)) return;
|
if (!(poller.revents & POLLIN)) return;
|
||||||
|
|
||||||
memset(buf, 0, BUF_SIZE);
|
memset(buf, 0, BUF_SIZE);
|
||||||
client_len = sizeof(client_addr);
|
client_len = sizeof(client_addr);
|
||||||
bytes_read = recvfrom(sockfd, buf, BUF_SIZE - 1, 0, (struct sockaddr *)&client_addr, &client_len);
|
ssize_t bytes_read = recvfrom(sockfd, buf, BUF_SIZE - 1, 0, (struct sockaddr *)&client_addr, &client_len);
|
||||||
if (bytes_read <= 0) return;
|
if (bytes_read <= 0) return;
|
||||||
|
|
||||||
buf[bytes_read] = '\0';
|
buf[bytes_read] = '\0';
|
||||||
@@ -62,10 +61,7 @@ void poll_udp_server() {
|
|||||||
run_lua(cmd_buf, cmd_output);
|
run_lua(cmd_buf, cmd_output);
|
||||||
|
|
||||||
size_t out_len = strlen(cmd_output);
|
size_t out_len = strlen(cmd_output);
|
||||||
if (out_len > 0) {
|
if (out_len > 0 && sendto(sockfd, cmd_output, out_len, 0, (struct sockaddr *)&client_addr, client_len) == -1) perror("sendto"); // no walrus
|
||||||
ssize_t sent = sendto(sockfd, cmd_output, out_len, 0, (struct sockaddr *)&client_addr, client_len);
|
|
||||||
if (sent == -1) perror("sendto");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
token = strtok(NULL, "\r\n");
|
token = strtok(NULL, "\r\n");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user