Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non int return function pointer not recognized #145

Open
jdkuki opened this issue Feb 16, 2023 · 0 comments
Open

Non int return function pointer not recognized #145

jdkuki opened this issue Feb 16, 2023 · 0 comments

Comments

@jdkuki
Copy link

jdkuki commented Feb 16, 2023

I a was attempting to create a set of bindings for libtsk: https://github.com/sleuthkit/sleuthkit

Having some trouble on the following struct:

https://github.com/sleuthkit/sleuthkit/blob/develop/tsk/fs/tsk_fs.h#L1000

This struct has several callback/function ptr members. For the members with return type int it appears c-for-go handles this correctly. If the type is something not recognized as built in ex uint8_t, c-for-go is not expanding the type of the member but stopping at the return type. Ex:

// C def
int (*name_cmp) (TSK_FS_INFO *, const char *, const char *);    ///< \internal
// c-for-go out
name_cmp              *func(arg0 []TSK_FS_INFO, arg1 []byte, arg2 []byte) int32

Is correct, but getting

// C def
uint8_t(*block_walk) (TSK_FS_INFO * fs, TSK_DADDR_T start, TSK_DADDR_T end, TSK_FS_BLOCK_WALK_FLAG_ENUM flags, TSK_FS_BLOCK_WALK_CB cb, void *ptr); 
// c-for-go out
block_walk            uint8_t

Sample yml I am working with to tweak:

GENERATOR: 
  PackageName: tsk
  PackageDescription: "Package tsk provides Go bindings for the sleuth kit"
  PackageLicense: "THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS."
  Includes: ["tsk/libtsk.h"]
  Options:
    SafeStrings: true
PARSER: 
  SourcesPaths: ["tsk/libtsk.h"]
TRANSLATOR: 
  ConstCharIsString: true
  ConstUCharIsString: false
  ConstRules: 
    defines: eval
  Rules: 
    global: 
      - {action: accept, from: "^TSK_FS_INFO$"}

Full generated output for TSK_FS_INFO

// THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS.

// WARNING: This file has automatically been generated on Thu, 16 Feb 2023 12:28:59 PST.
// Code generated by https://git.io/c-for-go. DO NOT EDIT.

package tsk

/*
#include "tsk/libtsk.h"
#include <stdlib.h>
#include "cgo_helpers.h"
*/
import "C"
import "unsafe"

// TSK_FS_INFO as declared in fs/tsk_fs.h:50
type TSK_FS_INFO struct {
	tag                   int32
	inum_count            uint64
	root_inum             uint64
	first_inum            uint64
	last_inum             uint64
	block_count           uint64
	first_block           uint64
	last_block            uint64
	last_block_act        uint64
	block_size            uint32
	dev_bsize             uint32
	block_pre_size        uint32
	block_post_size       uint32
	journ_inum            uint64
	duname                string
	fs_id                 [32]byte
	fs_id_used            uint64
	block_walk            uint8_t
	block_getflags        TSK_FS_BLOCK_FLAG_ENUM
	inode_walk            uint8_t
	file_add_meta         uint8_t
	get_default_attr_type TSK_FS_ATTR_TYPE_ENUM
	load_attrs            uint8_t
	decrypt_block         uint8_t
	istat                 uint8_t
	dir_open_meta         TSK_RETVAL_ENUM
	jopen                 uint8_t
	jblk_walk             uint8_t
	jentry_walk           uint8_t
	fsstat                uint8_t
	name_cmp              *func(arg0 []TSK_FS_INFO, arg1 []byte, arg2 []byte) int32
	fscheck               uint8_t
	close                 *func(fs []TSK_FS_INFO)
	fread_owner_sid       uint8_t
	impl                  unsafe.Pointer
	refead83f4e           *C.TSK_FS_INFO
	allocsead83f4e        interface{}
}
@jdkuki jdkuki changed the title Non-int function pointer not recognized Non int return function pointer not recognized Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant