include # COPYMASK -- Copy one mask to another, converting formats as necessary procedure copymask (inmask, outmask, ndim, verbose) char inmask[ARB] # i: input mask name char outmask[ARB] # i: output mask name int ndim # i: number of dimensions in output mask bool verbose # i: print the operation? #-- int len1, len2, nline1, nline2 pointer buf1, buf2, msk1, msk2 string badsize "Input and output masks are not the same size" pointer old_mask(), new_mask(), rd_mask(), wrt_mask() begin # Open the input and output masks msk1 = old_mask (inmask, READ_ONLY) msk2 = new_mask (outmask, ndim, msk1) call sz_mask (msk1, len1, nline1) call sz_mask (msk2, len2, nline2) if ((len1 != len2) || (nline1 != nline2)) call error (1, badsize) # Copy the mask repeat { buf1 = rd_mask (msk1) if (buf1 == NULL) break buf2 = wrt_mask (msk2) if (buf2 == NULL) call error (1, badsize) call amovi (Memi[buf1], Memi[buf2], len1) } call cls_mask (msk1) call cls_mask (msk2) # If verbose print the operation. if (verbose) { call eprintf ("%s -> %s\n") call pargstr (inmask) call pargstr (outmask) call flush (STDERR) } end