1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 03:22:48 -05:00

Basic configurability for client-initiated rekeys.

[originally from svn r5027]
This commit is contained in:
Jacob Nevins
2004-12-24 13:39:32 +00:00
parent d0da973746
commit 30896d650e
9 changed files with 116 additions and 23 deletions

33
misc.c
View File

@ -9,6 +9,39 @@
#include <assert.h>
#include "putty.h"
/*
* Parse a string block size specification. This is approximately a
* subset of the block size specs supported by GNU fileutils:
* "nk" = n kilobytes
* "nM" = n megabytes
* "nG" = n gigabytes
* All numbers are decimal, and suffixes refer to powers of two.
* Case-insensitive.
*/
unsigned long parse_blocksize(const char *bs)
{
char *suf;
unsigned long r = strtoul(bs, &suf, 10);
if (*suf != '\0') {
while (isspace(*suf)) suf++;
switch (*suf) {
case 'k': case 'K':
r *= 1024ul;
break;
case 'm': case 'M':
r *= 1024ul * 1024ul;
break;
case 'g': case 'G':
r *= 1024ul * 1024ul * 1024ul;
break;
case '\0':
default:
break;
}
}
return r;
}
/* ----------------------------------------------------------------------
* String handling routines.
*/