:: Re: [DNG] Systemd Shims
Startseite
Nachricht löschen
Nachricht beantworten
Autor: tilt!
Datum:  
To: dng
Betreff: Re: [DNG] Systemd Shims
Hi Edward,

On 08/19/2015 03:29 PM, Edward Bartolo wrote:
> [...]
> The C code:
 > [...]
> #define opSave                0
> #define opSaveConnect            1
> #define opQueryConnect            2
> #define opDeleteConnect            3
> #define opConnectionConnect            4
> #define opDisconnectActiveConnection    5
> #define opScan                6
> #define opLoadExisting            7
 > [...]


It is maybe more elegant to write

```C
typedef enum {
    opSave = 0,
    opSaveConnect = 1,
    // etc etc
} ops_t;
```


That way you immediately have a well-defined datatype ops_t
for passing your operations around.

Personally, I would treat the numerical value 0 differently,
and start with 1 for the actual operations, like,

```C
typedef enum {
    opNone = 0,
    opSave = 1,
    opSaveConnect = 2,
    // etc etc
} ops_t;
```


That way you can write in main():

```C
    ops_t switch_item = opNone;
    int i;
```


which I like better than assuming that -1 means anything
in particular.

Kind regards,
T.