From e2bc023e9dfbaea09120482c7c4d25f59ad2837e Mon Sep 17 00:00:00 2001 From: starg2 <75976488+starg2@users.noreply.github.com> Date: Sat, 11 May 2024 21:58:52 +0900 Subject: [PATCH] Add unsigned-typed INI accessors --- interface/w32g_ini.c | 16 +++++++-------- interface/w32g_utl.c | 46 ++++++++++++++++++++++++++++++++++++++++++++ interface/w32g_utl.h | 4 ++++ 3 files changed, 58 insertions(+), 8 deletions(-) diff --git a/interface/w32g_ini.c b/interface/w32g_ini.c index 6b3d3adc..cda22937 100644 --- a/interface/w32g_ini.c +++ b/interface/w32g_ini.c @@ -540,10 +540,10 @@ void LoadIniFile(SETTING_PLAYER *sp, SETTING_TIMIDITY *st) #if defined(WINDRV_SETUP) IniGetKeyInt(INI_SEC_TIMIDITY,"processPriority",&(st->processPriority)); - IniGetKeyInt(INI_SEC_TIMIDITY,"syn_ThreadPriority",&(st->syn_ThreadPriority)); + IniGetKeyULong(INI_SEC_TIMIDITY,"syn_ThreadPriority",&(st->syn_ThreadPriority)); IniGetKeyInt(INI_SEC_TIMIDITY,"SynShTime",&(st->SynShTime)); if ( st->SynShTime < 0 ) st->SynShTime = 0; - IniGetKeyInt(INI_SEC_TIMIDITY,"opt_rtsyn_latency",&(st->opt_rtsyn_latency)); + IniGetKeyUInt32(INI_SEC_TIMIDITY,"opt_rtsyn_latency",&(st->opt_rtsyn_latency)); if ( st->opt_rtsyn_latency < 1 ) st->opt_rtsyn_latency = 1; if ( st->opt_rtsyn_latency > 1000 ) st->opt_rtsyn_latency = 1000; IniGetKeyInt(INI_SEC_TIMIDITY,"opt_rtsyn_skip_aq",&(st->opt_rtsyn_skip_aq)); @@ -551,11 +551,11 @@ void LoadIniFile(SETTING_PLAYER *sp, SETTING_TIMIDITY *st) IniGetKeyIntArray(INI_SEC_TIMIDITY,"SynIDPort",st->SynIDPort,MAX_PORT); IniGetKeyInt(INI_SEC_TIMIDITY,"syn_AutoStart",&(st->syn_AutoStart)); IniGetKeyInt(INI_SEC_TIMIDITY,"processPriority",&(st->processPriority)); - IniGetKeyInt(INI_SEC_TIMIDITY,"syn_ThreadPriority",&(st->syn_ThreadPriority)); + IniGetKeyULong(INI_SEC_TIMIDITY,"syn_ThreadPriority",&(st->syn_ThreadPriority)); IniGetKeyInt(INI_SEC_TIMIDITY,"SynPortNum",&(st->SynPortNum)); IniGetKeyInt(INI_SEC_TIMIDITY,"SynShTime",&(st->SynShTime)); if ( st->SynShTime < 0 ) st->SynShTime = 0; - IniGetKeyInt(INI_SEC_TIMIDITY,"opt_rtsyn_latency",&(st->opt_rtsyn_latency)); + IniGetKeyUInt32(INI_SEC_TIMIDITY,"opt_rtsyn_latency",&(st->opt_rtsyn_latency)); if ( st->opt_rtsyn_latency < 1 ) st->opt_rtsyn_latency = 1; if ( st->opt_rtsyn_latency > 1000 ) st->opt_rtsyn_latency = 1000; IniGetKeyInt(INI_SEC_TIMIDITY,"opt_rtsyn_skip_aq",&(st->opt_rtsyn_skip_aq)); @@ -789,18 +789,18 @@ SaveIniFile(SETTING_PLAYER *sp, SETTING_TIMIDITY *st) #if defined(WINDRV_SETUP) IniPutKeyInt(INI_SEC_TIMIDITY,"processPriority",&(st->processPriority)); - IniPutKeyInt(INI_SEC_TIMIDITY,"syn_ThreadPriority",&(st->syn_ThreadPriority)); + IniPutKeyULong(INI_SEC_TIMIDITY,"syn_ThreadPriority",&(st->syn_ThreadPriority)); IniPutKeyInt(INI_SEC_TIMIDITY,"SynShTime",&(st->SynShTime)); - IniPutKeyInt(INI_SEC_TIMIDITY,"opt_rtsyn_latency",&(st->opt_rtsyn_latency)); + IniPutKeyUInt32(INI_SEC_TIMIDITY,"opt_rtsyn_latency",&(st->opt_rtsyn_latency)); IniPutKeyInt(INI_SEC_TIMIDITY,"opt_rtsyn_skip_aq",&(st->opt_rtsyn_skip_aq)); #elif defined(IA_W32G_SYN) IniPutKeyIntArray(INI_SEC_TIMIDITY,"SynIDPort",st->SynIDPort,MAX_PORT); IniPutKeyInt(INI_SEC_TIMIDITY,"syn_AutoStart",&(st->syn_AutoStart)); IniPutKeyInt(INI_SEC_TIMIDITY,"processPriority",&(st->processPriority)); - IniPutKeyInt(INI_SEC_TIMIDITY,"syn_ThreadPriority",&(st->syn_ThreadPriority)); + IniPutKeyULong(INI_SEC_TIMIDITY,"syn_ThreadPriority",&(st->syn_ThreadPriority)); IniPutKeyInt(INI_SEC_TIMIDITY,"SynPortNum",&(st->SynPortNum)); IniPutKeyInt(INI_SEC_TIMIDITY,"SynShTime",&(st->SynShTime)); - IniPutKeyInt(INI_SEC_TIMIDITY,"opt_rtsyn_latency",&(st->opt_rtsyn_latency)); + IniPutKeyUInt32(INI_SEC_TIMIDITY,"opt_rtsyn_latency",&(st->opt_rtsyn_latency)); IniPutKeyInt(INI_SEC_TIMIDITY,"opt_rtsyn_skip_aq",&(st->opt_rtsyn_skip_aq)); IniPutKeyInt(INI_SEC_TIMIDITY,"opt_use_twsyn_bridge",&(st->opt_use_twsyn_bridge)); #else diff --git a/interface/w32g_utl.c b/interface/w32g_utl.c index fb22c021..93eee585 100644 --- a/interface/w32g_utl.c +++ b/interface/w32g_utl.c @@ -140,6 +140,32 @@ CHAR *INI_SEC_TIMIDITY = "TIMIDITY"; #define INI_MAXLEN 1024 ///r +int +IniGetKeyUInt32(char *section, char *key,uint32 *n) +{ + CHAR buffer[INI_MAXLEN]; + GetPrivateProfileString + (section,key,INI_INVALID,buffer,INI_MAXLEN-1,IniFile); + if(strcasecmp(buffer,INI_INVALID)){ + *n =strtoul(buffer, NULL, 10); + return 0; + } else + return 1; +} + +int +IniGetKeyULong(char *section, char *key,unsigned long *n) +{ + CHAR buffer[INI_MAXLEN]; + GetPrivateProfileString + (section,key,INI_INVALID,buffer,INI_MAXLEN-1,IniFile); + if(strcasecmp(buffer,INI_INVALID)){ + *n =strtoul(buffer, NULL, 10); + return 0; + } else + return 1; +} + int IniGetKeyInt64(char *section, char *key,int64 *n) { @@ -283,6 +309,26 @@ IniGetKeyStringN(char *section, char *key,char *str, int size) return 1; } ///r +int +IniPutKeyUInt32(char *section, char *key,uint32 *n) +{ + CHAR buffer[INI_MAXLEN]; + sprintf(buffer,"%u",*n); + WritePrivateProfileString + (section,key,buffer,IniFile); + return 0; +} + +int +IniPutKeyULong(char *section, char *key,unsigned long *n) +{ + CHAR buffer[INI_MAXLEN]; + sprintf(buffer,"%lu",*n); + WritePrivateProfileString + (section,key,buffer,IniFile); + return 0; +} + int IniPutKeyInt64(char *section, char *key,int64 *n) { diff --git a/interface/w32g_utl.h b/interface/w32g_utl.h index 80ba23b6..707838a2 100644 --- a/interface/w32g_utl.h +++ b/interface/w32g_utl.h @@ -310,6 +310,8 @@ extern int DocFontSize; extern int ListFontSize; extern int TracerFontSize; ///r +extern int IniGetKeyUInt32(char *section, char *key,uint32 *n); +extern int IniGetKeyULong(char *section, char *key,unsigned long *n); extern int IniGetKeyInt64(char *section, char *key,int64 *n); extern int IniGetKeyInt32(char *section, char *key,int32 *n); extern int IniGetKeyInt32Array(char *section, char *key, int32 *n, int arraysize); @@ -320,6 +322,8 @@ extern int IniGetKeyIntArray(char *section, char *key, int *n, int arraysize); extern int IniGetKeyString(char *section, char *key,char *str); extern int IniGetKeyStringN(char *section, char *key,char *str, int size); extern int IniGetKeyFloat(char *section, char *key, FLOAT_T *n); +extern int IniPutKeyUInt32(char *section, char *key,uint32 *n); +extern int IniPutKeyULong(char *section, char *key,unsigned long *n); extern int IniPutKeyInt64(char *section, char *key,int64 *n); extern int IniPutKeyInt32(char *section, char *key,int32 *n); extern int IniPutKeyInt32Array(char *section, char *key, int32 *n, int arraysize);