mirror of
https://github.com/joncampbell123/dosbox-x.git
synced 2025-05-09 03:41:10 +08:00
Port phonebook feature from dosbox-staging
e905a6bd5d
create a phoneboox-<version>.txt file with the layout:
<number> <host:port>
When you dial the number, it will actually connect to the specified host. This is needed
as not all programs allow to enter a hostname or IP address.
It also adds a new property to the config file in the [serial] section named phonebookfile=
This commit is contained in:
parent
a79fae60fa
commit
1acb01b95b
@ -80,4 +80,33 @@ static inline bool is_power_of_2(Bitu val) {
|
||||
* For more info see https://graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2*/
|
||||
}
|
||||
|
||||
/// Copy a string into C array
|
||||
///
|
||||
/// This function copies string pointed by src to fixed-size buffer dst.
|
||||
/// At most N bytes from src are copied, where N is size of dst.
|
||||
/// If exactly N bytes are copied, then terminating null byte is put
|
||||
/// into buffer, thus buffer overrun is prevented.
|
||||
///
|
||||
/// Function returns pointer to buffer to be compatible with std::strcpy.
|
||||
///
|
||||
/// Usage:
|
||||
///
|
||||
/// char buffer[2];
|
||||
/// safe_strcpy(buffer, "abc");
|
||||
/// // buffer is filled with "a"
|
||||
|
||||
template<size_t N>
|
||||
char * safe_strcpy(char (& dst)[N], const char * src) noexcept {
|
||||
snprintf(dst, N, "%s", src);
|
||||
return & dst[0];
|
||||
}
|
||||
|
||||
template<size_t N>
|
||||
char * safe_strcat(char (& dst)[N], const char * src) noexcept {
|
||||
strncat(dst, src, N - strnlen(dst, N) - 1);
|
||||
return & dst[0];
|
||||
}
|
||||
|
||||
#define safe_strncpy(a,b,n) do { strncpy((a),(b),(n)-1); (a)[(n)-1] = 0; } while (0)
|
||||
|
||||
#endif
|
||||
|
@ -2796,6 +2796,9 @@ void DOSBOX_SetupConfigSections(void) {
|
||||
Pmulti_remain->GetSection()->Add_string("parameters",Property::Changeable::WhenIdle,"");
|
||||
Pmulti_remain->Set_help("see serial1");
|
||||
|
||||
Pstring = secprop->Add_path("phonebookfile", Property::Changeable::OnlyAtStart, "phonebook-" VERSION ".txt");
|
||||
Pstring->Set_help("File used to map fake phone numbers to addresses.");
|
||||
|
||||
// printer redirection parameters
|
||||
secprop = control->AddSection_prop("printer", &Null_Init);
|
||||
Pbool = secprop->Add_bool("printer", Property::Changeable::WhenIdle, true);
|
||||
|
@ -1337,6 +1337,11 @@ public:
|
||||
// COM1 is a 8251 UART, while COM2 and higher if they exist are 8250/16xxx UARTs
|
||||
if (IS_PC98_ARCH) return;
|
||||
|
||||
#if C_MODEM
|
||||
const Prop_path *pbFilename = section->Get_path("phonebookfile");
|
||||
MODEM_ReadPhonebook(pbFilename->realpath);
|
||||
#endif
|
||||
|
||||
char s_property[] = "serialx";
|
||||
for(Bit8u i = 0; i < 4; i++) {
|
||||
// get the configuration property
|
||||
|
@ -50,6 +50,8 @@ enum ResTypes {
|
||||
#define TEL_CLIENT 0
|
||||
#define TEL_SERVER 1
|
||||
|
||||
bool MODEM_ReadPhonebook(const std::string &filename);
|
||||
|
||||
class CFifo {
|
||||
public:
|
||||
CFifo(Bitu _size) {
|
||||
@ -166,9 +168,9 @@ public:
|
||||
|
||||
void EnterIdleState();
|
||||
void EnterConnectedState();
|
||||
|
||||
|
||||
void openConnection(void);
|
||||
bool Dial(char * host);
|
||||
bool Dial(const char *host);
|
||||
void AcceptIncomingCall(void);
|
||||
Bitu ScanNumber(char * & scan);
|
||||
char GetChar(char * & scan);
|
||||
|
Loading…
x
Reference in New Issue
Block a user