matrixtest.c

Go to the documentation of this file.
00001 /**
00002  * @file matrixtest.c
00003  * Try out the ccn/matrix calls.
00004  * 
00005  * A CCNx program.
00006  *
00007  * Copyright (C) 2009 Palo Alto Research Center, Inc.
00008  *
00009  * This work is free software; you can redistribute it and/or modify it under
00010  * the terms of the GNU General Public License version 2 as published by the
00011  * Free Software Foundation.
00012  * This work is distributed in the hope that it will be useful, but WITHOUT ANY
00013  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
00015  * for more details. You should have received a copy of the GNU General Public
00016  * License along with this program; if not, write to the
00017  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019  */
00020 #include <stdlib.h>
00021 #include <stdint.h>
00022 #include <stdio.h>
00023 #include <string.h>
00024 #include <ccn/matrix.h>
00025 
00026 void
00027 Dump(struct ccn_matrix *m)
00028 {
00029     struct ccn_matrix_bounds r;
00030     int res = ccn_matrix_getbounds(m, &r);
00031     printf("ccn_matrix_getbounds res = %d, rows [%ld..%ld), cols [%ld..%ld)\n",
00032             res,
00033             (long)r.row_min, (long)r.row_max, 
00034             (long)r.col_min, (long)r.col_max);
00035 }
00036 
00037 int
00038 main(int argc, char **argv)
00039 {
00040     //char buf[1024] = {0};
00041     struct ccn_matrix *m;
00042     
00043     m = ccn_matrix_create();
00044     
00045     Dump(m);
00046     printf("%d: %ld\n", __LINE__, (long)ccn_matrix_fetch(m, 1, 100));
00047     Dump(m); printf("                   ccn_matrix_store(m, 1, 100, 30);"  "\n");
00048                                         ccn_matrix_store(m, 1, 100, 30);
00049     Dump(m);
00050     printf("%d: %ld\n", __LINE__, (long)ccn_matrix_fetch(m, 31415926, 101));
00051     printf("%d: %ld\n", __LINE__, (long)ccn_matrix_fetch(m, 1, 100));
00052     Dump(m); printf("                   ccn_matrix_store(m, 31415926, 101, 43);"  "\n");
00053                                         ccn_matrix_store(m, 31415926, 101, 43);
00054     printf("%d: %ld\n", __LINE__, (long)ccn_matrix_fetch(m, 31415926, 101));
00055     printf("%d: %ld\n", __LINE__, (long)ccn_matrix_fetch(m, 1, 100));
00056     Dump(m);
00057     printf("%d: %ld\n", __LINE__, (long)ccn_matrix_fetch(m, 1, 100));
00058     Dump(m); printf("                   ccn_matrix_store(m, 1, 100, 0);"  "\n");
00059                                         ccn_matrix_store(m, 1, 100, 0);
00060     printf("%d: %ld\n", __LINE__, (long)ccn_matrix_fetch(m, 31415926, 101));
00061     printf("%d: %ld\n", __LINE__, (long)ccn_matrix_fetch(m, 1, 100));                                         
00062     Dump(m); printf("                   ccn_matrix_store(m, 31415926, 101, 0);"  "\n");
00063                                         ccn_matrix_store(m, 31415926, 101, 0);
00064     printf("%d: %ld\n", __LINE__, (long)ccn_matrix_fetch(m, 31415926, 101));
00065     printf("%d: %ld\n", __LINE__, (long)ccn_matrix_fetch(m, 1, 100));                                         
00066     Dump(m);
00067     ccn_matrix_destroy(&m);
00068     return(0);
00069 }
Generated on Fri May 13 16:27:03 2011 for Content-Centric Networking in C by  doxygen 1.6.3