xbitnot.c 702 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include <grass/gis.h>
  2. #include <grass/raster.h>
  3. #include "globals.h"
  4. #include "expression.h"
  5. #include "func_proto.h"
  6. /****************************************************************
  7. bitnot(a) = ~a
  8. ****************************************************************/
  9. int f_bitnot(int argc, const int *argt, void **args)
  10. {
  11. CELL *res = args[0];
  12. CELL *arg1 = args[1];
  13. int i;
  14. if (argc < 1)
  15. return E_ARG_LO;
  16. if (argc > 1)
  17. return E_ARG_HI;
  18. if (argt[1] != CELL_TYPE)
  19. return E_ARG_TYPE;
  20. if (argt[0] != CELL_TYPE)
  21. return E_RES_TYPE;
  22. for (i = 0; i < columns; i++) {
  23. if (IS_NULL_C(&arg1[i]))
  24. SET_NULL_C(&res[i]);
  25. else
  26. res[i] = ~arg1[i];
  27. }
  28. return 0;
  29. }