|
Hi,
First let me say that I am a Windows guy so I don't know how to troubleshoot the SAMBA or Apple SMB side of your issue. However I believe that you are looking for the SetServiceBits function[^].
This should allow you or your company (or Apple or Google or whoever wants to use this) to define:
#define SV_TYPE_APPLE_MINI_CUSTOM_TYPE 0x123456789 Both the client and server would need to have this type registered. All I can do is tell you what you need to do on the Windows side.
Have you tried using SV_TYPE_SERVER_UNIX
Looking through the Apple source code[^] I see that they have that one defined.
Update:
1.) Looks like SAMBA uses[^] the 'announce as' in the configuration file to set this value.
2.) Apple code shows that they hard code this value with:
default_server_announce = 0;
default_server_announce |= SV_TYPE_WORKSTATION;
default_server_announce |= SV_TYPE_SERVER;
default_server_announce |= SV_TYPE_SERVER_UNIX;
default_server_announce |= SV_TYPE_PRINTQ_SERVER;
switch (lp_announce_as())
{
case ANNOUNCE_AS_NT_SERVER:
{
default_server_announce |= SV_TYPE_SERVER_NT;
}
case ANNOUNCE_AS_NT_WORKSTATION:
{
default_server_announce |= SV_TYPE_NT;
break;
}
case ANNOUNCE_AS_WIN95:
{
default_server_announce |= SV_TYPE_WIN95_PLUS;
break;
}
case ANNOUNCE_AS_WFW:
{
default_server_announce |= SV_TYPE_WFW;
break;
}
default:
{
break;
}
}
It's located at the very bottom of loadparm.c[^]
So it looks like you will not be able to change this. Maybe you should try an Apple forum instead.
modified 4-Dec-20 5:25am.
|
|
|
|
|
I am using the NetServerEnum function to enumerate the network and printing all records. But I'm getting the same SV type for MAC OS system and Windows10 system. Also, sv101_version_major and sv101_version_minor are wrong. Kindly let me know how this function works, and from where I am getting these values. What is the limitation of this API.
printed logs using the provided example is:
NetServerEnum(pszServerName,
dwLevel,
(LPBYTE *) & pBuf,
dwPrefMaxLen,
&dwEntriesRead,
&dwTotalEntries,
dwServerType,
pszDomainName,
&dwResumeHandle);
//Printing logs:
printf("\tPlatform: %d\n", pTmpBuf->sv101_platform_id);
wprintf(L"\tName: %s\n", pTmpBuf->sv101_name);
printf("\tVersion: %d.%d\n",
pTmpBuf->sv101_version_major,
pTmpBuf->sv101_version_minor);
printf("\tType: %d", pTmpBuf->sv101_type);
Output=>
Platform: 500
Name: MACMINI-558088
Version: 6.1 //<==VERSION is common among both UNIX and MAC
Type: 4099 //<==SAME SV_TYPE
Platform:500
Name: MAILSRV
Version: 6.1 //<==VERSION is common among both UNIX and MAC
Type: 8493571
Platform:500
Name: WIN1019H2X64
Version: 10.0
Type: 4099 //<==SAME SV_TYPE
Where macmini is MAC and mailsrv is Unix system. sv_type of macmini and WIN1019H2X64 is the same. sv101_version_major and sv101_version_minor are the same for UNIX and MAC systems, which use SAMBA. Kindly let me know why it is? So I can differentiate these systems using predefined macros in lmserver.h.
|
|
|
|
|
Member 14117853 wrote: Kindly let me know how this function works, and from where I am getting these values. These values are set by the other side. Meaning that MACMINI-558088 broadcasts/announces itself and sets those values itself.
The Netserverenum function will simply echo/repeat what MACMINI-558088 claims to be. If your SAMBA configuration file is set to announce as "Win95" then Netserverenum will print Windows 95.
Member 14117853 wrote: sv101_version_major and sv101_version_minor are the same for UNIX and MAC systems, which use SAMBA. Kindly let me know why it is? Did you invest any time reading my last post? I already told you that you can edit the SAMBA configuration file and modify these values.
smb.conf[^]
Scroll down and look at
[announce as]
This specifies what type of server nmbd(8) will announce itself as, to a network neighborhood browse list. By default this is set to Windows NT. The valid options are : "NT Server" (which can also be written as "NT"), "NT Workstation", "Win95" or "WfW" meaning Windows NT Server, Windows NT Workstation, Windows 95 and Windows for Workgroups respectively. Do not change this parameter unless you have a specific need to stop Samba appearing as an NT server as this may prevent Samba servers from participating as browser servers correctly.
Default: announce as = NT Server
Example: announce as = Win95
[announce version]
This specifies the major and minor version numbers that nmbd will use when announcing itself as a server. The default is 4.9. Do not change this parameter unless you have a specific need to set a Samba server to be a downlevel server.
Default: announce version = 4.9
Example: announce version = 2.0
By the way... these are not C++ issues, you are basically asking for SAMBA support in the C++ forum.
Best Wishes,
-David Delaune
|
|
|
|
|
Hi David,
thanks for the updates.
|
|
|
|
|
Hello.
I'm a developer who needs help.
First of all, I hope you understand that the sentence structure can be strange as I ask questions using a translator machine.
I am currently working on a program that requires watermarking on any printout.
If our program is running, when printing in programs such as Notepad, Office 2016, mspaint, Adobe Reader, etc., the set watermark is printed well.
However, when printing in Chrome or Edge, the watermark is not displayed.
Currently, we are hooking GDI32.DLL and taking watermarks.
Except for IE11, Chrome, Edge, Notepad, etc. all call the hooked StartDoc function in GDI32.DLL.
I thought that Chrome or Edge would not call the function of GDI32.DLL, but when I saw the hooked function call, I knew it was not.
I think something is blocking itself when printing from Chrome or Edge.
I am curious if the above sentence is correct.
So,
If the idea of the sentence above is correct, the question is how to approach to make the watermark appear in Chrome or Edge printouts?
If even the approach is wrong, I wonder if there is another way.
I would be grateful for any help.
Thank you.
|
|
|
|
|
|
Hi,
Some thoughts:
1.) Chrome (and Microsoft Edge based on Chromium) rendering process set the PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY[^] which will block Win32k in the rendering process. But this probably is not causing your issue.
2.) The Chrome (and Microsoft Edge based on Chromium) top/root process sets the PROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY[^] which will block AppInit and other types of extension points. This is probably causing your hooking DLL to not load.
You should probably look for other solutions.
Best Wishes,
-David Delaune
|
|
|
|
|
This has been hashed over umpteen times...
C&R said .. loosely... , thus directly NOT defining "bool" as it is used in C++
if(true) process , if not true skip processing
One would then expect
if(discoveryAgent->discoveredDevices().isEmpty())
do not iterate devices...
code will skip iteration.
Would
<pre>if(discoveryAgent->discoveredDevices().isEmpty()== 0 )
do not iterate devices...
be overcautious overkill or create a headache or wrong assumption that 0 = false in C++ ?
Perhaps some with more experience in C+ could chime in with some practical advise?
|
|
|
|
|
The second one is the exact opposite of the first one and shows you why you shouldn't mix bool with int: it just creates confusion.
I assume that isEmpty() returns true is the set is empty. So first one says "if set is empty, do not iterate devices". The second one says "if empty is false (that means there are some devices), do not iterate devices". Probably not what you had in mind.
Mircea
|
|
|
|
|
if(discoveryAgent->discoveredDevices().isEmpty()) -> if ( statement is true )
do not iterate devices... -> process / do this code
Poor wording /formating on my part
code will skip iteration should read "process this code "
|
|
|
|
|
Anyway my advice remains the same: mixing booleans and integers is bad form. People will frown at your code and we don’t want that to happen, do we?
Mircea
|
|
|
|
|
Given that the bool type has existed in C from its earliest days, don't you think that if the result of a method is Boolean (true / false), you should treat it as such in code?
bool isFoo();
void bar()
{
if (isFoo())
{
}
else
{
}
}
Even C has had a built-in _Bool type (define bool, true, and false by including stdbool.h) for 21 years!
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
I am trying hard to understand C++ templates.
The following test code works as expected in class constructor.
When I add SAME code to class method - which is is activated via
an event - I get "index" out of range error.
The error goes away when I include
<pre>QList<QBluetoothHostInfo> information_main = QBluetoothLocalDevice::allDevices(); = QBluetoothLocalDevice::allDevices();
in the method.
If the
QList<QBluetoothHostInfo> information_main;
is "class variable" why do I have to "initialize " it again in the method?
The "index" is method variable (local) and is initialized to 0. - So why am I running out of index range ?
If you kindly answer the above and refrain from critiquing my coding style I would be grateful.
Thanks
<pre lang="text"><pre lang="c++">
<pre>
QList<QBluetoothHostInfo> information_main = QBluetoothLocalDevice::allDevices();
qDebug() << "QDEBUG TRACE //11/23/2020 # of local BT detetced " << information_main.count();
ui->listWidget->addItem("MainWindow test # of local BT detetced ");
ui->listWidget->addItem("# of local BT detetced ");
ui->listWidget->addItem("information_main.count())");
ui->listWidget->addItem("TODO add conversion");
int index = 0;
do
{
information_main.at(index).address().toString();
ui->listWidget->addItem("information_main.at(0).address()");
ui->listWidget->addItem( information_main.at(index).address().toString());
ui->listWidget->addItem(" information_main.at(0).name()");
ui->listWidget->addItem( information_main.at(index).name());
index++;
} while( index != information_main.count() );
qDebug() << "file " << __FILE__;
qDebug() << "function "<<__FUNCTION__;
qDebug() << "@line " << __LINE__;
qDebug()<<"TEMPORARY EXIT ";
information_main.count();
#endif
EDITED
The purpose of the post is to identify WHY
the do-while loop works as coded in constructor and fails - run time error - when used in method.
It is , as already posted , a test code.
The task is to read the list of devices returned by
Template "list" = QBluetoothLocalDevice::allDevices();
It would be nice if contributions lead to resolve this SPECIFIC problem.
Naming variables, verifying validity of "loop index / count" , pointing out the code is
repeated in class method so far does not addresses my error usage of template.
The only answer I have - it is run time error , not a compiler error as I initially thought. Good point.
modified 25-Nov-20 23:32pm.
|
|
|
|
|
Member 14980433 wrote: is "class variable" why do I have to "initialize " it again in the method? You don't. What you have done is to create a second local variable inside that method with the same name as the class level one. Change the code inside the method to just:
information_main = QBluetoothLocalDevice::allDevices();
The error message is less easy to diagnose, so you need to use the debugger to check what value it is when the error occurs.
|
|
|
|
|
What you have done is to create a second local variable inside that method with the same name as the class level one
So the variable in class takes precedence over the variable in method?
Then why is the error saying the "index" is out of range?
The "index" is local in constructor and also local in method.
|
|
|
|
|
Member 14980433 wrote: So the variable in class takes precedence over the variable in method?
No, you cannot have two variables with the same name in scope at the same time.
|
|
|
|
|
No, the other way round. The variable declared in the method will be the one that is used, as it is in the innermost scope. But you should not be declaring the same variable at two scope levels. Just change your code as I suggested to correct the problem. As to the index problem, i suggest you change the do while to a simple while or for loop, to ensure you do not enter the loop if information_main.count() returns zero.
|
|
|
|
|
So in other words "index" in constructor and "index" in methods are independent , hence not source of the "out of range error".
That should apply to any variable, including template.
I understand that using same names could be buggy, but I need to verify WHAT is causing the
"out of range error" and IMHO using DIFFERENT names should not be "real " solutions, unless something else is wrong with my implementation of templates.
As I said - this is a test code and the "count" is used to simply verify the list content prior to doing the "do -while " loop and it is > 0.
I have never used "iteration" but planning to employ it after I get the "out of range " error Solved.
|
|
|
|
|
Having this;
QList<QBluetoothHostInfo> information_main; inside the method creates a new Qlist type variable called 'information_main', this variable is totally different than the class variable called 'information_main' that has been initialized in a class constructor. This new QList variable (the one just declared inside the method) is empty because you just created it and have not added anything to it. When you make an indexed access to an empty QList variable it will fail. That's why you have to initialize (add stuff to) the new QList variable (the one just declared inside the method) to get the loop to work.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Yes, as I mentioned above the one in the innermost scope is the one that will be used; that is the one declared inside the method. But you really should not create variables with the same name like this, it just confuses people, particularly you. See my last sentence in the previous reply for a possible fix to the out of range error. But you should really capture the count first in a variable and test it to see if it returns a ositive value.
|
|
|
|
|
I am not sure who is confused. Just read the original post and subsequent comments.
So far it looks as the template code fails if there are NO items in it. That makes sense, but it is not the primary issue - just nice to know.
However, the list is not empty and I still do not have an answer to the original post.
Maybe I should rephrase the question.
The template list content was created by other process, what I want is to read it - I do not want to rebuild / reinitialize it.
I can read it fine first time in constructor, now I like to read it again in method.
I do not want to reinitialize it.
And I am doing it wrong , and the matching names is NOT the issue.
I do not want to reinitialize it.
|
|
|
|
|
Member 14980433 wrote: I am not sure who is confused. I am, because there is still some information missing. And I cannot understand why you need to read this information inside the constructor (which is definitely wrong), as well as in the method (which is correct).
But to go back to the main point, the only way to resolve the index out of range problem is to use the debugger and step through the code as it runs.
|
|
|
|
|
Is there a chance that the following call
QBluetoothLocalDevice::allDevices(); may return no devices? If so, your do-while loop will have an out of range issue.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Thanks for the reply.
Good point, but does not address the question.
The do-while-loop compares the index to count of the items being processed.
No count , no processing,
Yes, I could check the count before entering the loop.
I am sure I will find more "elegant" way to process the items and stop the loop.
|
|
|
|
|
Member 14980433 wrote: No count , no processing, No, you're going to process it once before size is checked, and likely crash if the list is empty.
Member 14980433 wrote: I am sure I will find more "elegant" way to process the items and stop the loop. Indeed, most likely a for loop.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|