Logo Search packages:      
Sourcecode: nbsmtp version File versions  Download package

char* osx_location (  ) 

Returns the current OSX-location.

Returns:
Returns an allocated pointer to the network location name. The programmer must free the pointer.

Definition at line 41 of file osx.c.

Referenced by fileconfig_parse_all().

{
      FILE *scselect;
      char buf[BUFSIZ], location[BUFSIZ];
      char *p,*lp;

      if ((scselect = popen("/usr/sbin/scselect 2>&1","r"))!=NULL)
      {
            while (fgets(buf,BUFSIZ,scselect)!=NULL)
            {
                  if (buf[1]=='*')
                  {
                        break;
                  }
            }
            (void)pclose(scselect);
      }

      p = buf;
      lp = location;

      /* Forward the pointer to the first ( */
      while (*(p++) != '(');
      /* Copy everything except last ) [the string ends in )\n] */
      for (; *(p+1) && *(p+1) != '\n' ; *(lp++) = *(p++));
      /* Close it */
      *lp = (char)NULL;

      return (char *)strdup(location);
}


Generated by  Doxygen 1.6.0   Back to index