RetroArch
smb.h
Go to the documentation of this file.
1 /****************************************************************************
2  * TinySMB
3  * Nintendo Wii/GameCube SMB implementation
4  *
5  * Copyright softdev
6  * Modified by Tantric to utilize NTLM authentication
7  * PathInfo added by rodries
8  * SMB devoptab by scip, rodries
9  *
10  * You will find WireShark (http://www.wireshark.org/)
11  * invaluable for debugging SAMBA implementations.
12  *
13  * Recommended Reading
14  * Implementing CIFS - Christopher R Hertel
15  * http://www.ubiqx.org/cifs/SMB.html
16  *
17  * License:
18  *
19  * This library is free software; you can redistribute it and/or
20  * modify it under the terms of the GNU Lesser General Public
21  * License as published by the Free Software Foundation; either
22  * version 2.1 of the License, or (at your option) any later version.
23  *
24  * This library is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27  * Lesser General Public License for more details.
28  *
29  * You should have received a copy of the GNU Lesser General Public
30  * License along with this library; if not, write to the Free Software
31  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32  ****************************************************************************/
33 
34 #ifndef __NBTSMB_H__
35 #define __NBTSMB_H__
36 
37 #include <gctypes.h>
38 #include <sys/statvfs.h>
39 
40 #define SMB_MAXPATH 4096
41 
45 #define SMB_SUCCESS 0
46 #define SMB_ERROR -1
47 #define SMB_BAD_PROTOCOL -2
48 #define SMB_BAD_COMMAND -3
49 #define SMB_PROTO_FAIL -4
50 #define SMB_NOT_USER -5
51 #define SMB_BAD_KEYLEN -6
52 #define SMB_BAD_DATALEN -7
53 #define SMB_BAD_LOGINDATA -8
54 
58 #define SMB_OF_OPEN 1
59 #define SMB_OF_TRUNCATE 2
60 #define SMB_OF_CREATE 16
61 
65 #define SMB_SRCH_READONLY 1
66 #define SMB_SRCH_HIDDEN 2
67 #define SMB_SRCH_SYSTEM 4
68 #define SMB_SRCH_VOLUME 8
69 #define SMB_SRCH_DIRECTORY 16
70 #define SMB_SRCH_ARCHIVE 32
71 
75 #define SMB_OPEN_READING 0
76 #define SMB_OPEN_WRITING 1
77 #define SMB_OPEN_READWRITE 2
78 #define SMB_OPEN_COMPATIBLE 0
79 #define SMB_DENY_READWRITE 0x10
80 #define SMB_DENY_WRITE 0x20
81 #define SMB_DENY_READ 0x30
82 #define SMB_DENY_NONE 0x40
83 
84 
85 #ifdef __cplusplus
86 extern "C" {
87 #endif
88 
89 /***
90  * SMB Connection Handle
91  */
92 typedef u32 SMBCONN;
93 
94 /***
95  * SMB File Handle
96  */
97 typedef void* SMBFILE;
98 
99 /*** SMB_FILEENTRY
100  SMB Long Filename Directory Entry
101  ***/
102  typedef struct
103 {
110  char name[768]; //unicode
111 } SMBDIRENTRY;
112 
117 /*** Functions to be used with stdio API ***/
118 bool smbInitDevice(const char* name, const char *user, const char *password, const char *share, const char *ip);
119 bool smbInit(const char *user, const char *password, const char *share, const char *ip);
120 void smbClose(const char* name);
121 bool smbCheckConnection(const char* name);
122 void smbSetSearchFlags(unsigned short flags);
123 
124 /*** Session ***/
125 s32 SMB_Connect(SMBCONN *smbhndl, const char *user, const char *password, const char *share, const char *IP);
126 void SMB_Close(SMBCONN smbhndl);
127 s32 SMB_Reconnect(SMBCONN *_smbhndl, bool test_conn);
128 
129 /*** File Find ***/
130 s32 SMB_PathInfo(const char *filename, SMBDIRENTRY *sdir, SMBCONN smbhndl);
131 s32 SMB_FindFirst(const char *filename, unsigned short flags, SMBDIRENTRY *sdir, SMBCONN smbhndl);
132 s32 SMB_FindNext(SMBDIRENTRY *sdir,SMBCONN smbhndl);
133 s32 SMB_FindClose(SMBDIRENTRY *sdir,SMBCONN smbhndl);
134 
135 /*** File I/O ***/
136 SMBFILE SMB_OpenFile(const char *filename, unsigned short access, unsigned short creation,SMBCONN smbhndl);
137 void SMB_CloseFile(SMBFILE sfid);
138 s32 SMB_ReadFile(char *buffer, size_t size, off_t offset, SMBFILE sfid);
139 s32 SMB_WriteFile(const char *buffer, size_t size, off_t offset, SMBFILE sfid);
140 s32 SMB_CreateDirectory(const char *dirname, SMBCONN smbhndl);
141 s32 SMB_DeleteDirectory(const char *dirname, SMBCONN smbhndl);
142 s32 SMB_DeleteFile(const char *filename, SMBCONN smbhndl);
143 s32 SMB_Rename(const char *filename, const char * newname, SMBCONN smbhndl);
144 s32 SMB_DiskInformation(struct statvfs *buf, SMBCONN smbhndl);
145 
146 #ifdef __cplusplus
147  }
148 #endif
149 
150 #endif
GLuint const GLchar * name
Definition: glext.h:6671
int32_t s32
32bit signed integer
Definition: gctypes.h:24
static const unsigned char password[MAX_TESTS][32]
Definition: pkcs5.c:305
Definition: smb.h:102
Data type definitions.
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:8418
s32 SMB_WriteFile(const char *buffer, size_t size, off_t offset, SMBFILE sfid)
u64 mtime
Definition: smb.h:107
s32 SMB_CreateDirectory(const char *dirname, SMBCONN smbhndl)
GLsizeiptr size
Definition: glext.h:6559
void smbClose(const char *name)
s32 SMB_Rename(const char *filename, const char *newname, SMBCONN smbhndl)
void smbSetSearchFlags(unsigned short flags)
bool smbInit(const char *user, const char *password, const char *share, const char *ip)
SMBFILE SMB_OpenFile(const char *filename, unsigned short access, unsigned short creation, SMBCONN smbhndl)
u32 SMBCONN
Definition: smb.h:92
uint16_t u16
16bit unsigned integer
Definition: gctypes.h:18
void SMB_Close(SMBCONN smbhndl)
s32 SMB_FindNext(SMBDIRENTRY *sdir, SMBCONN smbhndl)
u32 attributes
Definition: smb.h:108
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:8533
s32 SMB_FindFirst(const char *filename, unsigned short flags, SMBDIRENTRY *sdir, SMBCONN smbhndl)
s32 SMB_DeleteFile(const char *filename, SMBCONN smbhndl)
bool smbCheckConnection(const char *name)
u64 size
Definition: smb.h:104
s32 SMB_DiskInformation(struct statvfs *buf, SMBCONN smbhndl)
u16 sid
Definition: smb.h:109
uint64_t u64
64bit unsigned integer
Definition: gctypes.h:20
s32 SMB_Reconnect(SMBCONN *_smbhndl, bool test_conn)
s32 SMB_PathInfo(const char *filename, SMBDIRENTRY *sdir, SMBCONN smbhndl)
s32 SMB_DeleteDirectory(const char *dirname, SMBCONN smbhndl)
void * SMBFILE
Definition: smb.h:97
s32 SMB_Connect(SMBCONN *smbhndl, const char *user, const char *password, const char *share, const char *IP)
s32 SMB_FindClose(SMBDIRENTRY *sdir, SMBCONN smbhndl)
bf_uint8_t share
Definition: connect_ps4.c:77
bool smbInitDevice(const char *name, const char *user, const char *password, const char *share, const char *ip)
Definition: video4linux2.c:51
GLintptr offset
Definition: glext.h:6560
GLbitfield flags
Definition: glext.h:7828
u64 ctime
Definition: smb.h:105
uint32_t u32
32bit unsigned integer
Definition: gctypes.h:19
void SMB_CloseFile(SMBFILE sfid)
s32 SMB_ReadFile(char *buffer, size_t size, off_t offset, SMBFILE sfid)
u64 atime
Definition: smb.h:106