text_mode.c 603 B

1234567891011121314151617181920212223242526272829303132
  1. // (C) 2016 Cybozu.
  2. #include "yrmcds.h"
  3. #include <errno.h>
  4. yrmcds_error yrmcds_text_mode(yrmcds* c) {
  5. if( c == NULL )
  6. return YRMCDS_BAD_ARGUMENT;
  7. #ifndef LIBYRMCDS_NO_INTERNAL_LOCK
  8. int e = pthread_mutex_lock(&c->lock);
  9. if( e != 0 ) {
  10. errno = e;
  11. return YRMCDS_SYSTEM_ERROR;
  12. }
  13. #endif // ! LIBYRMCDS_NO_INTERNAL_LOCK
  14. yrmcds_error ret = YRMCDS_OK;
  15. if( c->serial != 0 ) {
  16. ret = YRMCDS_IN_BINARY;
  17. goto OUT;
  18. }
  19. c->text_mode = 1;
  20. OUT:
  21. #ifndef LIBYRMCDS_NO_INTERNAL_LOCK
  22. pthread_mutex_unlock(&c->lock);
  23. #endif
  24. return ret;
  25. }