Main Page | Class Hierarchy | Class List | File List | Class Members

cclassad.h

00001 /*********************************************************************
00002  *
00003  * Condor ClassAd library
00004  * Copyright (C) 1990-2003, Condor Team, Computer Sciences Department,
00005  * University of Wisconsin-Madison, WI and Rajesh Raman.
00006  *
00007  * This source code is covered by the Condor Public License, which can
00008  * be found in the accompanying LICENSE file, or online at
00009  * www.condorproject.org.
00010  *
00011  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00012  * AND THE UNIVERSITY OF WISCONSIN-MADISON "AS IS" AND ANY EXPRESS OR
00013  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00014  * WARRANTIES OF MERCHANTABILITY, OF SATISFACTORY QUALITY, AND FITNESS
00015  * FOR A PARTICULAR PURPOSE OR USE ARE DISCLAIMED. THE COPYRIGHT
00016  * HOLDERS AND CONTRIBUTORS AND THE UNIVERSITY OF WISCONSIN-MADISON
00017  * MAKE NO MAKE NO REPRESENTATION THAT THE SOFTWARE, MODIFICATIONS,
00018  * ENHANCEMENTS OR DERIVATIVE WORKS THEREOF, WILL NOT INFRINGE ANY
00019  * PATENT, COPYRIGHT, TRADEMARK, TRADE SECRET OR OTHER PROPRIETARY
00020  * RIGHT.
00021  *
00022  *********************************************************************/
00023 
00024 #ifndef __CCLASSAD_H_
00025 #define __CCLASSAD_H_
00026 
00027 /*
00028 This is a C interface to the classad library.
00029 This allows programs to use the ClassAd library in
00030 a compiler-independent fashion with traditional constructs
00031 such as integers and C strings.  No special compiler flags
00032 or other packages are necessary to use this interface.
00033 */
00034 
00035 #ifdef __cplusplus
00036 BEGIN_NAMESPACE( classad )
00037 extern "C" {
00038 #endif
00039 
00040 struct classad;
00041 
00042 /*
00043 Create and delete ClassAds.
00044 If str is null, the ad is empty.
00045 If str is non-null, the ad is parsed from the given string.
00046 Returns a new ClassAd or null if the input is invalid or memory is full.
00047 */
00048 
00049 struct cclassad * cclassad_create( const char *str );
00050 void cclassad_delete( struct cclassad *c );
00051 
00052 /*
00053 Display a ClassAd in its external representation.
00054 Returns a string allocated with malloc().
00055 The user is responsible for freeing it.
00056 */
00057 
00058 char * cclassad_unparse( struct cclassad *c );
00059 char * cclassad_unparse_xml( struct cclassad *c );
00060 
00061 /*
00062 Check to see if two ClassAds match.
00063 Return true if their requirements expressions are
00064 mutually satisfied.  Otherwise, return false.
00065 */
00066 
00067 int cclassad_match( struct cclassad *a, struct cclassad *b );
00068 
00069 /*
00070 Four ways to insert elements into a classad.
00071 In each case, "attr" names the attribute to be
00072 inserted. In the "expr" form, the "value" must be a ClassAd
00073 expression which is parsed and then inserted.
00074 The remaining forms insert atomic types without parsing.
00075 Returns true on success, false on failure.
00076 */
00077 
00078 int cclassad_insert_expr( struct cclassad *c, const char *attr, const char *value );
00079 int cclassad_insert_string( struct cclassad *c, const char *attr, const char *value );
00080 int cclassad_insert_double( struct cclassad *c, const char *attr, double value );
00081 int cclassad_insert_int( struct cclassad *c, const char *attr, int value ); 
00082 int cclassad_insert_bool( struct cclassad *c, const char *attr, int value );
00083 
00084 /*
00085 Remove the named element from the ClassAd.
00086 Returns true if the attribute existed, false otherwise.
00087 */
00088 
00089 int cclassad_remove( struct cclassad *c, const char *attr );
00090 
00091 /*
00092 Four ways to evaluate the contents of a classad.
00093 In each case, "expr" is an expression to be parsed and evaluted.
00094 In the "to_expr" form, the result is given as an expression in
00095 external form allocated with malloc().  The caller must free() it.
00096 In the remaining forms, the results are given as atomic values
00097 that need not be parsed.  Returns true on success, false on failure.
00098 */
00099 
00100 int cclassad_evaluate_to_expr( struct cclassad *c, const char *expr, char **result );
00101 int cclassad_evaluate_to_string( struct cclassad *c, const char *expr, char **result );
00102 int cclassad_evaluate_to_double( struct cclassad *c, const char *expr, double *result );
00103 int cclassad_evaluate_to_int( struct cclassad *c, const char *expr, int *result );
00104 int cclassad_evaluate_to_bool( struct cclassad *c, const char *expr, int *result );
00105 
00106 #ifdef __cplusplus
00107 }
00108 END_NAMESPACE
00109 #endif
00110 
00111 #endif