Skip to content

Commit

Permalink
Add unsigned-typed INI accessors
Browse files Browse the repository at this point in the history
  • Loading branch information
starg2 committed May 11, 2024
1 parent f29d494 commit e2bc023
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 8 deletions.
16 changes: 8 additions & 8 deletions interface/w32g_ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,22 +540,22 @@ 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));
#elif defined(IA_W32G_SYN)
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));
Expand Down Expand Up @@ -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
Expand Down
46 changes: 46 additions & 0 deletions interface/w32g_utl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down
4 changes: 4 additions & 0 deletions interface/w32g_utl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit e2bc023

Please sign in to comment.