00001 /* 00002 * finflect - Algorithms and tools for inflecting Finnish nouns 00003 * Copyright (C) 2004, 2005 The FinFlect Team 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 * 00019 * 00020 * For the complete legal text of the GNU Lesser General Public License, 00021 * see the file LICENSE. For a complete list of authors and copyright 00022 * holders, see the file AUTHORS. 00023 */ 00024 00025 /** 00026 * @file ffword.c Implements functions for manipulating instances of 00027 * the ffword data type. They are declared along with the data type 00028 * itself in ffword.h. 00029 */ 00030 00031 #include <string.h> 00032 00033 #include "ffword.h" 00034 00035 ffint32 ffword_create(const ffchar* source, ffword* target) { 00036 ffint32 err; 00037 00038 if((err = ffstring_create(source, &target->data))) 00039 return err; 00040 00041 memset(&target->metadata, 0, sizeof(ffops)); 00042 00043 return 0; 00044 } 00045 00046 ffint32 ffword_copy(ffword* source, ffword* target) { 00047 ffint32 err; 00048 00049 if((err = ffstring_copy(&source->data, &target->data))) 00050 return err; 00051 00052 memcpy(&target->metadata, &source->metadata, sizeof(ffops)); 00053 00054 return 0; 00055 } 00056 00057 ffint32 ffword_delete(ffword* target) { 00058 ffint32 err; 00059 00060 if((err = ffstring_delete(&target->data))) 00061 return err; 00062 00063 return 0; 00064 } 00065 00066 ffint32 ffword_swap_delete(ffword* source, ffword* target) { 00067 ffint32 err; 00068 00069 if((err = ffstring_delete(&target->data))) 00070 return err; 00071 00072 target->data = source->data; 00073 /* Target is now new owner of the data 00074 * so don't do 00075 * ffword_delete(source); 00076 * ALSO don't do 00077 * ffword_finalize(source); 00078 * because ffstring_delete does it already 00079 */ 00080 00081 return 0; 00082 } 00083 00084 ffint32 ffword_finalize(ffword* target) { 00085 ffstring_decinst(); 00086 return 0; 00087 } 00088