#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <stdlib.h>
Go to the source code of this file.
Defines | |
#define | STRING 0 |
#define | INTEGER 1 |
#define | FLOAT 2 |
Functions | |
int | InputType () |
void | WrongType () |
float | GetResol (float, float, float) |
void | RemoveBlanks () |
void | swapshort () |
void | swaplong () |
int | InputType (char *string) |
void | WrongType (int type, char *key, char *string) |
void | RemoveBlanks (char *str) |
void | swaplong (char *data, int nbytes) |
void | swapshort (unsigned short *data, int n) |
#define FLOAT 2 |
Definition at line 24 of file utils.c.
Referenced by InputType(), and WrongType().
#define INTEGER 1 |
Definition at line 23 of file utils.c.
Referenced by InputType(), and WrongType().
#define STRING 0 |
Definition at line 22 of file utils.c.
Referenced by InputType().
float GetResol | ( | float | radius, |
float | distance, | ||
float | wave | ||
) |
Definition at line 37 of file utils.c.
Referenced by MarXF::get_header_values().
{ float res; if ( distance < 1.0 ) return 0.0; res = atan( radius/distance); /* Two theta !!! */ if ( res < 0.0001 ) return 0.0; res = wave/(2.0*sin(res/2.0)); return( res ); }
int InputType | ( | ) |
int InputType | ( | char * | string | ) |
Definition at line 56 of file utils.c.
References FLOAT, i, INTEGER, j, and STRING.
{ int i,j=0,k=0,l=0; for ( i=0 ; i<strlen(string)-1; i++ ) { if ( isspace( string[i] ) ) { string[i] = ' '; j++; } else if ( string[i] == '.' ) { k++; continue; } else if ( string[i] == '-' || string[i] == '+' ) { l++; continue; } else if ( isdigit( string[i] ) ) { j++; continue; } } if ( k == 1 && l == 0 && j == i-1 ) return( FLOAT ); else if ( k == 1 && l == 1 && j == i-2 ) return( FLOAT ); else if ( k == 0 && l == 1 && j == i-1 ) return( INTEGER ); else if ( k == 0 && l == 0 && j == i ) return( INTEGER ); else return( STRING ); }
void RemoveBlanks | ( | ) |
void RemoveBlanks | ( | char * | str | ) |
Definition at line 113 of file utils.c.
Referenced by Command::BadInput(), GetConfig(), Getmar345Header(), GetmarNBHeader(), and Command::TestDirectory().
void swaplong | ( | char * | data, |
int | nbytes | ||
) |
Definition at line 129 of file utils.c.
References i.
Referenced by Getmar300Header(), MarXF::mar_start_scan_readout(), MarNet::net_comm(), MarNet::net_stat(), and MarHW::print_msg().
{ register int i, t1, t2, t3, t4; for(i=nbytes/4;i--;) { t1 = data[i*4+3]; t2 = data[i*4+2]; t3 = data[i*4+1]; t4 = data[i*4+0]; data[i*4+0] = t1; data[i*4+1] = t2; data[i*4+2] = t3; data[i*4+3] = t4; } }
void swaplong | ( | ) |
void swapshort | ( | unsigned short * | data, |
int | n | ||
) |
void swapshort | ( | ) |
void WrongType | ( | ) |