Exemple #1
0
int store_file_to_array(const char *file, int **arr)
{
	FILE *fd;
	char buf[32] = {0};
	int count; // count elements in file

	*arr = NULL;

	fd = fopen(file, "r");
	if (fd == NULL) {
		perror(file);
		return -1;
	}

	init_array();
	count = 0;
	while (fgets(buf, ARRAY_SIZE(buf), fd) != NULL) {
		int v;
		count++;
		v = strtol(buf, NULL, 10);
		append_to_array(arr, v);
	}

	array_resize(arr, count);
	fclose(fd);

	return count;
}
Exemple #2
0
int main(int argc, char** argv){
	int arrlen = 0;
	uint8_t *arr = NULL;
	char* textout;
	char* assout;
	int i;
	
	if (argc < 2){
		printf("usage: %s \"HEX-STRING\"\n",argv[0]);
		return 1;
	} else {
		unsigned int nv;
		while (sscanf(argv[1],"%X %*s",&nv) > 0){
			#ifdef DEBUG
				printf("read %x\n",nv);
			#endif
			arr = append_to_array(arr,nv,arrlen);
			arrlen++;
			argv[1] = &(*argv[1]++);
			argv[1] = &(*argv[1]++);
			argv[1] = &(*argv[1]++);
		}
	}
		
	#ifdef VERBOSE
		printf("Input from command line: ");
		for (i = 0; i < arrlen; i++){
			printf("%02X ",arr[i]);
		}
		printf("\n");
	#endif
	
	textout = parseARIBB24subtitleToText(arr,arrlen);
	assout = parseARIBB24subtitleToASS(arr,arrlen);
	printf("\n\nText:\n%s\n",textout);
	printf("\nASS-line:\n%s\n",assout);
	return 0;
}