#ifdef __APPLE__
#import "make.h"
#include <stdlib.h>
#include <string.h>
#include <mach/mach_init.h>
#include <servers/netname.h>
#include <stdio.h>
typedef int BOOL;
static char * tentative_path; static char cumulative_copies[4096]; static BOOL alreadyCommit;
static void reallyPublicizeCopy(char *path)
{
char *portName = getenv("MAKEPORT");
char *hostName = getenv("MAKEHOST");
mach_port_t port;
static BOOL port_set = FALSE;
char * fileName = rindex(path,'/')+1;
#ifdef BE_NOISY_ON_STDOUT
printf("Copying %s\n",fileName);
#else
strcat(cumulative_copies, " ");
strcat(cumulative_copies, fileName);
#endif
if (!port_set) {
if (!portName)
return;
if (!hostName)
hostName = "";
if ((netname_look_up (name_server_port, hostName, portName, &port)
!= KERN_SUCCESS)
|| (port == MACH_PORT_NULL))
return;
port_set = TRUE;
}
make_alert(port,
-1,
NULL, 0,
fileName, strlen(fileName) + 1,
NULL, 0,
0,
"Copying", 8);
}
void initializeCopyPublicity()
{
tentative_path = NULL;
cumulative_copies[0] = '\0';
}
void finalizeCopyPublicity()
{
if (cumulative_copies[0] != '\0') {
printf("Copied%s\n",cumulative_copies);
cumulative_copies[0] = '\0';
}
}
void publicizeCopy(char *path, int tentative)
{
if (!tentative_path) {
if (tentative)
tentative_path = path;
else
reallyPublicizeCopy(path);
}
}
void commitTentativePublicity()
{
if ((tentative_path) && !alreadyCommit) {
reallyPublicizeCopy(tentative_path); alreadyCommit = TRUE;
}
}
void abortTentativePublicity()
{
tentative_path = NULL;
alreadyCommit = FALSE; }
#else
void initializeCopyPublicity() {}
void finalizeCopyPublicity() {}
void publicizeCopy(const char* fileName, int tentative) {}
void commitTentativePublicity() {}
void abortTentativePublicity() {}
#endif