HNHacker News
TopNewBestAskShowJobs

Snaipe

233 karma · joined June 21, 2013

submissionscomments
Snaipe··on Wssdl – WireShark-Specific Dissector Language
This means that if you distribute your dissector, you have to make your sources available.

This is nothing new though: all wireshark plugins must be GPL, since the API itself they rely on is GPL.

Snaipe··on Wssdl – WireShark-Specific Dissector Language
This is because wssdl is still within the boundaries of the lua grammar: the file you provide is still lua, so you have to abide by its rule.

I experimented with a key/value approach on the syntax itself (something like `{ src_port = u16 }` or `{ src_port = 16 }`), which was nicer, but the problem was that, in lua, table literals are unordered. The current approach uses the method syntax (`a:b()`) as a nice workaround, but this mandates the use of parenthesis after the type and other specifiers. This is fine though since a lot of the provided types are parameterized (e.g. `bytes(n)` which takes a number of octets)

Snaipe··on Show HN: Rst2ansi – a rst document renderer for your terminal
I originally made this for an interactive index where you can query some document parts, and these parts are written in rst -- in essence, it's almost the same: rendering an arbitrary document into a string, that you may or may not manipulate later.
Snaipe··on Show HN: Rst2ansi – a rst document renderer for your terminal
Man pages are their own thing -- although the end result could be the same with some aesthetic differences (man pages does not support colors per-se, though with a config you could style your titles or emphasis).

rst2ansi is a more generic document renderer, that may be used in another program to render document parts. It doesn't convert the document to an intermediate man page, nor specifically formats the document as, well, documentation.

Snaipe··on Show HN: Rst2ansi – a rst document renderer for your terminal
Author here.

This software is still in alpha, and lacks in both handling some reST features and style extensibility, but is still pretty much functional.

I made this for another project of mine where I needed to render some document parts over the terminal, and decided to give reST a go.

As always, suggestions are welcome.

Snaipe··on Show HN: A simple algorithm for drawing complex tables
Author here. This was fun to make, although I'm sure this algorithm is absolutely nothing new.

An implementation of this for rendering tables as rst-style ascii is available here: https://github.com/Snaipe/table2ascii

As always, suggestions are welcome.

Snaipe··on Show HN: Writing modern C unit tests with Criterion
Because C hasn't been a subset of C++ since C99, there are plenty of case where trying to do C in C++ is awkward or just not possible with standard C++:

First, you'd have to wrap your header inclusions in `extern "C"` to disable mangling, then you would have to make sure you static_cast all your pointers where normally `void*` conversions would have done its job.

Furthermore, all interfaces relying on designated initializers and compound literals are broken unless you decide to compile in nonstandard GNU C++.

And there are more incompatibilities, such as using `static` or `const` in array parameter declarations or using VLA in macros which are not recognized by C++.

It's all about using the right tool for the right job, ultimately.

Snaipe··on Show HN: Writing modern C unit tests with Criterion
Macros are used to handle platform specific details, for the most part. I don't think it's that opaque, but then again I might be biased.
Snaipe··on Show HN: Writing modern C unit tests with Criterion
Google Test requires you to write your tests in C++ rather than C; so there was times I just could not use it.
Snaipe··on Show HN: Writing modern C unit tests with Criterion
By default, if the test raises any signal or exits with anything other than 0, the test fails.

Otherwise, you can't (yet!) test if the code exits with a specific value nor simply redirect input/output, but I'll be sure to take these suggestions into account, thanks!

Both will be implemented quite soon.

Snaipe··on Show HN: Writing modern C unit tests with Criterion
Actually, I didn't know about it until now! The project uses a similar approach to mine, by parsing the DIE tree produced by dwarf, which means that it won't work if you're not compiling with -g.

It also uses some very platform specific stuff, so windows & os x are out, too.

Very well made nonetheless.

Snaipe··on Show HN: Writing modern C unit tests with Criterion
Developer here.

I made this unit testing framework out of frustrations I had (and still have) with other C frameworks like CUnit or Check.

I wanted to make something much more simple, yet as powerful, and I think (and hope) I nailed it pretty much after a few months of work.

If you have any questions or suggestions, feel free to ask :)

Snaipe··on [dead]
Developer here. If you have any suggestion/criticism on the project, I'd be happy to know.

What this brings on the table compared to other frameworks is a very simple way to write tests, while giving the programmer enough liberty to do what he wants.

Criterion achieves that by implementing a xUnit structure with automatic test registration using a declarative syntax -- which means you can be very expressive with the way you declare your tests and suite in a few lines of code. The rest is handled by criterion itself and the default main it provides.

Samples: https://github.com/Snaipe/Criterion/blob/bleeding/samples

Documentation: http://criterion.readthedocs.org/en/latest/

Snaipe··on [dead]
Developer here. I'll be happy to answer or listen to any question/criticism.

The library is currently supported on Linux and Mac OS X.

Snaipe··on Show HN: Criterion – A new C unit testing framework
Developer here, I would be happy to answer any question that you have. If you have any suggestions/criticism, I would gladly hear it!
Snaipe··on Show HN: A new unit testing framework for C
Developer here, if anyone has suggestions/criticism, I would be glad to listen.

AMA.

Snaipe··on Show HN: Smart pointers for the C programming language
If a function may or may not return, and it is not marked for inlining, even gcc cannot infer whenever the variable exits the scope, so no. You have to be extra careful anyways when using context switches.
Snaipe··on Show HN: Smart pointers for the C programming language
Not tested, but since longjmp has __attribute__ ((noreturn)), it should.
Snaipe··on Show HN: Smart pointers for the C programming language
I pretty much explain all that in the article[1], but here is the gist of it:

* I implemented smalloc and sfree to respectively allocate and deallocate a memory block with prepended metadata

* I use a GNU variable attribute called cleanup to run sfree when the variable goes out of scope

* I made some macros to have some syntactic sugar on top of that

[1] - http://snaipe.me/c/c-smart-pointers/

Snaipe··on Show HN: Smart pointers for the C programming language
I've read with great interest the source of libCello when I first saw it a few days ago on reddit, it seems like a fun experiment. Good luck with your project ! :)
Snaipe··on Show HN: Smart pointers for the C programming language
Yep, but if I just let the system get all the memory back, valgrind would have yelled at us for leaking memory, and it would have been detected by the testing system, slapping us in the face with a malus on our final grade.
Snaipe··on Show HN: Smart pointers for the C programming language
I have to polish a bit my python test suite, but it's coming ;)
Snaipe··on Show HN: Smart pointers for the C programming language
Release tarballs can be uploaded on a third party, I usually don't like to commit binary blobs, especially releases, since you could just clone the release tag and run make distcheck. I'll commit a m4/.keep.
Snaipe··on Show HN: Smart pointers for the C programming language
I guess you're right. This was mostly an exercise on the attributes provided by gcc and clang/llvm, since I haven't seen anything really using RAII.
Snaipe··on Show HN: Smart pointers for the C programming language
I've only been actively programming in C for the past three years, so I'm not that much informed either, but from my researches on the subject, I haven't seen any. The probable reason behind this is that most people programming in C wanting automatic memory management will use the Boehm-Demers-Weiser garbage collector (?)
Snaipe··on Show HN: Smart pointers for the C programming language
Haha, I guess, but I think it's not about using them all over your code base -- there are always pros and cons in using RAII, smart pointers, GCs, and manual memory management, it's the programmer's job to balance it correctly.
Snaipe··on Show HN: Smart pointers for the C programming language
Ah, yes, good point. Great care should be taken for these cases to not happen.
Snaipe··on Show HN: Smart pointers for the C programming language
Not really, otherwise even the standard library would not exist, and we would manually ask pages to the kernel every time we want memory.

C, as a language, is indeed low level, but that does not mean that programs and libraries shouldn't build abstractions on top of the low level interface.

Snaipe··on Show HN: Smart pointers for the C programming language
I guess it's more about writing less & better than using known functions -- in the same reasoning, I /could/ use new/delete in C++, but I always end up using unique_ptr<T>(...) because it's just better, and we usually don't really know/care about the implementation details.

Now I realize that the comparison I made isn't fair since unique_ptr<T> is standard C++ (and hence, polished), and mine isn't and will never be standard C, but abstraction here is not that much of a threat to understanding -- in the end, it's still syntactic sugar on top of smalloc/sfree.

As a last word, I'll say that this is mostly a toy project, and I probably won't have the occasion to fully use it. This is just a proof of concept to say that it is possible to have modern idioms in C.

Snaipe··on Show HN: Smart pointers for the C programming language
Yup, these are just pointers, usage is still the same, and no cast/special functions are needed to manipulate them.
Page 1 of 2Next →