tom_modem: fix ld error

This commit is contained in:
fujr 2024-10-22 23:34:39 +08:00
parent 9057ede3b6
commit a51bf815aa
4 changed files with 17 additions and 11 deletions

View File

@ -11,8 +11,12 @@
#include <sys/select.h> #include <sys/select.h>
#include <errno.h> #include <errno.h>
FILE *fdi; // file descriptor for input
FILE *fdo; // file descriptor for output
int tty_fd; // file descriptor for tty device
PROFILE_T s_profile; // global profile
char *self_name; // program name
void _timeout(int signo) void _timeout(int signo)
{ {
err_msg("Exit with Signal %d", signo); err_msg("Exit with Signal %d", signo);

View File

@ -14,13 +14,12 @@
#define DEFAULT_TIMEOUT 3 #define DEFAULT_TIMEOUT 3
// //
extern FILE *fdi; // file descriptor for input
FILE *fdi; // file descriptor for input extern FILE *fdo; // file descriptor for output
FILE *fdo; // file descriptor for output extern int tty_fd; // file descriptor for tty device
int tty_fd; // file descriptor for tty device extern PROFILE_T s_profile; // global profile
extern char *self_name; // program name
PROFILE_T s_profile; // global profile extern struct termios oldtio; // old tty setting
char *self_name; // program name
extern int at(PROFILE_T *profile); extern int at(PROFILE_T *profile);

View File

@ -1,5 +1,6 @@
#include "utils.h" #include "utils.h"
#include "pdu_lib/pdu.h" #include "pdu_lib/pdu.h"
struct termios oldtio;
int match_option(char *option_name) int match_option(char *option_name)
{ {
@ -164,6 +165,7 @@ int open_tty_device(PROFILE_T *profile)
} }
tcflush(tty_fd, TCIOFLUSH); tcflush(tty_fd, TCIOFLUSH);
atexit(clean_up); atexit(clean_up);
if (tty_fd >= 0)
close(tty_fd); close(tty_fd);
tty_fd = open(profile->tty_dev, O_RDWR | O_NOCTTY); tty_fd = open(profile->tty_dev, O_RDWR | O_NOCTTY);
fdi = fdopen(tty_fd, "r"); fdi = fdopen(tty_fd, "r");
@ -305,7 +307,8 @@ static void clean_up()
} }
dbg_msg("Clean up success"); dbg_msg("Clean up success");
tcflush(tty_fd, TCIOFLUSH); tcflush(tty_fd, TCIOFLUSH);
close(tty_fd); // if (tty_fd >= 0)
// close(tty_fd);
} }
static void escape_json(char *input, char *output) static void escape_json(char *input, char *output)

View File

@ -9,7 +9,7 @@ extern PROFILE_T s_profile;
extern FILE *fdi; // file descriptor for input extern FILE *fdi; // file descriptor for input
extern FILE *fdo; // file descriptor for output extern FILE *fdo; // file descriptor for output
extern int tty_fd; // file descriptor for tty device extern int tty_fd; // file descriptor for tty device
struct termios oldtio; // old tty setting extern struct termios oldtio; // old tty setting