Skip to content

Instantly share code, notes, and snippets.

@cloudrain21
cloudrain21 / gist:04d3bd795d46e5f811af
Created February 4, 2016 01:57
use variable name as another variable's name
# use variable name as another variable's name
foobar="xx"
name=foobar
echo ${!name}
@cloudrain21
cloudrain21 / rtf.cpp
Last active January 16, 2016 03:30
recovery test framework
#include "rth.h"
#ifdef _RTF_TEST
cmnRTFInfo gTestCaseMap[MAX_RTF_HASH];
static int cmnRTFGetHashVal ( const char* aTestString , int aStrLen )
{
int i;
unsigned int sKey = 0;
#define VOMIT_ON_FAILURE(a) do { if (0 != (a)) { VOMIT_ABORT(errno, #a); } } while (0)
#define VOMIT_ON_FAILURE_NO_ERRNO(a) do { int err = (a); if (0 != err) { VOMIT_ABORT(err, #a); } } while (0)
#define VOMIT_ABORT(err, str) do { int code = (err); fprintf(stderr, "%s failed on line %d in file %s: %d (%s)\n", str, __LINE__, __FILE__, code, strerror(code)); abort(); } while(0)