#include "tmp/c.h"
#include "utils/log.h"
#include "tmp/libpq-fe.h"
#include "tmp/libpq-fs.h"
#include "catalog/pg_lobj.h"

#define BUFSIZE        1024

/*
 * newfilename--
 *     creates a new Inversion file and returns the handle
 */
char *newfilename()
{
    int inv_fd;
    oid invObjOid;     
    char inv_file[256];

    /*
     * our new object
     */
    invObjOid= newoid();
    sprintf(inv_file, "/INVOBJ%x", invObjOid);

    /*
     * create an inversion "object"
     */
    inv_fd = LOcreat(inv_file, INV_READ|INV_WRITE, Inversion);
    if (inv_fd < 0) {
       elog(WARN, "can't create inv object \"%s\" \n",
            inv_file);
       fprintf(stderr, "can't creat inv file\n");
    }
    (void) LOclose(inv_fd);

    return &inv_file[0];
}
