internal.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /********************************************************************
  2. * *
  3. * THIS FILE IS PART OF THE libopusfile SOFTWARE CODEC SOURCE CODE. *
  4. * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
  5. * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
  6. * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
  7. * *
  8. * THE libopusfile SOURCE CODE IS (C) COPYRIGHT 2012 *
  9. * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
  10. * *
  11. ********************************************************************/
  12. #ifdef HAVE_CONFIG_H
  13. #include "config.h"
  14. #endif
  15. #include "internal.h"
  16. #if defined(OP_ENABLE_ASSERTIONS)
  17. void op_fatal_impl(const char *_str,const char *_file,int _line){
  18. fprintf(stderr,"Fatal (internal) error in %s, line %i: %s\n",
  19. _file,_line,_str);
  20. abort();
  21. }
  22. #endif
  23. /*A version of strncasecmp() that is guaranteed to only ignore the case of
  24. ASCII characters.*/
  25. int op_strncasecmp(const char *_a,const char *_b,int _n){
  26. int i;
  27. for(i=0;i<_n;i++){
  28. int a;
  29. int b;
  30. int d;
  31. a=_a[i];
  32. b=_b[i];
  33. if(a>='a'&&a<='z')a-='a'-'A';
  34. if(b>='a'&&b<='z')b-='a'-'A';
  35. d=a-b;
  36. if(d)return d;
  37. }
  38. return 0;
  39. }