Este es el codigo de la funcion:;

#include <stdio.h>
#include <string.h>
#include "postgres.h"
#include <string.h>
#include "fmgr.h"
#include "libstd.h"

#define LENMAX 100

#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif

PG_FUNCTION_INFO_V1(pg_serverid);
Datum
pg_serverid(PG_FUNCTION_ARGS)
{  FILE *fp;
   char buffer[80],mac[20];
   int i,j;
   char *line="Physical Address";
   text *new_t = (text *) palloc(30);
   
      system("ipconfig /all > ww.txt");
      fp=fopen("ww.txt","r+");
      while (!feof(fp))
       {fgets(buffer,79,fp);
         if (strstr(buffer,line)!=NULL) break;
        }
        
         //inicio = strpos(buffer,':');  
         for (i=strpos(buffer,':')+1,j=0;i<strlen(buffer);i++)
           if ((buffer[i]>='0' && buffer[i]<='9') || (buffer[i]>='A' && 
buffer[i]<='F') || (buffer[i]=='-'))
             { mac[j]=buffer[i];j++; }
           
          //
          mac[j]=0;
          
         fclose(fp);
         system("del ww.txt");
         //

  SET_VARSIZE(new_t, strlen(mac) + VARHDRSZ);
  memcpy(VARDATA(new_t),mac,strlen(mac));
  PG_RETURN_TEXT_P(new_t);
}               





*-------------------------------------------------------* 
*-Edwin Quijada 
*-Developer DataBase 
*-JQ Microsistemas 

*-Soporte PostgreSQL

*-www.jqmicrosistemas.com
*-809-849-8087
*-------------------------------------------------------*

                                          

Responder a