group.c

Go to the documentation of this file.
00001 /*
00002  *  group.c
00003  *
00004  *  Copyright (c) 2002-2007 by Judd Vinet <jvinet@zeroflux.org>
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00018  */
00019 
00020 #include "config.h"
00021 
00022 #include <stdlib.h>
00023 #include <stdio.h>
00024 #include <string.h>
00025 
00026 /* libalpm */
00027 #include "group.h"
00028 #include "alpm_list.h"
00029 #include "util.h"
00030 #include "error.h"
00031 #include "log.h"
00032 #include "alpm.h"
00033 
00034 pmgrp_t *_alpm_grp_new()
00035 {
00036     pmgrp_t* grp;
00037 
00038     ALPM_LOG_FUNC;
00039 
00040     CALLOC(grp, 1, sizeof(pmgrp_t), RET_ERR(PM_ERR_MEMORY, NULL));
00041 
00042     return(grp);
00043 }
00044 
00045 void _alpm_grp_free(pmgrp_t *grp)
00046 {
00047     ALPM_LOG_FUNC;
00048 
00049     if(grp == NULL) {
00050         return;
00051     }
00052 
00053     FREELIST(grp->packages);
00054     FREE(grp);
00055 }
00056 
00057 /* Helper function for sorting groups
00058  */
00059 int _alpm_grp_cmp(const void *g1, const void *g2)
00060 {
00061     pmgrp_t *grp1 = (pmgrp_t *)g1;
00062     pmgrp_t *grp2 = (pmgrp_t *)g2;
00063 
00064     return(strcmp(grp1->name, grp2->name));
00065 }
00066 
00067 const char SYMEXPORT *alpm_grp_get_name(const pmgrp_t *grp)
00068 {
00069     ALPM_LOG_FUNC;
00070 
00071     /* Sanity checks */
00072     ASSERT(grp != NULL, return(NULL));
00073 
00074     return grp->name;
00075 }
00076 
00077 const alpm_list_t SYMEXPORT *alpm_grp_get_pkgs(const pmgrp_t *grp)
00078 {
00079     ALPM_LOG_FUNC;
00080 
00081     /* Sanity checks */
00082     ASSERT(grp != NULL, return(NULL));
00083 
00084     return grp->packages;
00085 }
00086 /* vim: set ts=2 sw=2 noet: */

Generated on Mon Jan 14 23:53:40 2008 for libalpm by  doxygen 1.5.4