diff options
author | unknown <knielsen@knielsen-hq.org> | 2009-06-11 14:53:26 +0200 |
---|---|---|
committer | unknown <knielsen@knielsen-hq.org> | 2009-06-11 14:53:26 +0200 |
commit | 93bcda598bd6c58a7f5ad3d2e860b194325eed9f (patch) | |
tree | 014bccd2ba79d230f4f3cb4ff03f89640b99e1e4 /mysys/mf_iocache2.c | |
parent | d2d7b5bbb6796ee171ef605f5ea61cb782918b72 (diff) | |
parent | 121461f6f3987c4b058d64775f1380016b68896c (diff) | |
download | mariadb-git-93bcda598bd6c58a7f5ad3d2e860b194325eed9f.tar.gz |
Merge latest XtraDB from lp:percona-xtradb into MariaDB.
include/my_sys.h:
Move generic file parsing functions out to shared code, as they are used in several places.
mysys/mf_iocache2.c:
Move generic file parsing functions out to shared code, as they are used in several places.
sql/log_event.cc:
Fix XtraDB build with embedded server.
XtraDB needs access to replication stuff, which is missing in embedded server.
Solved by defining wrapper function for this which is compiled differently for normal and
embedded case.
sql/log_event.h:
Fix XtraDB build with embedded server.
XtraDB needs access to replication stuff, which is missing in embedded server.
Solved by defining wrapper function for this which is compiled differently for normal and
embedded case.
sql/slave.cc:
Move generic file parsing functions out to shared code, as they are used in several places.
Diffstat (limited to 'mysys/mf_iocache2.c')
-rw-r--r-- | mysys/mf_iocache2.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c index 728501e6c50..87346f26b60 100644 --- a/mysys/mf_iocache2.c +++ b/mysys/mf_iocache2.c @@ -464,3 +464,52 @@ process_flags: err: return (size_t) -1; } + +int init_strvar_from_file(char *var, int max_size, IO_CACHE *f, + const char *default_val) +{ + uint length; + DBUG_ENTER("init_strvar_from_file"); + + if ((length=my_b_gets(f,var, max_size))) + { + char* last_p = var + length -1; + if (*last_p == '\n') + *last_p = 0; /* if we stopped on newline, kill it */ + else + { + /* + If we truncated a line or stopped on last char, remove all chars + up to and including newline. + */ + int c; + while (((c=my_b_get(f)) != '\n' && c != my_b_EOF)) + ; + } + DBUG_RETURN(0); + } + else if (default_val) + { + strmake(var, default_val, max_size-1); + DBUG_RETURN(0); + } + DBUG_RETURN(1); +} + +int init_intvar_from_file(int* var, IO_CACHE* f, int default_val) +{ + char buf[32]; + DBUG_ENTER("init_intvar_from_file"); + + if (my_b_gets(f, buf, sizeof(buf))) + { + *var = atoi(buf); + DBUG_RETURN(0); + } + else if (default_val) + { + *var = default_val; + DBUG_RETURN(0); + } + DBUG_RETURN(1); +} |