fork(1) download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #define ATTRIBUTE struct attribute
  5. ATTRIBUTE{
  6. int token;
  7. #define MAX_BUFFER_SIZE 128
  8. char buffer[MAX_BUFFER_SIZE];
  9. int length;
  10. #define FORMAT_NONE 0
  11. #define FORMAT_CHAR 1
  12. #define FORMAT_DECIMAL 2
  13. #define FORMAT_HEXIDECIMAL 3
  14. #define FORMAT_OCTAL 4
  15. #define FORMAT_FLOAT 5
  16. int format;
  17. };
  18.  
  19. #define DATA struct data
  20. DATA
  21. {
  22. //define the scanner attribute table
  23. #define MAX_ATTRIBUTES 128
  24. ATTRIBUTE attributes[MAX_ATTRIBUTES];
  25. unsigned int index;
  26. int column;
  27. int flags;
  28. #define FLAGS_ECHO 0x0001
  29. #define FLAGS_DEBUG 0x0002
  30. #define FLAGS_PARSE 0x0004
  31. #define FLAGS_SYMBOL 0x0008
  32. #define IS_FLAGS_ECHO(a) (a & FLAGS_ECHO)
  33. #define SET_FLAGS_ECHO(a) (a |= FLAGS_ECHO)
  34. #define CLR_FLAGS_ECHO(a) (a &= ~FLAGS_ECHO)
  35. #define IS_FLAGS_DEBUG(a) (a & FLAGS_DEBUG)
  36. #define SET_FLAGS_DEBUG(a) (a |= FLAGS_DEBUG)
  37. #define CLR_FLAGS_DEBUG(a) (a &= ~FLAGS_DEBUG)
  38. #define IS_FLAGS_PARSE(a) (a & FLAGS_PARSE)
  39. #define SET_FLAGS_PARSE(a) (a |= FLAGS_PARSE)
  40. #define CLR_FLAGS_PARSE(a) (a &= ~FLAGS_PARSE)
  41. #define IS_FLAGS_SYMBOL(a) (a & FLAGS_SYMBOL)
  42. #define SET_FLAGS_SYMBOL(a) (a |= FLAGS_SYMBOL)
  43. #define CLR_FLAGS_SYMBOL(a) (a &= ~FLAGS_SYMBOL)
  44. };
  45.  
  46. int main(void) {
  47. int token = 1;
  48. char buffer[] = "This Is A Buffer";
  49. int length = strlen(buffer);
  50. int format = 1;
  51. struct data data = {.flags = 255};
  52. struct attribute attr = {.token = token, .buffer = buffer, .length = length, .format = format};
  53. fprintf(stdout, "after struct: %d\n", data.flags);
  54. data.attributes[0] = attr;
  55. fprintf(stdout, "after data.attributes[i] = attr: %d\n", data.flags);
  56. return 0;
  57. }
  58.  
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
after struct: 255
after data.attributes[i] = attr: 255