1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/tools/trace-malloc/formdata.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,64 @@ 1.4 +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#if !defined(__formdata_H__) 1.11 +#define __formdata_H__ 1.12 + 1.13 +/* 1.14 +** formdata.h 1.15 +** 1.16 +** Play (quick and dirty) utility API to parse up form get data into 1.17 +** name value pairs. 1.18 +*/ 1.19 + 1.20 +typedef struct __struct_FormData 1.21 +/* 1.22 +** Structure to hold the breakdown of any form data. 1.23 +** 1.24 +** mNArray Each form datum is a name value pair. 1.25 +** This array holds the names. 1.26 +** You can find the corresponding value at the same index in 1.27 +** mVArray. 1.28 +** Never NULL, but perhpas an empty string. 1.29 +** mVArray Each form datum is a name value pair. 1.30 +** This array holds the values. 1.31 +** You can find the corresponding name at the same index in 1.32 +** mNArray. 1.33 +** Never NULL, but perhpas an empty string. 1.34 +** mNVCount Count of array items in both mNArray and mVArray. 1.35 +** mStorage Should be ignored by users of this API. 1.36 +** In reality holds the duped and decoded form data. 1.37 +*/ 1.38 +{ 1.39 + char** mNArray; 1.40 + char** mVArray; 1.41 + unsigned mNVCount; 1.42 + char* mStorage; 1.43 +} 1.44 +FormData; 1.45 + 1.46 +FormData* FormData_Create(const char* inFormData) 1.47 +/* 1.48 +** Take a contiguous string of form data, possibly hex encoded, and return 1.49 +** the name value pairs parsed up and decoded. 1.50 +** A caller of this routine should call FormData_Destroy at some point. 1.51 +** 1.52 +** inFormData The form data to parse up and decode. 1.53 +** returns FormData* The result of our effort. 1.54 +** This should be passed to FormData_Destroy at some 1.55 +** point of the memory will be leaked. 1.56 +*/ 1.57 +; 1.58 + 1.59 +void FormData_Destroy(FormData* inDestroy) 1.60 +/* 1.61 +** Release to the heap the structure previously created via FormData_Create. 1.62 +** 1.63 +** inDestroy The object to free off. 1.64 +*/ 1.65 +; 1.66 + 1.67 +#endif /* __formdata_H__ */