Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.38 KB | None | 0 0
  1.  
  2.  
  3.  
  4.  
  5. #define DEVICE_NAME_MAX_LENGTH 10
  6. #define DEVICE_SERIAL_MAX_LENGTH 20
  7.  
  8. typedef struct
  9. {
  10.     struct
  11.     {
  12.         char name[DEVICE_NAME_MAX_LENGTH + 1];
  13.         char serial[DEVICE_SERIAL_MAX_LENGTH + 1];
  14.     }
  15.     device;
  16.  
  17.     struct
  18.     {
  19.         uint32_t levelMask;
  20.         uint32_t outputMask;
  21.     }
  22.     syslog;
  23.  
  24.     struct
  25.     {
  26.  
  27.  
  28.     }
  29.     dvr;
  30.  
  31.     struct
  32.     {
  33.         struct
  34.         {
  35.             struct
  36.             {
  37.  
  38.  
  39.             }
  40.             courier;
  41.  
  42.             struct
  43.             {
  44.  
  45.  
  46.             }
  47.             client;
  48.         }
  49.         process;
  50.  
  51.  
  52.     }
  53.     scl;
  54. }
  55. MainConfig_t;
  56.  
  57. typedef struct
  58. {
  59.     char*    jsonDescriptor;
  60.     uint32_t structPosition;
  61.     uint32_t flashPosition;
  62.     uint32_t size;
  63.     void*    def;
  64. }
  65. MainConfigEntry_t;
  66.  
  67. const MainConfigEntry_t MainConfigDescriptor[] =
  68. {
  69.     {"device.name",         offsetof(MainConfig_t, device.name),        128,        DEVICE_NAME_MAX_LENGTH + 1,     (void*)"DEF_NAME"},
  70.     {"device.serial",       offsetof(MainConfig_t, device.serial),      128,        DEVICE_SERIAL_MAX_LENGTH + 1,   (void*)"DEF_NAME"},
  71.     {"syslog.levelMask",    offsetof(MainConfig_t, syslog.levelMask),   128,        sizeof(uint32_t),               (void*)(LOG_LVL_INFO | LOG_LVL_WARN | LOG_LVL_ERR)},
  72.     {"syslog.outputMask",   offsetof(MainConfig_t, syslog.outputMask),  0xFFFFFFFF, sizeof(uint32_t),               (void*)(LOG_LVL_INFO | LOG_LVL_WARN | LOG_LVL_ERR)},
  73.  
  74. };
  75.  
  76.  
  77. void MainConfigLoad(void)
  78. {
  79.     //...
  80. }
  81.  
  82. MainConfig_t MainConfig;
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89. void ExampleFunction(void)
  90. {
  91.  
  92.     printf("MachineName: %s", MainConfig.device.name);
  93.  
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement