-
-bool do_qos_set (int nb, const char **com, struct ngadmin *nga) {
-
- int i, p;
- const struct swi_attr *sa;
- bool ret=true;
- char d=PRIO_UNSPEC, *ports=NULL;
-
-
- if ( nb<2 ) {
- printf("Usage: qos set (all <prio0>)|(<port1> <prio1> [<port2> <prio2> ...])\n");
- ret=false;
- goto end;
- }
-
- if ( (sa=ngadmin_getCurrentSwitch(nga))==NULL ) {
- printf("must be logged\n");
- ret=false;
- goto end;
- }
-
-
- ports=malloc(sa->ports*sizeof(char));
-
- if ( strcmp(com[0], "all")==0 ) {
- d=parsePrio(com[1]);
- com+=2;
- nb-=2;
- }
-
- for (i=0; i<sa->ports; ++i) {
- ports[i]=d;
- }
-
- for (i=0; i<nb; i+=2) {
- if ( (p=strtol(com[i], NULL, 0))<1 || p>sa->ports ) continue;
- ports[p-1]=parsePrio(com[i+1]);
- }
-
-
- i=ngadmin_setQOSValues(nga, ports);
- printErrCode(i);
-
-
- end:
- free(ports);
-
- return ret;
-
+bool do_qos_set (int nb, const char **com, struct ngadmin *nga)
+{
+ int i, p;
+ const struct swi_attr *sa;
+ bool ret = true;
+ char d = PRIO_UNSPEC, *ports = NULL;
+
+
+ if (nb < 2) {
+ printf("Usage: qos set (all <prio0>)|(<port1> <prio1> [<port2> <prio2> ...])\n");
+ ret = false;
+ goto end;
+ }
+
+ sa = ngadmin_getCurrentSwitch(nga);
+ if (sa ==NULL) {
+ printf("must be logged\n");
+ ret = false;
+ goto end;
+ }
+
+ ports = malloc(sa->ports * sizeof(char));
+
+ if (strcmp(com[0], "all") == 0) {
+ d = parsePrio(com[1]);
+ com += 2;
+ nb -= 2;
+ }
+
+ for (i = 0; i < sa->ports; i++)
+ ports[i] = d;
+
+ for (i = 0; i < nb; i += 2) {
+ p = strtol(com[i], NULL, 0);
+ if (p < 1 || p > sa->ports)
+ continue;
+ ports[p - 1] = parsePrio(com[i + 1]);
+ }
+
+ i = ngadmin_setQOSValues(nga, ports);
+ printErrCode(i);
+
+end:
+ free(ports);
+
+ return ret;