The ugliest thing I've ever seen

And it's this. This code is used to tell libVLC (the core of VLC player) to send output to memory instead of allocating its own player window:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
char clock[64],
	cunlock[64],
	cdata[64],
	width[32],
	height[32],
	pitch[32];
const char *vlc_argv[]={
	//...
	"--vout",
	"vmem",
	"--vmem-width" ,
	width,
	"--vmem-height",
	height,
	"--vmem-pitch" ,
	pitch,
	"--vmem-chroma",
	"RV24",
	"--vmem-lock"  ,
	clock,
	"--vmem-unlock",
	cunlock,
	"--vmem-data"  ,
	cdata,
	//...
};
There's no possible way it can get better from this (and it won't). You're probably wondering why not do something that looks less like calling a program. Oh, but that's nothing compared to what you're about to see.
Let's see how those strings are initialized further down:
1
2
3
4
5
6
sprintf(clock,  "%lld",(long long int)lock);
sprintf(cunlock,"%lld",(long long int)unlock);
sprintf(cdata,  "%lld",(long long int)data);
sprintf(width,  "%i",  Width);
sprintf(height, "%i",  Height);
sprintf(pitch,  "%i",  Pitch);
I'm sure those explicit casts are already raising red flags in your brain. If you're standing, I recommend you sit down, or the shock of what you're about to see might knock you off your feet.
Let's take a look at the types of lock, unlock, and ctx, shall we?
1
2
3
4
parameters *data=/*...*/;
//...
void *lock(parameters *);
void unlock(parameters *);

Yes, you just saw that. Someone somewhere thought it was a great idea (or, at least, hilarious) to pass callback pointers and user pointers as strings. Apparently the unsafety of casting function pointers to data pointers (or integers) just wasn't enough for this person, and they decided that a representation conversion was also in order.
Was something like this so much to ask?
1
2
3
4
5
6
7
8
9
10
11
12
libvlc_instance_t *libvlc=libvlc_begin_init();
libvlc_set_enum(libvlc,"output",LIBVLC_VMEM);
libvlc_set_uint(libvlc,"width",width);
libvlc_set_uint(libvlc,"height",height);
libvlc_set_uint(libvlc,"pitch",pitch);
libvlc_set_callback(libvlc,"lock",lock); //We'll have to trust that the user
                                         //won't screw up the function type.
                                         //Alternatively, we could declare more
                                         //functions.
libvlc_set_callback(libvlc,"unlock",unlock);
libvlc_set_data(libvlc,data);
libvlc_end_init(libvlc);

I'm not asking to be aesthetically moved by every library I use, but this is just ridiculous.
No comment.

-Albatross
OH MY GOD, MY EYES.
closed account (1yR4jE8b)
I thought some of the code my classmates in University wrote was horrendous(they could barely write a Java hello world program to save their own lives)...this is quite possibly the worst I have EVER SEEN.
Last edited on
No! Not my VLC! That's just sick.
rofl...
Where did You find this "thing"?^^...
Oh my science... I just gagged and vomited simultaneously.
If you fed that down your compiler it would throw up because that is a trolls dunny!(if you fed my programs down your compiler it would throw up AND explode with vomit, trust me they suck because i couldn't be bothered to read the whole tutorial).
Last edited on
Topic archived. No new replies allowed.