/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk

« back to all changes in this revision

Viewing changes to src/utils.h

  • Committer: Gustav Hartvigsson
  • Date: 2015-04-08 18:25:07 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20150408182507-094jw13yhmi3bhfu
* Added "check" target for testing.
* Changed SRC to SSTS_SRC for future proofing.
* Removed a few "_" from before some struct names. It is not needed.
* Re-wrote how s_object_to_string () works on SError's. Should be faster now, but less safe...
  * To make this work I added SErrorTypeName string array. (Need to surpress the errer it creats).
* Re-orderd SErrorType enum.
* Use s_string_new_fmt () the default method for s_object_to_string ().
* Changed to strdup in some functions in utils.c.
* Added s_current_time () function to get an ISO time string.
* Added some more documentation to utils.h
* !DEBUG -> DEBUG in utils.h
* Added more tests to the test suite.
* Re-Wrote test_macros.h to display time, making it a lil' bit nicer to look at.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
BEGIN_DECLS
32
32
 
 
33
/**
 
34
 * Creats a new C string with the correct length from a long string.
 
35
 * This may be a costly operation.
 
36
 *
 
37
 * The restulting string must be freed by caller.
 
38
 */
33
39
char * s_string_new (const char * s);
34
40
 
 
41
/**
 
42
 * Creats a new C string with the correct length using standard fprint style
 
43
 * format.
 
44
 *
 
45
 * The restulting string must be freed by caller.
 
46
 */
 
47
char * s_string_new_fmt (const char * format, ...);
 
48
 
 
49
/**
 
50
 * Same as s_string_new, but with a set length.
 
51
 *
 
52
 * The restulting string must be freed by caller
 
53
 */
35
54
char * s_string_new_with_len (const char * s, size_t len);
36
55
 
 
56
/**
 
57
 * Returns a C string with the current time (as run).
 
58
 *
 
59
 * The restulting string must be freed by caller.
 
60
 */
 
61
char * s_current_time (void);
 
62
 
 
63
#ifndef strdup
 
64
/* strdup is not ISO C, so we have to declare it somewhare, this should work
 
65
 * even if we do not impliment the function ourselfs.
 
66
 *
 
67
 * This just to supress a compiler warning.
 
68
 */
 
69
char * strdup(const char *str);
 
70
#endif
 
71
 
 
72
/** Just a standard print function. */
37
73
#define s_print(p, ...)\
38
74
  fprintf (stdout, p, ##__VA_ARGS__)
39
75
 
50
86
  fprintf (stderr, RED "[ERR] " p RESET "\n", ##__VA_ARGS__)
51
87
 
52
88
 
53
 
#if !DEBUG
 
89
#if DEBUG
54
90
/**
55
91
 * debug_print is a function that only prints if compiled with the debug
56
92
 * flag not unset.