Implement 'swap' command.

This patch introduces a new command 'swap' that swaps two containers so
that they assume each other's position and geometry.

fixes #917
This commit is contained in:
Ingo Bürk
2016-02-26 22:39:44 +01:00
parent 9bc504ebdb
commit 5f9a5e8d7d
13 changed files with 794 additions and 46 deletions

View File

@ -458,3 +458,20 @@ void kill_nagbar(pid_t *nagbar_pid, bool wait_for_it) {
* waitpid() here. */
waitpid(*nagbar_pid, NULL, 0);
}
/*
* Converts a string into a long using strtol().
* This is a convenience wrapper checking the parsing result. It returns true
* if the number could be parsed.
*/
bool parse_long(const char *str, long *out, int base) {
char *end;
long result = strtol(str, &end, base);
if (result == LONG_MIN || result == LONG_MAX || result < 0 || (end != NULL && *end != '\0')) {
*out = result;
return false;
}
*out = result;
return true;
}