adnan kamili
adnan kamili

Reputation: 9455

How to suppress the output of a library function

I wish to suppress the default output of the function smbc_opendir(), and print only using printf.

gcc filename.c -lsmbclient

#include <libsmbclient.h>
#include <stdio.h>

void auth_fn()
{

}

int main(int argc,char* argv[])   
{ 
  int dirHandle;
  if(smbc_init(auth_fn,  10)) /* Initialize things */
  {
     return 0;
  }
  dirHandle= smbc_opendir(argv[1]);    /* Argument is smb://<ip-address>/ */
  /* Just display value of dirHandle in output and nothing else */
  printf("%d",dirHandle);
  return 0;
}

Upvotes: 3

Views: 651

Answers (2)

Rost
Rost

Reputation: 9089

Try debug level 0, it shall log only critical errors: smbc_init(auth_fn, 0)

Upvotes: 4

Gen&#237;s
Gen&#237;s

Reputation: 1508

You can redirect the stdout or the stderr with something such as:

stderr = freopen("/dev/null", "w", stderr );

and then you call smbc_opendir.

Upvotes: 3

Related Questions