# include "Ximage.h"

int EraseOverlay (int sock) {

  char buffer[256];
  int i, status, N;
  Graphic *graphic;
  Section *section;
  KapaImageWidget *image;

  graphic = GetGraphic();
  section = GetActiveSection();
  image = section->image;
  if (image == NULL) return (TRUE);

  KiiScanCommand (sock, 16, "%*s %d", &N);

  if (N > NOVERLAYS) {
    REALLOCATE (image[0].tickmarks.objects, KiiOverlay, 1);
    image[0].tickmarks.Nobjects = 0;
  } else {
    for (i = 0; i < image[0].overlay[N].Nobjects; i++) {
      if (image[0].overlay[N].objects[i].type == KII_OVERLAY_TEXT) {
	free (image[0].overlay[N].objects[i].text);
      }
    }
    REALLOCATE (image[0].overlay[N].objects, KiiOverlay, 1);
    image[0].overlay[N].Nobjects = 0;
    image[0].overlay[N].active = FALSE;
  }

  if (USE_XWINDOW) Refresh ();
  return (TRUE);
}
