Using new utility function str_startswith, to get rid of many sizeof:s and hardcoded constants.
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@1009 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
parent
def2b08c1a
commit
e82a259ad2
2
disk.c
2
disk.c
@ -997,7 +997,7 @@ FsVolumeInfo(char *fpath)
|
|||||||
|
|
||||||
while ((e = getmntent(fdfs)))
|
while ((e = getmntent(fdfs)))
|
||||||
{
|
{
|
||||||
if (strncmp(fpath, e->mnt_dir, strlen(fpath)) == 0)
|
if (str_startswith(e->mnt_dir, fpath))
|
||||||
{
|
{
|
||||||
strcpy(info.type, e->mnt_type);
|
strcpy(info.type, e->mnt_type);
|
||||||
strcpy(info.name, e->mnt_fsname);
|
strcpy(info.name, e->mnt_fsname);
|
||||||
|
1
proto.h
1
proto.h
@ -117,6 +117,7 @@ void unimpl(char *format, ...);
|
|||||||
void hexdump(unsigned char *p, unsigned int len);
|
void hexdump(unsigned char *p, unsigned int len);
|
||||||
char *next_arg(char *src, char needle);
|
char *next_arg(char *src, char needle);
|
||||||
void toupper_str(char *p);
|
void toupper_str(char *p);
|
||||||
|
BOOL str_startswith(const char *s, const char *prefix);
|
||||||
char *l_to_a(long N, int base);
|
char *l_to_a(long N, int base);
|
||||||
int load_licence(unsigned char **data);
|
int load_licence(unsigned char **data);
|
||||||
void save_licence(unsigned char *data, int length);
|
void save_licence(unsigned char *data, int length);
|
||||||
|
31
rdesktop.c
31
rdesktop.c
@ -605,17 +605,17 @@ main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'x':
|
case 'x':
|
||||||
if (strncmp("modem", optarg, 1) == 0)
|
if (str_startswith(optarg, "m")) /* modem */
|
||||||
{
|
{
|
||||||
g_rdp5_performanceflags =
|
g_rdp5_performanceflags =
|
||||||
RDP5_NO_WALLPAPER | RDP5_NO_FULLWINDOWDRAG |
|
RDP5_NO_WALLPAPER | RDP5_NO_FULLWINDOWDRAG |
|
||||||
RDP5_NO_MENUANIMATIONS | RDP5_NO_THEMING;
|
RDP5_NO_MENUANIMATIONS | RDP5_NO_THEMING;
|
||||||
}
|
}
|
||||||
else if (strncmp("broadband", optarg, 1) == 0)
|
else if (str_startswith(optarg, "b")) /* broadband */
|
||||||
{
|
{
|
||||||
g_rdp5_performanceflags = RDP5_NO_WALLPAPER;
|
g_rdp5_performanceflags = RDP5_NO_WALLPAPER;
|
||||||
}
|
}
|
||||||
else if (strncmp("lan", optarg, 1) == 0)
|
else if (str_startswith(optarg, "l")) /* lan */
|
||||||
{
|
{
|
||||||
g_rdp5_performanceflags = RDP5_DISABLE_NOTHING;
|
g_rdp5_performanceflags = RDP5_DISABLE_NOTHING;
|
||||||
}
|
}
|
||||||
@ -631,7 +631,7 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
case 'r':
|
case 'r':
|
||||||
|
|
||||||
if (strncmp("sound", optarg, 5) == 0)
|
if (str_startswith(optarg, "sound"))
|
||||||
{
|
{
|
||||||
optarg += 5;
|
optarg += 5;
|
||||||
|
|
||||||
@ -640,17 +640,17 @@ main(int argc, char *argv[])
|
|||||||
*optarg++;
|
*optarg++;
|
||||||
while ((p = next_arg(optarg, ',')))
|
while ((p = next_arg(optarg, ',')))
|
||||||
{
|
{
|
||||||
if (strncmp("remote", optarg, 6) == 0)
|
if (str_startswith(optarg, "remote"))
|
||||||
flags |= RDP_LOGON_LEAVE_AUDIO;
|
flags |= RDP_LOGON_LEAVE_AUDIO;
|
||||||
|
|
||||||
if (strncmp("local", optarg, 5) == 0)
|
if (str_startswith(optarg, "local"))
|
||||||
#ifdef WITH_RDPSND
|
#ifdef WITH_RDPSND
|
||||||
g_rdpsnd = True;
|
g_rdpsnd = True;
|
||||||
#else
|
#else
|
||||||
warning("Not compiled with sound support\n");
|
warning("Not compiled with sound support\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (strncmp("off", optarg, 3) == 0)
|
if (str_startswith(optarg, "off"))
|
||||||
#ifdef WITH_RDPSND
|
#ifdef WITH_RDPSND
|
||||||
g_rdpsnd = False;
|
g_rdpsnd = False;
|
||||||
#else
|
#else
|
||||||
@ -669,24 +669,24 @@ main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (strncmp("disk", optarg, 4) == 0)
|
else if (str_startswith(optarg, "disk"))
|
||||||
{
|
{
|
||||||
/* -r disk:h:=/mnt/floppy */
|
/* -r disk:h:=/mnt/floppy */
|
||||||
disk_enum_devices(&g_num_devices, optarg + 4);
|
disk_enum_devices(&g_num_devices, optarg + 4);
|
||||||
}
|
}
|
||||||
else if (strncmp("comport", optarg, 7) == 0)
|
else if (str_startswith(optarg, "comport"))
|
||||||
{
|
{
|
||||||
serial_enum_devices(&g_num_devices, optarg + 7);
|
serial_enum_devices(&g_num_devices, optarg + 7);
|
||||||
}
|
}
|
||||||
else if (strncmp("lptport", optarg, 7) == 0)
|
else if (str_startswith(optarg, "lptport"))
|
||||||
{
|
{
|
||||||
parallel_enum_devices(&g_num_devices, optarg + 7);
|
parallel_enum_devices(&g_num_devices, optarg + 7);
|
||||||
}
|
}
|
||||||
else if (strncmp("printer", optarg, 7) == 0)
|
else if (str_startswith(optarg, "printer"))
|
||||||
{
|
{
|
||||||
printer_enum_devices(&g_num_devices, optarg + 7);
|
printer_enum_devices(&g_num_devices, optarg + 7);
|
||||||
}
|
}
|
||||||
else if (strncmp("clientname", optarg, 7) == 0)
|
else if (str_startswith(optarg, "clientname"))
|
||||||
{
|
{
|
||||||
g_rdpdr_clientname = xmalloc(strlen(optarg + 11) + 1);
|
g_rdpdr_clientname = xmalloc(strlen(optarg + 11) + 1);
|
||||||
strcpy(g_rdpdr_clientname, optarg + 11);
|
strcpy(g_rdpdr_clientname, optarg + 11);
|
||||||
@ -1170,6 +1170,13 @@ toupper_str(char *p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL
|
||||||
|
str_startswith(const char *s, const char *prefix)
|
||||||
|
{
|
||||||
|
return (strncmp(s, prefix, strlen(prefix)) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* not all clibs got ltoa */
|
/* not all clibs got ltoa */
|
||||||
#define LTOA_BUFSIZE (sizeof(long) * 8 + 1)
|
#define LTOA_BUFSIZE (sizeof(long) * 8 + 1)
|
||||||
|
|
||||||
|
15
xkeymap.c
15
xkeymap.c
@ -311,7 +311,7 @@ xkeymap_read(char *mapname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Include */
|
/* Include */
|
||||||
if (strncmp(line, "include ", sizeof("include ") - 1) == 0)
|
if (str_startswith(line, "include "))
|
||||||
{
|
{
|
||||||
if (!xkeymap_read(line + sizeof("include ") - 1))
|
if (!xkeymap_read(line + sizeof("include ") - 1))
|
||||||
return False;
|
return False;
|
||||||
@ -319,7 +319,7 @@ xkeymap_read(char *mapname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* map */
|
/* map */
|
||||||
if (strncmp(line, "map ", sizeof("map ") - 1) == 0)
|
if (str_startswith(line, "map "))
|
||||||
{
|
{
|
||||||
g_keylayout = strtol(line + sizeof("map ") - 1, NULL, 16);
|
g_keylayout = strtol(line + sizeof("map ") - 1, NULL, 16);
|
||||||
DEBUG_KBD(("Keylayout 0x%x\n", g_keylayout));
|
DEBUG_KBD(("Keylayout 0x%x\n", g_keylayout));
|
||||||
@ -327,7 +327,7 @@ xkeymap_read(char *mapname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* compose */
|
/* compose */
|
||||||
if (strncmp(line, "enable_compose", sizeof("enable_compose") - 1) == 0)
|
if (str_startswith(line, "enable_compose"))
|
||||||
{
|
{
|
||||||
DEBUG_KBD(("Enabling compose handling\n"));
|
DEBUG_KBD(("Enabling compose handling\n"));
|
||||||
g_enable_compose = True;
|
g_enable_compose = True;
|
||||||
@ -335,14 +335,14 @@ xkeymap_read(char *mapname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* sequence */
|
/* sequence */
|
||||||
if (strncmp(line, "sequence", sizeof("sequence") - 1) == 0)
|
if (str_startswith(line, "sequence"))
|
||||||
{
|
{
|
||||||
add_sequence(line + sizeof("sequence") - 1, mapname);
|
add_sequence(line + sizeof("sequence") - 1, mapname);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* keyboard_type */
|
/* keyboard_type */
|
||||||
if (strncmp(line, "keyboard_type ", sizeof("keyboard_type ") - 1) == 0)
|
if (str_startswith(line, "keyboard_type "))
|
||||||
{
|
{
|
||||||
g_keyboard_type = strtol(line + sizeof("keyboard_type ") - 1, NULL, 16);
|
g_keyboard_type = strtol(line + sizeof("keyboard_type ") - 1, NULL, 16);
|
||||||
DEBUG_KBD(("keyboard_type 0x%x\n", g_keyboard_type));
|
DEBUG_KBD(("keyboard_type 0x%x\n", g_keyboard_type));
|
||||||
@ -350,7 +350,7 @@ xkeymap_read(char *mapname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* keyboard_subtype */
|
/* keyboard_subtype */
|
||||||
if (strncmp(line, "keyboard_subtype ", sizeof("keyboard_subtype ") - 1) == 0)
|
if (str_startswith(line, "keyboard_subtype "))
|
||||||
{
|
{
|
||||||
g_keyboard_subtype =
|
g_keyboard_subtype =
|
||||||
strtol(line + sizeof("keyboard_subtype ") - 1, NULL, 16);
|
strtol(line + sizeof("keyboard_subtype ") - 1, NULL, 16);
|
||||||
@ -359,8 +359,7 @@ xkeymap_read(char *mapname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* keyboard_functionkeys */
|
/* keyboard_functionkeys */
|
||||||
if (strncmp(line, "keyboard_functionkeys ", sizeof("keyboard_functionkeys ") - 1) ==
|
if (str_startswith(line, "keyboard_functionkeys "))
|
||||||
0)
|
|
||||||
{
|
{
|
||||||
g_keyboard_functionkeys =
|
g_keyboard_functionkeys =
|
||||||
strtol(line + sizeof("keyboard_functionkeys ") - 1, NULL, 16);
|
strtol(line + sizeof("keyboard_functionkeys ") - 1, NULL, 16);
|
||||||
|
Loading…
Reference in New Issue
Block a user