...
1/* Copyright 2011 The Go Authors. All rights reserved.
2 Use of this source code is governed by a BSD-style
3 license that can be found in the LICENSE file. */
4
5/* A trivial example of wrapping a C library using SWIG. */
6
7%{
8#include <stdio.h>
9#include <stdlib.h>
10%}
11
12%typemap(gotype) const char * "string"
13%typemap(in) const char * %{
14 $1 = malloc($input.n + 1);
15 memcpy($1, $input.p, $input.n);
16 $1[$input.n] = '\0';
17%}
18%typemap(freearg) const char * %{
19 free($1);
20%}
21
22FILE *fopen(const char *name, const char *mode);
23int fclose(FILE *);
24int fgetc(FILE *);
View as plain text