00001 /*------------------------------------------------------------------------ 00002 *--------------------- RT-WMP -------------------- 00003 *------------------------------------------------------------------------ 00004 * 00005 * 00006 * 00007 * File: ./src/platforms/linux_ks/config/compiler.c 00008 * Authors: Rubén Durán 00009 * Danilo Tardioli 00010 * ---------------------------------------------------------------------- 00011 * Copyright (C) 2000-2011, Universidad de Zaragoza, SPAIN 00012 * 00013 * Contact Addresses: Danilo Tardioli dantard@unizar.es 00014 * 00015 * RT-WMP is free software; you can redistribute it and/or modify it 00016 * under the terms of the GNU General Public License as published by the 00017 * Free Software Foundation; either version 2, or (at your option) any 00018 * later version. 00019 * 00020 * RT-WMP is distributed in the hope that it will be useful, but 00021 * WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00023 * General Public License for more details. 00024 * 00025 * You should have received a copy of the GNU General Public License 00026 * distributed with RT-WMP; see file COPYING. If not, write to the 00027 * Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 00028 * 02111-1307, USA. 00029 * 00030 * As a special exception, if you link this unit with other files to 00031 * produce an executable, this unit does not by itself cause the 00032 * resulting executable to be covered by the GNU General Public License. 00033 * This exception does not however invalidate any other reasons why the 00034 * executable file might be covered by the GNU Public License. 00035 * 00036 *----------------------------------------------------------------------*/ 00037 00038 #include "compiler.h" 00039 #include <asm/uaccess.h> 00040 00041 void inline atof(const char *cadena, double *res){ 00042 int entero, decimal, decimales; 00043 char *next; 00044 entero = (int) simple_strtol(cadena,&next,10); 00045 decimales = strlen(next+1); 00046 decimal = (int) simple_strtol(next+1,&next,10); 00047 00048 /* kernel_fpu_begin(); 00049 *res = decimal; 00050 while (decimales > 0) 00051 { 00052 *res = *res/10; 00053 decimales--; 00054 } 00055 *res += entero; 00056 kernel_fpu_end(); 00057 */ 00058 } 00059 00060 char * fgets(char *s, int size, struct file *f){ 00061 mm_segment_t oldfs; 00062 int i, leido; 00063 00064 if (size > 0) 00065 { 00066 oldfs = get_fs(); 00067 set_fs(get_ds()); 00068 00069 i = 0; 00070 do { 00071 leido=vfs_read(f,&s[i],1, &f->f_pos); 00072 i++; 00073 }while(i<size-1 && leido && s[i-1] !='\n'); 00074 // Leemos letra a letra hasta encontrar el fin del fichero, un salto de 00075 // linea o alcanzar 'size' 00076 00077 set_fs(oldfs); 00078 00079 00080 if(!leido && i==1) 00081 return NULL; 00082 else if (i == size-1) 00083 s[i]='\0'; 00084 else 00085 s[i-1]='\0'; 00086 00087 return s; 00088 } 00089 return NULL; 00090 } 00091 EXPORT_SYMBOL(fgets);