Commit bb1c3523 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

XDR: Add proper get_string method

parent 7a0173db
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ class XDRInput {
		double get_double();
		uint32_t get_opaque_length();
		char* get_opaque(uint32_t length);
		void get_string(char *target);
};

#endif
+14 −0
Original line number Diff line number Diff line
@@ -61,3 +61,17 @@ char *XDRInput::get_opaque(uint32_t length)
	}
	return ret;
}

void XDRInput::get_string(char* target)
{
	uint16_t length = get_opaque_length();
	uint16_t i;
	for (i = 0; i < length; i++) {
		target[i] = data[pos + i];
	}
	target[i] = 0;
	pos += length;
	if (length % 4) {
		pos += 4 - (length % 4);
	}
}