int main(int argc, char **argv)
{
	int i, j, char_count = 0, byte_count;
	char data[4], *bin;
	FILE *fid;
	if (argc != 2)
	{
		printf("usage: hex2bin <outfile>\n");
		return 1;
	}
	printf("hex2bin\n");

	fid = fopen(argv[1], "w");
	for (i = 0; i < strlen(test_str); i++)
	{
		data[char_count] = test_str[i];
		char_count++;
		if (char_count == 4)
		{
			bin = base642bin(data, &byte_count);
			for (j = 0; j < byte_count; j++)
			{
				//printf("%c", bin[j]);
				fprintf(fid, "%c", bin[j]);
			}
			char_count = 0;
		}
	}
	if (char_count != 0)
		printf("errorrrrrr\n");

	//printf(" '%d'", (int)strlen(test_str));
	fclose(fid);

	return 0;
}
int32_t  write_h264_ps(char *sdp,FILE *fid){

    char *dpos,*data,*temp;
    uint8_t *out;
    int32_t word,len1,len2;
    data = sdp;
    while( (dpos = strstr(data,"="))!=NULL){
	//	len = (int32_t)(dpos-data);
	temp = strtok(data,"=");
	//Can have a , here . Account for it
	if(temp[0]==','){
	    //  len-=1;
	    temp++;
	}

	word = NALU_DELIMIT;
	word = htonl(word);
	nkn_vfs_fwrite(&word,1,sizeof(int32_t),fid);
	len1 = strlen(temp);
	len2 = 3*(len1/4);
	len2 += len1%4;//len1 - (len2*4/3);
	if(len1%4 != 0)
	    len2-=1;
	
	out = (uint8_t*)calloc(sizeof(uint8_t)*len2,1);
	base642bin(temp,len1,out);
	nkn_vfs_fwrite(out,len2,1,fid);
	
	data = dpos+2;
	free(out);	
	out=NULL;
    }

    return VPE_SUCCESS;

}
static char *write_base64_string_to_binary_file(struct Interpreter *interpreter,
	char *base64_string)
/*******************************************************************************
LAST MODIFIED : 25 January 2005

DESCRIPTION :
This wrapper allows the passing of the <base64_string> which is intended to
contain a binary file converted to base64.  This function converts it back to
binary and writes a temporary file for which the filename is returned.
It is up to the calling routine to free the string returned and to
remove the temporary file it refers to.
==============================================================================*/
{
	char *return_string, *binary, data[4];
	FILE *bin_file;
	size_t string_length;
	size_t char_count = 0, byte_count, i, j;
#if ! defined (WIN32)
	char template_name[]="/tmp/perl_interpreterXXXXXX";
#else
	char template_name[MAX_PATH+1];
#endif
	int temp_fd;

	if (base64_string)
	{
		string_length=strlen(base64_string);
		temp_fd=mkstemp(template_name);
		if ((temp_fd != -1) && (bin_file=fdopen(temp_fd, "wb"))
			&& (return_string = (char *)malloc(strlen(template_name)+1)))
		{
			if (string_length % 4 != 0)
			{
				(*interpreter->display_message_function)(ERROR_MESSAGE,
					"write_base64_string_to_binary_file.  Unexpected length: %d",
					string_length);
				return 0;
			}
			for (i = 0; i < string_length; i++)
			{
				data[char_count] = base64_string[i];
				char_count++;
				if (char_count == 4)
				{
					binary = base642bin(data, &byte_count);
					for (j = 0; j < byte_count; j++)
					{
						fprintf(bin_file, "%c", binary[j]);
					}
					char_count = 0;
				}
			}
			fclose(bin_file);
			strcpy(return_string, template_name);
		}
		else
		{
			(*interpreter->display_message_function)(ERROR_MESSAGE,
				"write_base64_string_to_binary_file.  Invalid argument(s)");
			return_string = (char *)NULL;
		}
	}
	else
	{
		(*interpreter->display_message_function)(ERROR_MESSAGE,
			"write_base64_string_to_binary_file.  Invalid argument(s)");
		return_string = (char *)NULL;
	}

	return (return_string);
} /* write_base64_string_to_binary_file */