/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.c

  • Committer: Gustav Hartvigsson
  • Date: 2015-08-27 15:01:32 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20150827150132-pwijpi0k2f4f96rg
* Working on SMatrix to finish it off.
* Added (non working?) s_wstiring_to_string () to convert Wide Strings (wchar_t *) to Byte Strings (char *).
* fixed spelling of tuple in Matrix.[h,c]
* added documentation to different parts of the code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include <stdio.h>
27
27
#include <stdarg.h>
28
28
#include <time.h>
29
 
 
 
29
#include <wchar.h>
30
30
 
31
31
char *
32
32
s_string_new (const char * s) {
61
61
  strftime (ret_val, 21, "%F %T", localtime (&t));
62
62
  return ret_val;
63
63
}
 
64
 
 
65
 
 
66
char *
 
67
s_wstring_to_string (const wchar_t * ws) {
 
68
  size_t new_len = ((sizeof (wchar_t *) * wcslen (ws)) + 1);
 
69
  char * buffer = malloc (new_len);
 
70
  char * ret_val = NULL;
 
71
  mbstate_t state;
 
72
  
 
73
  int ret = wcsrtombs (buffer, &ws, new_len, &state);
 
74
  if (ret) {
 
75
    ret_val = (char *) strdup (buffer);
 
76
  } else {
 
77
    s_warn_print ("Could not copy wide c string into a c string.\n");
 
78
  }
 
79
  free (buffer);
 
80
  return ret_val;
 
81
}