input/smbclient: move code to lib/smbclient/Init.cxx
This commit is contained in:
		| @@ -866,6 +866,7 @@ endif | |||||||
|  |  | ||||||
| if ENABLE_SMBCLIENT | if ENABLE_SMBCLIENT | ||||||
| libinput_a_SOURCES += \ | libinput_a_SOURCES += \ | ||||||
|  | 	src/lib/smbclient/Init.cxx src/lib/smbclient/Init.hxx \ | ||||||
| 	src/input/plugins/SmbclientInputPlugin.cxx src/input/plugins/SmbclientInputPlugin.hxx | 	src/input/plugins/SmbclientInputPlugin.cxx src/input/plugins/SmbclientInputPlugin.hxx | ||||||
| endif | endif | ||||||
|  |  | ||||||
|   | |||||||
| @@ -19,6 +19,7 @@ | |||||||
|  |  | ||||||
| #include "config.h" | #include "config.h" | ||||||
| #include "SmbclientInputPlugin.hxx" | #include "SmbclientInputPlugin.hxx" | ||||||
|  | #include "lib/smbclient/Init.hxx" | ||||||
| #include "../InputStream.hxx" | #include "../InputStream.hxx" | ||||||
| #include "../InputPlugin.hxx" | #include "../InputPlugin.hxx" | ||||||
| #include "util/StringUtil.hxx" | #include "util/StringUtil.hxx" | ||||||
| @@ -26,8 +27,6 @@ | |||||||
|  |  | ||||||
| #include <libsmbclient.h> | #include <libsmbclient.h> | ||||||
|  |  | ||||||
| #include <string.h> |  | ||||||
|  |  | ||||||
| class SmbclientInputStream { | class SmbclientInputStream { | ||||||
| 	InputStream base; | 	InputStream base; | ||||||
|  |  | ||||||
| @@ -80,19 +79,6 @@ public: | |||||||
| 	} | 	} | ||||||
| }; | }; | ||||||
|  |  | ||||||
| static void |  | ||||||
| mpd_smbc_get_auth_data(gcc_unused const char *srv, |  | ||||||
| 		       gcc_unused const char *shr, |  | ||||||
| 		       char *wg, gcc_unused int wglen, |  | ||||||
| 		       char *un, gcc_unused int unlen, |  | ||||||
| 		       char *pw, gcc_unused int pwlen) |  | ||||||
| { |  | ||||||
| 	// TODO: implement |  | ||||||
| 	strcpy(wg, "WORKGROUP"); |  | ||||||
| 	strcpy(un, "foo"); |  | ||||||
| 	strcpy(pw, "bar"); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * InputPlugin methods |  * InputPlugin methods | ||||||
|  * |  * | ||||||
| @@ -101,11 +87,8 @@ mpd_smbc_get_auth_data(gcc_unused const char *srv, | |||||||
| static bool | static bool | ||||||
| input_smbclient_init(gcc_unused const config_param ¶m, Error &error) | input_smbclient_init(gcc_unused const config_param ¶m, Error &error) | ||||||
| { | { | ||||||
| 	constexpr int debug = 0; | 	if (!SmbclientInit(error)) | ||||||
| 	if (smbc_init(mpd_smbc_get_auth_data, debug) < 0) { |  | ||||||
| 		error.SetErrno("smbc_init() failed"); |  | ||||||
| 		return false; | 		return false; | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	// TODO: create one global SMBCCTX here? | 	// TODO: create one global SMBCCTX here? | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										51
									
								
								src/lib/smbclient/Init.cxx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								src/lib/smbclient/Init.cxx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,51 @@ | |||||||
|  | /* | ||||||
|  |  * Copyright (C) 2003-2014 The Music Player Daemon Project | ||||||
|  |  * http://www.musicpd.org | ||||||
|  |  * | ||||||
|  |  * This program is free software; you can redistribute it and/or modify | ||||||
|  |  * it under the terms of the GNU General Public License as published by | ||||||
|  |  * the Free Software Foundation; either version 2 of the License, or | ||||||
|  |  * (at your option) any later version. | ||||||
|  |  * | ||||||
|  |  * This program is distributed in the hope that it will be useful, | ||||||
|  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |  * GNU General Public License for more details. | ||||||
|  |  * | ||||||
|  |  * You should have received a copy of the GNU General Public License along | ||||||
|  |  * with this program; if not, write to the Free Software Foundation, Inc., | ||||||
|  |  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | #include "config.h" | ||||||
|  | #include "Init.hxx" | ||||||
|  | #include "util/Error.hxx" | ||||||
|  |  | ||||||
|  | #include <libsmbclient.h> | ||||||
|  |  | ||||||
|  | #include <string.h> | ||||||
|  |  | ||||||
|  | static void | ||||||
|  | mpd_smbc_get_auth_data(gcc_unused const char *srv, | ||||||
|  | 		       gcc_unused const char *shr, | ||||||
|  | 		       char *wg, gcc_unused int wglen, | ||||||
|  | 		       char *un, gcc_unused int unlen, | ||||||
|  | 		       char *pw, gcc_unused int pwlen) | ||||||
|  | { | ||||||
|  | 	// TODO: implement | ||||||
|  | 	strcpy(wg, "WORKGROUP"); | ||||||
|  | 	strcpy(un, "foo"); | ||||||
|  | 	strcpy(pw, "bar"); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | bool | ||||||
|  | SmbclientInit(Error &error) | ||||||
|  | { | ||||||
|  | 	constexpr int debug = 0; | ||||||
|  | 	if (smbc_init(mpd_smbc_get_auth_data, debug) < 0) { | ||||||
|  | 		error.SetErrno("smbc_init() failed"); | ||||||
|  | 		return false; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return true; | ||||||
|  | } | ||||||
							
								
								
									
										33
									
								
								src/lib/smbclient/Init.hxx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								src/lib/smbclient/Init.hxx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,33 @@ | |||||||
|  | /* | ||||||
|  |  * Copyright (C) 2003-2014 The Music Player Daemon Project | ||||||
|  |  * http://www.musicpd.org | ||||||
|  |  * | ||||||
|  |  * This program is free software; you can redistribute it and/or modify | ||||||
|  |  * it under the terms of the GNU General Public License as published by | ||||||
|  |  * the Free Software Foundation; either version 2 of the License, or | ||||||
|  |  * (at your option) any later version. | ||||||
|  |  * | ||||||
|  |  * This program is distributed in the hope that it will be useful, | ||||||
|  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |  * GNU General Public License for more details. | ||||||
|  |  * | ||||||
|  |  * You should have received a copy of the GNU General Public License along | ||||||
|  |  * with this program; if not, write to the Free Software Foundation, Inc., | ||||||
|  |  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | #ifndef MPD_SMBCLIENT_INIT_HXX | ||||||
|  | #define MPD_SMBCLIENT_INIT_HXX | ||||||
|  |  | ||||||
|  | #include "check.h" | ||||||
|  |  | ||||||
|  | class Error; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Initialize libsmbclient. | ||||||
|  |  */ | ||||||
|  | bool | ||||||
|  | SmbclientInit(Error &error); | ||||||
|  |  | ||||||
|  | #endif | ||||||
		Reference in New Issue
	
	Block a user
	 Max Kellermann
					Max Kellermann