Actual source code: aodataalias.c

      1: #define PETSCDM_DLL

     3:  #include src/dm/ao/aoimpl.h

      7: /*@C
      8:     AODataAddAlias - Allows accessing a key or field using an alternative
      9:           name.

     11:     Not collective

     13:     Input Parameters:
     14: +   ao - the AOData database
     15: .   alias - substitute name that may be used
     16: -   name - name the alias replaces

     18:    Level: intermediate

     20: .keywords: aliases, keys, fields

     22: .seealso:
     23: @*/
     24: PetscErrorCode PETSCDM_DLLEXPORT AODataAddAlias(AOData ao,char *alias,char *name)
     25: {
     26:   AODataAlias *aoalias,*t;

     32:   PetscNew(AODataAlias,&aoalias);
     33:   PetscStrallocpy(alias,&aoalias->alias);
     34:   PetscStrallocpy(name,&aoalias->name);
     35:   aoalias->next = PETSC_NULL;

     37:   if (!ao->aliases) {
     38:     ao->aliases = aoalias;
     39:   } else {
     40:     t = ao->aliases;
     41:     while (t->next) t = t->next;
     42:     t->next = aoalias;
     43:   }

     45:   return(0);
     46: }