ua_architecture_functions.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  2. * See http://creativecommons.org/publicdomain/zero/1.0/ for more information.
  3. *
  4. * Copyright 2018 (c) Stephan Kantelberg
  5. */
  6. #ifdef UA_ARCHITECTURE_WEC7
  7. #include <open62541/types.h>
  8. #undef UA_fileExists
  9. UA_Boolean UA_fileExists(const char* path) {
  10. FILE *fp = fopen(path,"rb");
  11. UA_Boolean exists = (fp==NULL);
  12. if(fp)
  13. fclose(fp);
  14. return exists;
  15. }
  16. unsigned int UA_socket_set_blocking(UA_SOCKET sockfd){
  17. u_long iMode = 0;
  18. if(ioctlsocket(sockfd, FIONBIO, &iMode) != NO_ERROR)
  19. return UA_STATUSCODE_BADINTERNALERROR;
  20. return UA_STATUSCODE_GOOD;;
  21. }
  22. #ifdef UNDER_CE
  23. char *strerror(int errnum)
  24. {
  25. if (errnum > MAX_STRERROR)
  26. return errorStrings[MAX_STRERROR];
  27. else
  28. return errorStrings[errnum];
  29. }
  30. #endif
  31. unsigned int UA_socket_set_nonblocking(UA_SOCKET sockfd){
  32. u_long iMode = 1;
  33. if(ioctlsocket(sockfd, FIONBIO, &iMode) != NO_ERROR)
  34. return UA_STATUSCODE_BADINTERNALERROR;
  35. return UA_STATUSCODE_GOOD;;
  36. }
  37. void UA_initialize_architecture_network(void){
  38. WSADATA wsaData;
  39. WSAStartup(MAKEWORD(2, 2), &wsaData);
  40. }
  41. void UA_deinitialize_architecture_network(void){
  42. WSACleanup();
  43. }
  44. #endif /* UA_ARCHITECTURE_WEC7 */