From 186915db036f06a604883b644e40eaf377aedadf Mon Sep 17 00:00:00 2001 From: sotech117 Date: Mon, 18 Sep 2023 18:52:24 -0400 Subject: got it to work, not sure on protocol. --- c | Bin 35150 -> 35150 bytes c.dSYM/Contents/Resources/DWARF/c | Bin 13761 -> 13761 bytes client.c | 2 +- l | Bin 34654 -> 34654 bytes s | Bin 54558 -> 54494 bytes s.dSYM/Contents/Resources/DWARF/s | Bin 21520 -> 21128 bytes snowcast_control | Bin 20992 -> 35165 bytes snowcast_control.dSYM/Contents/Info.plist | 20 +++++++++++++++ .../Contents/Resources/DWARF/snowcast_control | Bin 0 -> 13761 bytes snowcast_server | Bin 25336 -> 35116 bytes snowcast_server.dSYM/Contents/Info.plist | 20 +++++++++++++++ .../Contents/Resources/DWARF/snowcast_server | Bin 0 -> 15573 bytes snowcast_server_concurrent.c | 27 +++++++-------------- 13 files changed, 50 insertions(+), 19 deletions(-) create mode 100644 snowcast_control.dSYM/Contents/Info.plist create mode 100644 snowcast_control.dSYM/Contents/Resources/DWARF/snowcast_control create mode 100644 snowcast_server.dSYM/Contents/Info.plist create mode 100644 snowcast_server.dSYM/Contents/Resources/DWARF/snowcast_server diff --git a/c b/c index a1f2a86..8e2e138 100755 Binary files a/c and b/c differ diff --git a/c.dSYM/Contents/Resources/DWARF/c b/c.dSYM/Contents/Resources/DWARF/c index c325e9f..7af6442 100644 Binary files a/c.dSYM/Contents/Resources/DWARF/c and b/c.dSYM/Contents/Resources/DWARF/c differ diff --git a/client.c b/client.c index 6e6c95a..5edff63 100644 --- a/client.c +++ b/client.c @@ -156,7 +156,7 @@ void *reply_thread_routine(void* args) { printf("client: replyType: %d, stringSize: %d\n", buf[0], buf[1]); // print the while buffer by char for (int i = 0; i < recvbytes; i++) { - printf("%d", buf[i]); + printf("%c ", buf[i]); } struct Reply reply; diff --git a/l b/l index 265f692..52aca28 100755 Binary files a/l and b/l differ diff --git a/s b/s index 63b39b5..b664e12 100755 Binary files a/s and b/s differ diff --git a/s.dSYM/Contents/Resources/DWARF/s b/s.dSYM/Contents/Resources/DWARF/s index 09cab17..feff9cb 100644 Binary files a/s.dSYM/Contents/Resources/DWARF/s and b/s.dSYM/Contents/Resources/DWARF/s differ diff --git a/snowcast_control b/snowcast_control index 24fe551..1ab5778 100755 Binary files a/snowcast_control and b/snowcast_control differ diff --git a/snowcast_control.dSYM/Contents/Info.plist b/snowcast_control.dSYM/Contents/Info.plist new file mode 100644 index 0000000..afe5b44 --- /dev/null +++ b/snowcast_control.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.snowcast_control + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/snowcast_control.dSYM/Contents/Resources/DWARF/snowcast_control b/snowcast_control.dSYM/Contents/Resources/DWARF/snowcast_control new file mode 100644 index 0000000..76fce35 Binary files /dev/null and b/snowcast_control.dSYM/Contents/Resources/DWARF/snowcast_control differ diff --git a/snowcast_server b/snowcast_server index 8a4c1cc..444d321 100755 Binary files a/snowcast_server and b/snowcast_server differ diff --git a/snowcast_server.dSYM/Contents/Info.plist b/snowcast_server.dSYM/Contents/Info.plist new file mode 100644 index 0000000..789e734 --- /dev/null +++ b/snowcast_server.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.snowcast_server + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/snowcast_server.dSYM/Contents/Resources/DWARF/snowcast_server b/snowcast_server.dSYM/Contents/Resources/DWARF/snowcast_server new file mode 100644 index 0000000..0123b4a Binary files /dev/null and b/snowcast_server.dSYM/Contents/Resources/DWARF/snowcast_server differ diff --git a/snowcast_server_concurrent.c b/snowcast_server_concurrent.c index 4387407..110792d 100644 --- a/snowcast_server_concurrent.c +++ b/snowcast_server_concurrent.c @@ -379,33 +379,24 @@ void *select_thread(void *arg) { // update station of user update_user_station(i, ntohs(command.number)); - const char* song_name = station_data[station_num].filePath; - size_t song_name_size = strlen(song_name); // don't add 1, don't want to include the null terminator - struct Announce *announce = malloc(sizeof *announce + song_name_size); + char* file_path = station_data[station_num].filePath; + int len_file_path = strlen(file_path); - printf("song_name: %s\n", song_name); + char *send_buffer = malloc(len_file_path+2); + send_buffer[0] = 3; + send_buffer[1] = len_file_path; - announce->replyType = 3; - announce->songnameSize = song_name_size; + memcpy(send_buffer + 2, file_path, len_file_path); - announce->songname = malloc(song_name_size); - memcpy(announce->songname, song_name, song_name_size); - - // print out all fields on announce on one line - printf("announce: %d %d %s\n", announce->replyType, announce->songnameSize, announce->songname); - - char* send_buffer[sizeof(struct Announce) + song_name_size]; - memcpy(send_buffer, announce, sizeof(struct Announce)); - memcpy(send_buffer+sizeof(struct Announce), song_name, song_name_size); + printf("buffer: %s\n", send_buffer); int bytessent; - if ((bytessent = send(newfd, send_buffer, sizeof(struct Announce) + song_name_size, 0)) == -1) + if ((bytessent = send(newfd, send_buffer, len_file_path + 2, 0)) == -1) perror("send"); // print the number of bytes sent printf("sent %d bytes\n", bytessent); - free(announce->songname); - free(announce); + free(send_buffer); } else { // send back in invalid command -- cgit v1.2.3-70-g09d2