2016-04-10 15:32:26 -06:00
|
|
|
/* Copyright 2011 The Go Authors. All rights reserved.
|
2011-03-22 14:05:51 -06:00
|
|
|
Use of this source code is governed by a BSD-style
|
|
|
|
license that can be found in the LICENSE file. */
|
|
|
|
|
|
|
|
/* A trivial example of wrapping a C library using SWIG. */
|
|
|
|
|
|
|
|
%{
|
|
|
|
#include <stdio.h>
|
2012-08-03 19:08:43 -06:00
|
|
|
#include <stdlib.h>
|
2011-03-22 14:05:51 -06:00
|
|
|
%}
|
|
|
|
|
2012-08-03 19:08:43 -06:00
|
|
|
%typemap(gotype) const char * "string"
|
|
|
|
%typemap(in) const char * %{
|
|
|
|
$1 = malloc($input.n + 1);
|
|
|
|
memcpy($1, $input.p, $input.n);
|
|
|
|
$1[$input.n] = '\0';
|
|
|
|
%}
|
|
|
|
%typemap(freearg) const char * %{
|
|
|
|
free($1);
|
|
|
|
%}
|
|
|
|
|
|
|
|
FILE *fopen(const char *name, const char *mode);
|
|
|
|
int fclose(FILE *);
|
|
|
|
int fgetc(FILE *);
|