TPCCLIB
Loading...
Searching...
No Matches
parorder.c File Reference

Sort or otherwise change the order of data in PAR struct. More...

#include "tpcclibConfig.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include "tpcpar.h"

Go to the source code of this file.

Functions

int parSortByName (PAR *d, TPCSTATUS *status)

Detailed Description

Sort or otherwise change the order of data in PAR struct.

Definition in file parorder.c.

Function Documentation

◆ parSortByName()

int parSortByName ( PAR * d,
TPCSTATUS * status )

Sort TACs in alphabetical order by their TAC name.

Returns
enum tpcerror (TPCERROR_OK when successful).
See also
parSelectTACs, tacSortByName, parEnsureNames
Parameters
dPointer to PAR struct.
statusPointer to status data; enter NULL if not needed.

Definition at line 30 of file parorder.c.

35 {
36 int verbose=0; if(status!=NULL) verbose=status->verbose;
37 if(verbose>0) printf("%s()\n", __func__);
38 /* Check that required data exists */
39 if(d==NULL) {
40 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_NO_DATA);
41 return TPCERROR_NO_DATA;
42 }
43 if(d->tacNr>d->_tacNr) {
44 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_FAIL);
45 return TPCERROR_FAIL;
46 }
47 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_OK);
48 if(d->tacNr<2) return TPCERROR_OK;
49 qsort(d->r, d->tacNr, sizeof(PARR), parQSortName);
50 return TPCERROR_OK;
51}
void statusSet(TPCSTATUS *s, const char *func, const char *srcfile, int srcline, tpcerror error)
Definition statusmsg.c:142
int tacNr
Definition tpcpar.h:104
PARR * r
Definition tpcpar.h:114
int _tacNr
Definition tpcpar.h:106
Definition tpcpar.h:46
int verbose
Verbose level, used by statusPrint() etc.
@ TPCERROR_FAIL
General error.
@ TPCERROR_OK
No error.
@ TPCERROR_NO_DATA
File contains no data.